Skip to content
Snippets Groups Projects
Commit 1eb7474b authored by MrGVSV's avatar MrGVSV
Browse files

Fixed some style issues in widgets

parent a34ef422
No related branches found
No related tags found
No related merge requests found
...@@ -38,24 +38,23 @@ impl WidgetProps for ButtonProps { ...@@ -38,24 +38,23 @@ impl WidgetProps for ButtonProps {
#[widget] #[widget]
pub fn Button(props: ButtonProps) { pub fn Button(props: ButtonProps) {
let base_styles = props.styles.clone().unwrap_or_default(); props.styles = Some(
props.styles = Some(Style { Style::default()
render_command: StyleProp::Value(RenderCommand::Quad), .with_style(Style {
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), render_command: StyleProp::Value(RenderCommand::Quad),
height: if base_styles.height == StyleProp::Default { ..Default::default()
StyleProp::Value(Units::Pixels(45.0)) })
} else { .with_style(&props.styles)
base_styles.height .with_style(Style {
}, background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)),
background_color: if matches!(base_styles.background_color, StyleProp::Default) { border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)),
StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)) height: StyleProp::Value(Units::Pixels(45.0)),
} else { padding_left: StyleProp::Value(Units::Stretch(1.0)),
base_styles.background_color padding_right: StyleProp::Value(Units::Stretch(1.0)),
}, ..Default::default()
padding_left: StyleProp::Value(Units::Stretch(1.0)), })
padding_right: StyleProp::Value(Units::Stretch(1.0)), );
..base_styles
});
rsx! { rsx! {
<Fragment> <Fragment>
{children} {children}
......
...@@ -88,7 +88,7 @@ pub fn TextBox(props: TextBoxProps) { ...@@ -88,7 +88,7 @@ pub fn TextBox(props: TextBoxProps) {
..Default::default() ..Default::default()
}) })
// Apply any prop-given styles // Apply any prop-given styles
.with_style(props.styles) .with_style(&props.styles)
// If not set by props, apply these styles // If not set by props, apply these styles
.with_style(Style { .with_style(Style {
top: Units::Pixels(0.0).into(), top: Units::Pixels(0.0).into(),
......
...@@ -99,22 +99,25 @@ pub fn TooltipProvider(props: TooltipProviderProps) { ...@@ -99,22 +99,25 @@ pub fn TooltipProvider(props: TooltipProviderProps) {
} = tooltip.get(); } = tooltip.get();
let tooltip_size = tooltip_size.unwrap_or((WIDTH, HEIGHT)); let tooltip_size = tooltip_size.unwrap_or((WIDTH, HEIGHT));
props.styles = Some(Style { props.styles = Some(
left: StyleProp::Value(Units::Pixels(position.0)), Style::default()
top: StyleProp::Value(Units::Pixels(position.1)), .with_style(Style {
width: StyleProp::Value(Units::Pixels(size.0)), left: StyleProp::Value(Units::Pixels(position.0)),
height: StyleProp::Value(Units::Pixels(size.1)), top: StyleProp::Value(Units::Pixels(position.1)),
..props.styles.clone().unwrap_or_default() ..Default::default()
}); })
.with_style(&props.styles)
.with_style(Style {
width: StyleProp::Value(Units::Pixels(size.0)),
height: StyleProp::Value(Units::Pixels(size.1)),
..Default::default()
})
);
let base_styles = props.styles.clone().unwrap(); let base_styles = props.styles.clone().unwrap();
let mut tooltip_styles = Style { let mut tooltip_styles = Style {
position_type: StyleProp::Value(PositionType::SelfDirected), position_type: StyleProp::Value(PositionType::SelfDirected),
background_color: if matches!(base_styles.background_color, StyleProp::Default) { background_color: StyleProp::select(&[&base_styles.background_color, &Color::new(0.13, 0.15, 0.17, 0.85).into()]).clone(),
StyleProp::Value(Color::new(0.13, 0.15, 0.17, 0.85))
} else {
base_styles.background_color
},
width: StyleProp::Value(Units::Pixels(tooltip_size.0)), width: StyleProp::Value(Units::Pixels(tooltip_size.0)),
height: StyleProp::Value(Units::Pixels(tooltip_size.1)), height: StyleProp::Value(Units::Pixels(tooltip_size.1)),
..Style::default() ..Style::default()
...@@ -137,11 +140,7 @@ pub fn TooltipProvider(props: TooltipProviderProps) { ...@@ -137,11 +140,7 @@ pub fn TooltipProvider(props: TooltipProviderProps) {
let text_styles = Style { let text_styles = Style {
width: StyleProp::Value(Units::Pixels(tooltip_size.0)), width: StyleProp::Value(Units::Pixels(tooltip_size.0)),
height: StyleProp::Value(Units::Pixels(tooltip_size.1)), height: StyleProp::Value(Units::Pixels(tooltip_size.1)),
color: if matches!(base_styles.color, StyleProp::Default) { color: StyleProp::select(&[&base_styles.color, &Color::WHITE.into()]).clone(),
StyleProp::Value(Color::WHITE)
} else {
base_styles.color
},
..Style::default() ..Style::default()
}; };
...@@ -196,12 +195,19 @@ pub fn TooltipConsumer(props: TooltipConsumerProps) { ...@@ -196,12 +195,19 @@ pub fn TooltipConsumer(props: TooltipConsumerProps) {
let TooltipConsumerProps { let TooltipConsumerProps {
anchor, size, text, .. anchor, size, text, ..
} = props.clone(); } = props.clone();
props.styles = Some(Style { props.styles = Some(
render_command: StyleProp::Value(RenderCommand::Clip), Style::default()
width: StyleProp::Value(Units::Auto), .with_style(Style {
height: StyleProp::Value(Units::Auto), render_command: StyleProp::Value(RenderCommand::Clip),
..props.styles.clone().unwrap_or_default() ..Default::default()
}); })
.with_style(&props.styles)
.with_style(Style {
width: StyleProp::Value(Units::Auto),
height: StyleProp::Value(Units::Auto),
..Default::default()
})
);
let data = context let data = context
.create_consumer::<TooltipData>() .create_consumer::<TooltipData>()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment