Update icon size
This commit is contained in:
parent
af72772a72
commit
f9efaebddf
1 changed files with 13 additions and 7 deletions
|
@ -1,15 +1,26 @@
|
||||||
use gpui::{rems, svg, IntoElement, Svg};
|
use gpui::{rems, svg, IntoElement, Rems, Svg};
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Copy, Clone)]
|
#[derive(Default, PartialEq, Copy, Clone)]
|
||||||
pub enum IconSize {
|
pub enum IconSize {
|
||||||
|
XSmall,
|
||||||
Small,
|
Small,
|
||||||
#[default]
|
#[default]
|
||||||
Medium,
|
Medium,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IconSize {
|
||||||
|
pub fn rems(self) -> Rems {
|
||||||
|
match self {
|
||||||
|
IconSize::XSmall => rems(12. / 16.),
|
||||||
|
IconSize::Small => rems(14. / 16.),
|
||||||
|
IconSize::Medium => rems(16. / 16.),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Copy, Clone, EnumIter)]
|
#[derive(Debug, PartialEq, Copy, Clone, EnumIter)]
|
||||||
pub enum Icon {
|
pub enum Icon {
|
||||||
Ai,
|
Ai,
|
||||||
|
@ -170,13 +181,8 @@ impl RenderOnce for IconElement {
|
||||||
type Rendered = Svg;
|
type Rendered = Svg;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
let svg_size = match self.size {
|
|
||||||
IconSize::Small => rems(12. / 16.),
|
|
||||||
IconSize::Medium => rems(16. / 16.),
|
|
||||||
};
|
|
||||||
|
|
||||||
svg()
|
svg()
|
||||||
.size(svg_size)
|
.size(self.size.rems())
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.path(self.path)
|
.path(self.path)
|
||||||
.text_color(self.color.color(cx))
|
.text_color(self.color.color(cx))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue