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 {
#[widget]
pub fn Button(props: ButtonProps) {
let base_styles = props.styles.clone().unwrap_or_default();
props.styles = Some(Style {
render_command: StyleProp::Value(RenderCommand::Quad),
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)),
height: if base_styles.height == StyleProp::Default {
StyleProp::Value(Units::Pixels(45.0))
} else {
base_styles.height
},
background_color: if matches!(base_styles.background_color, StyleProp::Default) {
StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0))
} else {
base_styles.background_color
},
padding_left: StyleProp::Value(Units::Stretch(1.0)),
padding_right: StyleProp::Value(Units::Stretch(1.0)),
..base_styles
});
props.styles = Some(
Style::default()
.with_style(Style {
render_command: StyleProp::Value(RenderCommand::Quad),
..Default::default()
})
.with_style(&props.styles)
.with_style(Style {
background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)),
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)),
height: StyleProp::Value(Units::Pixels(45.0)),
padding_left: StyleProp::Value(Units::Stretch(1.0)),
padding_right: StyleProp::Value(Units::Stretch(1.0)),
..Default::default()
})
);
rsx! {
<Fragment>
{children}
......
......@@ -88,7 +88,7 @@ pub fn TextBox(props: TextBoxProps) {
..Default::default()
})
// Apply any prop-given styles
.with_style(props.styles)
.with_style(&props.styles)
// If not set by props, apply these styles
.with_style(Style {
top: Units::Pixels(0.0).into(),
......
......@@ -99,22 +99,25 @@ pub fn TooltipProvider(props: TooltipProviderProps) {
} = tooltip.get();
let tooltip_size = tooltip_size.unwrap_or((WIDTH, HEIGHT));
props.styles = Some(Style {
left: StyleProp::Value(Units::Pixels(position.0)),
top: StyleProp::Value(Units::Pixels(position.1)),
width: StyleProp::Value(Units::Pixels(size.0)),
height: StyleProp::Value(Units::Pixels(size.1)),
..props.styles.clone().unwrap_or_default()
});
props.styles = Some(
Style::default()
.with_style(Style {
left: StyleProp::Value(Units::Pixels(position.0)),
top: StyleProp::Value(Units::Pixels(position.1)),
..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 mut tooltip_styles = Style {
position_type: StyleProp::Value(PositionType::SelfDirected),
background_color: if matches!(base_styles.background_color, StyleProp::Default) {
StyleProp::Value(Color::new(0.13, 0.15, 0.17, 0.85))
} else {
base_styles.background_color
},
background_color: StyleProp::select(&[&base_styles.background_color, &Color::new(0.13, 0.15, 0.17, 0.85).into()]).clone(),
width: StyleProp::Value(Units::Pixels(tooltip_size.0)),
height: StyleProp::Value(Units::Pixels(tooltip_size.1)),
..Style::default()
......@@ -137,11 +140,7 @@ pub fn TooltipProvider(props: TooltipProviderProps) {
let text_styles = Style {
width: StyleProp::Value(Units::Pixels(tooltip_size.0)),
height: StyleProp::Value(Units::Pixels(tooltip_size.1)),
color: if matches!(base_styles.color, StyleProp::Default) {
StyleProp::Value(Color::WHITE)
} else {
base_styles.color
},
color: StyleProp::select(&[&base_styles.color, &Color::WHITE.into()]).clone(),
..Style::default()
};
......@@ -196,12 +195,19 @@ pub fn TooltipConsumer(props: TooltipConsumerProps) {
let TooltipConsumerProps {
anchor, size, text, ..
} = props.clone();
props.styles = Some(Style {
render_command: StyleProp::Value(RenderCommand::Clip),
width: StyleProp::Value(Units::Auto),
height: StyleProp::Value(Units::Auto),
..props.styles.clone().unwrap_or_default()
});
props.styles = Some(
Style::default()
.with_style(Style {
render_command: StyleProp::Value(RenderCommand::Clip),
..Default::default()
})
.with_style(&props.styles)
.with_style(Style {
width: StyleProp::Value(Units::Auto),
height: StyleProp::Value(Units::Auto),
..Default::default()
})
);
let data = context
.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