-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs[DST-511]: revise switch component (#4110)
* DST-511: typo button page * DST-511: revise switch component page * Create seven-ads-kiss.md * DST-511: revise switch component page * DST-511: edit comments
- Loading branch information
Showing
12 changed files
with
92 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@marigold/docs": patch | ||
"@marigold/components": patch | ||
--- | ||
|
||
docs[DST-511]: Revise switch component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
docs/content/components/form/switch/switch-active-disabled.demo.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
docs/content/components/form/switch/switch-appearance.demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Container, Switch, SwitchProps } from '@marigold/components'; | ||
|
||
export default (props: SwitchProps) => ( | ||
<Container size={'small'}> | ||
<Switch {...props}>Default Switch</Switch> | ||
</Container> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,99 @@ | ||
--- | ||
title: Switch | ||
caption: Component that switches between two states. | ||
badge: updated | ||
--- | ||
|
||
The `<Switch>` component allows the users to select between two states, e.g. on and off. | ||
It consists of a visual selection indicator and a label. | ||
|
||
Users may click or touch a Switch to toggle the state, or use the tab key to navigate to it and the space key to toggle it. | ||
|
||
The styles are separated into some parts (container, label, thumb, track) that you can style in a custom variant. | ||
## Anatomy | ||
|
||
## Import | ||
<Image | ||
src="/switch/switch-anatomy.jpg" | ||
alt="Anatomy of table" | ||
width={800} | ||
height={550} | ||
className="mx-auto block" | ||
/> | ||
|
||
```tsx | ||
import { Switch } from '@marigold/components'; | ||
``` | ||
The styles are separated into some parts (container, label, thumb, track) that you can style in a custom variant. | ||
|
||
## Appearance | ||
|
||
<AppearanceTable component={title} /> | ||
|
||
## Props | ||
|
||
<PropsTable component={title} /> | ||
|
||
## Examples | ||
<AppearanceDemo component={title} /> | ||
|
||
### Default | ||
|
||
In this example you can see a simple `<Switch>` component with no properties. | ||
|
||
<ComponentDemo file="./switch-basic.demo.tsx" /> | ||
|
||
### Active | ||
|
||
Here you can see an already active `<Switch>`. It can be used when e.g. settings options are per default set to true. | ||
<AppearanceTable component={title} /> | ||
|
||
<ComponentDemo file="./switch-active.demo.tsx" /> | ||
## Usage | ||
|
||
Switches are best used to adjust settings and other standalone options. They make a binary selection, like on and off or true and false. | ||
|
||
The effects of a switch should start immediately, without needing to save. | ||
|
||
<GuidelineTiles> | ||
<Do> | ||
<Do.Figure> | ||
<Image | ||
width={700} | ||
height={700} | ||
unoptimized | ||
src="/switch/switch-do-settings.jpg" | ||
alt="Immediately activate or deactivate something" | ||
/> | ||
</Do.Figure> | ||
<Do.Description> | ||
<strong>Immediately</strong> activate or deactivate something. | ||
</Do.Description> | ||
</Do> | ||
<Dont> | ||
<Dont.Figure> | ||
<Image | ||
width={700} | ||
height={700} | ||
unoptimized | ||
src="/switch/switch-dont-settings.jpg" | ||
alt="Don't use save actions with switches." | ||
/> | ||
</Dont.Figure> | ||
<Dont.Description> | ||
Avoid using a switch to select multiple options that require people to | ||
save. Switches should be immediate. | ||
</Dont.Description> | ||
</Dont> | ||
</GuidelineTiles> | ||
|
||
<Dont> | ||
<Dont.Figure> | ||
<Image | ||
width={700} | ||
height={700} | ||
unoptimized | ||
src="/switch/switch-dont-opposing-options.jpg" | ||
alt="Avoid using switches to toggle between opposing options." | ||
/> | ||
</Dont.Figure> | ||
<Dont.Description> | ||
Avoid using switches to toggle between opposing options. | ||
</Dont.Description> | ||
</Dont> | ||
|
||
### Disabled | ||
## Props | ||
|
||
In this mode the user can not change the status of the `<Switch>`. It can be used e.g. if you want to disable a certain setting for some users. | ||
<StorybookHintMessage component={title} /> | ||
|
||
<ComponentDemo file="./switch-disabled.demo.tsx" /> | ||
<PropsTable component={title} /> | ||
|
||
### Disabled (active) | ||
## Alternative components | ||
|
||
This mode can be used when an option is or was already active and there is a variable that does not allow the user switch to be moved from its "on" mode. | ||
Alternative selection controls can be used to enter decisions or declare preferences such as settings or dialogs. | ||
|
||
<ComponentDemo file="./switch-active-disabled.demo.tsx" /> | ||
<ul> | ||
<li> | ||
[Checkbox](/components/form/checkbox): Select multiple related options in a | ||
list. | ||
</li> | ||
<li>[Radio](/components/form/radio): Select a single option in a list.</li> | ||
</ul> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters