Skip to content

Commit

Permalink
Add params to TextField
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Oct 22, 2023
1 parent cc11096 commit d8a92c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn Button<'a>(
/// Background color of the container (optional).
background_color: Option<&'a str>,

/// Border radiusof the container (optional).
/// Border radius of the container (optional).
border_radius: Option<&'a str>,

/// Height of the container (optional).
Expand Down
8 changes: 5 additions & 3 deletions src/text_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ pub fn TextField<'a>(
onchange: EventHandler<'a, FormEvent>,
background: Option<&'a str>,
font_size: Option<f32>,
width: Option<&'a str>
) -> Element<'a> {
let is_populated = use_state(cx, || !value.is_empty());
let theme = use_theme(cx);

let font_size = font_size.unwrap_or(theme.label_medium);
let spring = use_spring(
cx,
if **is_populated {
[10f32, 12f32, 16f32]
} else {
[20., 16., 24.]
[20., font_size, 24.]
},
Duration::from_millis(50),
);
Expand All @@ -40,12 +42,12 @@ pub fn TextField<'a>(
});

let background = background.unwrap_or(&theme.background_color);
let font_size = font_size.unwrap_or(theme.label_medium);
let width = width.unwrap_or("200px");

render!(
div {
position: "relative",
width: "200px",
width: width,
background: "{background}",
font_family: "sans-serif",
border_bottom: "2px solid #999",
Expand Down

0 comments on commit d8a92c0

Please sign in to comment.