refactor: update existing buttons
This commit is contained in:
parent
3507e9f4cf
commit
f8c25096fd
2 changed files with 11 additions and 5 deletions
|
|
@ -253,12 +253,13 @@ impl button::StyleSheet for Theme {
|
|||
return active(self);
|
||||
}
|
||||
|
||||
let corner_radii = &self.cosmic().corner_radii;
|
||||
let component = style.cosmic(self);
|
||||
button::Appearance {
|
||||
border_radius: match style {
|
||||
Button::Link => 0.0.into(),
|
||||
Button::Card => 8.0.into(),
|
||||
_ => 24.0.into(),
|
||||
Button::Link => corner_radii.radius_0.into(),
|
||||
Button::Card => corner_radii.radius_xs.into(),
|
||||
_ => corner_radii.radius_xl.into(),
|
||||
},
|
||||
background: match style {
|
||||
Button::Link | Button::Text => None,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::{theme, Element, Renderer};
|
||||
use crate::{
|
||||
theme::{self, THEME},
|
||||
Element, Renderer,
|
||||
};
|
||||
use iced::widget;
|
||||
|
||||
/// A button widget with COSMIC styling
|
||||
|
|
@ -44,9 +47,11 @@ impl<Message: 'static> Button<Message> {
|
|||
|
||||
/// A custom button that has the desired default spacing and padding.
|
||||
pub fn custom(self, children: Vec<Element<Message>>) -> widget::Button<Message, Renderer> {
|
||||
let theme = THEME.with(|t| t.borrow().clone());
|
||||
let theme = theme.cosmic();
|
||||
let button = widget::button(widget::row(children).spacing(8))
|
||||
.style(self.style)
|
||||
.padding([8, 16]);
|
||||
.padding([theme.space_xs(), theme.space_s()]);
|
||||
|
||||
if let Some(message) = self.message {
|
||||
button.on_press(message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue