forked from reya/gpui-native-kit
add icon button
This commit is contained in:
@@ -134,6 +134,7 @@ impl RenderOnce for Button {
|
||||
|
||||
let on_click = self.on_click;
|
||||
let a11y_label = self.a11y_label.or_else(|| self.label.clone());
|
||||
let icon_only = self.label.is_none() && self.icon.is_some();
|
||||
|
||||
let (background, foreground, hover, pressed) = match self.variant {
|
||||
ButtonVariant::Primary => (
|
||||
@@ -166,8 +167,10 @@ impl RenderOnce for Button {
|
||||
.id(self.id)
|
||||
.role(Role::Button)
|
||||
.justify_center()
|
||||
.h(metrics.control_height)
|
||||
.px(metrics.padding_x)
|
||||
.when(icon_only, |button| button.size(metrics.control_height))
|
||||
.when(!icon_only, |button| {
|
||||
button.h(metrics.control_height).px(metrics.padding_x)
|
||||
})
|
||||
.line_height(relative(1.0))
|
||||
.gap_1p5()
|
||||
.rounded(theme.radius.control)
|
||||
|
||||
Reference in New Issue
Block a user