Toggle & Switch (#21979)
 - Adds the Switch component - Updates `Selected`, `Selectable` -> `ToggleState`, `Toggleable` - Adds `checkbox` and `switch` functions to align better with other elements in our layout system. We decided not to merge Switch and Checkbox. However, in a followup I'll introduce a Toggle or AnyToggle enum so we can update `CheckboxWithLabel` -> `ToggleWithLabel` as this component will work exactly the same with either a Checkbox or a Switch. Release Notes: - N/A
This commit is contained in:
@@ -13,11 +13,11 @@ impl Render for ButtonStory {
|
||||
.child(Story::label("Default"))
|
||||
.child(Button::new("default_filled", "Click me"))
|
||||
.child(Story::label("Selected"))
|
||||
.child(Button::new("selected_filled", "Click me").selected(true))
|
||||
.child(Button::new("selected_filled", "Click me").toggle_state(true))
|
||||
.child(Story::label("Selected with `selected_label`"))
|
||||
.child(
|
||||
Button::new("selected_label_filled", "Click me")
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.selected_label("I have been selected"),
|
||||
)
|
||||
.child(Story::label("With `label_color`"))
|
||||
@@ -27,7 +27,7 @@ impl Render for ButtonStory {
|
||||
.child(Story::label("Selected with `icon`"))
|
||||
.child(
|
||||
Button::new("filled_and_selected_with_icon", "Click me")
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.icon(IconName::FileGit),
|
||||
)
|
||||
.child(Story::label("Default (Subtle)"))
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Render for IconButtonStory {
|
||||
|
||||
let selected_button = StoryItem::new(
|
||||
"Selected",
|
||||
IconButton::new("selected_icon_button", IconName::Hash).selected(true),
|
||||
IconButton::new("selected_icon_button", IconName::Hash).toggle_state(true),
|
||||
)
|
||||
.description("Displays an icon button that is selected.")
|
||||
.usage(
|
||||
@@ -33,7 +33,7 @@ impl Render for IconButtonStory {
|
||||
let selected_with_selected_icon = StoryItem::new(
|
||||
"Selected with `selected_icon`",
|
||||
IconButton::new("selected_with_selected_icon_button", IconName::AudioOn)
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.selected_icon(IconName::AudioOff),
|
||||
)
|
||||
.description(
|
||||
@@ -89,7 +89,7 @@ impl Render for IconButtonStory {
|
||||
let selected_with_tooltip_button = StoryItem::new(
|
||||
"Selected with `tooltip`",
|
||||
IconButton::new("selected_with_tooltip_button", IconName::InlayHint)
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.tooltip(|cx| Tooltip::text("Toggle inlay hints", cx)),
|
||||
)
|
||||
.description("Displays a selected icon button with tooltip.")
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Render for TabStory {
|
||||
h_flex()
|
||||
.child(
|
||||
Tab::new("tab_1")
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.position(TabPosition::First)
|
||||
.child("Tab 1"),
|
||||
)
|
||||
@@ -85,7 +85,7 @@ impl Render for TabStory {
|
||||
.child(
|
||||
Tab::new("tab_4")
|
||||
.position(TabPosition::Last)
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.child("Tab 4"),
|
||||
),
|
||||
)
|
||||
@@ -100,7 +100,7 @@ impl Render for TabStory {
|
||||
.child(
|
||||
Tab::new("tab_2")
|
||||
.position(TabPosition::Middle(Ordering::Equal))
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.child("Tab 2"),
|
||||
)
|
||||
.child(
|
||||
|
||||
@@ -13,7 +13,7 @@ impl Render for TabBarStory {
|
||||
let tabs = (0..tab_count)
|
||||
.map(|index| {
|
||||
Tab::new(index)
|
||||
.selected(index == selected_tab_index)
|
||||
.toggle_state(index == selected_tab_index)
|
||||
.position(if index == 0 {
|
||||
TabPosition::First
|
||||
} else if index == tab_count - 1 {
|
||||
|
||||
@@ -68,7 +68,7 @@ impl Render for ToggleButtonStory {
|
||||
ToggleButton::new(2, "Banana")
|
||||
.style(ButtonStyle::Filled)
|
||||
.size(ButtonSize::Large)
|
||||
.selected(true)
|
||||
.toggle_state(true)
|
||||
.middle(),
|
||||
)
|
||||
.child(
|
||||
|
||||
Reference in New Issue
Block a user