11/* eslint-disable react/no-unescaped-entities */
2- import { ArgsTable , PRIMARY_STORY , Primary } from '@storybook/addon-docs'
2+ import { ArgsTable , PRIMARY_STORY , Primary , Story } from '@storybook/addon-docs'
33import { Meta , StoryObj } from '@storybook/react'
4- import {
5- DoDont ,
6- Hero ,
7- LiveDemo ,
8- RelatedComponent ,
9- RelatedComponentContainer ,
10- Section ,
11- StoryHeading ,
12- StoryStage ,
13- TableOfContents ,
14- } from 'pcln-docs-utils'
154import { Check as CheckIcon , Close as CloseIcon } from 'pcln-icons'
165import React , { useState } from 'react'
6+ import type { IToggleProps } from '..'
177import {
188 Box ,
199 Button ,
2010 Checkbox ,
2111 ChoiceChip ,
12+ DoDont ,
2213 Flex ,
23- IToggleProps ,
14+ Hero ,
2415 Image ,
2516 Label ,
2617 Radio ,
18+ RelatedComponent ,
19+ RelatedComponentContainer ,
20+ Section ,
21+ StoryHeading ,
22+ StoryStage ,
23+ TableOfContents ,
2724 Text ,
2825 ThemeProvider ,
2926 Toggle ,
3027} from '..'
3128
29+ import { toggleArgTypes } from './Toggle.stories.args'
30+
31+ import { linkTo } from '@storybook/addon-links'
3232import alignmentImage from './Toggle.Image.Alignment.png'
3333import heroImage from './Toggle.Image.Hero.png'
3434import statesImage from './Toggle.Image.States.png'
@@ -43,15 +43,7 @@ export const Playground: ToggleStory = {
4343
4444 return < Toggle isOn = { isOn } onToggle = { onToggle } { ...args } />
4545 } ,
46- argTypes : {
47- isOn : {
48- type : 'boolean' ,
49- } ,
50- disabled : {
51- type : 'boolean' ,
52- defaultValue : false ,
53- } ,
54- } ,
46+ argTypes : toggleArgTypes ,
5547}
5648
5749export const Sizes : ToggleStory = {
@@ -104,9 +96,9 @@ const meta: Meta<typeof Toggle> = {
10496 page : ( ) => (
10597 < ThemeProvider >
10698 < Hero name = 'Toggle' img = { heroImage } >
107- Buttons allow users to trigger an action or event with a single click. For example, you can use a
108- button for allowing the functionality of submitting a form, opening a dialog, canceling an action,
109- or performing a delete operation .
99+ A toggle allows users to independently control binary options ( a single state that is either on or
100+ off), such as a setting. When a toggle is interacted with, it should take immediate effect and its
101+ appearance should clearly indicate when it's in the activated or deactivated state .
110102 </ Hero >
111103
112104 < TableOfContents
@@ -116,8 +108,8 @@ const meta: Meta<typeof Toggle> = {
116108 < Section heading = 'Overview' >
117109 < Text textStyle = 'paragraph' >
118110 A toggle allows users to independently control binary options (a single state that is either on
119- or off), such as a setting. When a toggle is interacted with, it should take immediately effect
120- and it's appearance should clearly indicate when it's activated or deactivated state .
111+ or off), such as a setting. When a toggle is interacted with, it should take immediate effect
112+ and and its appearance should indicate whether it's activated or deactivated.
121113 </ Text >
122114 </ Section >
123115
@@ -135,23 +127,24 @@ const meta: Meta<typeof Toggle> = {
135127 < Section heading = 'Examples' >
136128 < StoryHeading storyName = 'Sizes' storyTitle = { meta . title } />
137129 < Text textStyle = 'paragraph' >
138- Toggles support two toggle sizes that consists of a base size, and a small size . These sizes
139- allow for hierarchy, emphasis, larger/smaller touch targets, and flexibility.
130+ Toggles support two sizes, < code > base</ code > and < code > small</ code > . These sizes allow for
131+ hierarchy, emphasis, larger/smaller touch targets, and flexibility.
140132 </ Text >
141- < LiveDemo code = { Sizes } />
133+ < Story name = ' Sizes' />
142134
143- < StoryHeading storyName = 'With Icon ' storyTitle = { meta . title } />
135+ < StoryHeading storyName = 'WithIcon ' storyTitle = { meta . title } />
144136 < Text textStyle = 'paragraph' >
145- Toggles support two toggle sizes that consists of a base size, and a small size . These sizes
146- allow for hierarchy, emphasis, larger/smaller touch targets, and flexibility.
137+ Toggles support two sizes, < code > base</ code > and < code > small</ code > . These sizes allow for
138+ hierarchy, emphasis, larger/smaller touch targets, and flexibility.
147139 </ Text >
148- < LiveDemo code = { WithIcon } />
140+ < Story name = 'With Icon' />
149141 </ Section >
150142
151143 < Section heading = 'Usage' >
152144 < Text . p textStyle = 'paragraph' >
153- Toggles should be used to adjust a setting, or if each item in a set can be independently
154- controlled. They’re used to control binary options, such as on/off or true/false.
145+ Toggles can contain an optional icon that can be used to visually emphasize the selected state.
146+ The icon's meaning should clearly indicate to help the user understand whether the toggle is
147+ switched on or off.
155148 </ Text . p >
156149 < Box p = { 3 } my = { 3 } borderRadius = 'xl' bg = 'primary.light' >
157150 < Image src = { usageImage } />
@@ -179,7 +172,7 @@ const meta: Meta<typeof Toggle> = {
179172 }
180173 doText = 'have a toggle with context or an inline label (short and direct) to describe the option that the toggle controls'
181174 dontExample = { < Toggle /> }
182- dontText = " have a toggle on it's own without any context or an inline label that leaves the user wondering that it controls"
175+ dontText = ' have a toggle on its own without any context or an inline label that leaves the user wondering what it controls'
183176 />
184177 < DoDont
185178 doExample = {
@@ -204,7 +197,7 @@ const meta: Meta<typeof Toggle> = {
204197 </ Label >
205198 </ Flex >
206199 }
207- dontText = 'use toggle if an item is opposing options, especially those that can be independently controlled'
200+ dontText = 'use toggle if an item has opposing options, especially those that can be independently controlled'
208201 />
209202 < DoDont
210203 doExample = {
@@ -213,7 +206,7 @@ const meta: Meta<typeof Toggle> = {
213206 < Toggle isOn />
214207 </ Flex >
215208 }
216- doText = 'use toggle to a setting that would take immediate and noticeable effect'
209+ doText = 'use toggle to change a setting that would take immediate and noticeable effect'
217210 dontExample = {
218211 < Flex alignItems = 'center' style = { { gap : 8 } } >
219212 < Label > Show Savings</ Label >
@@ -247,18 +240,18 @@ const meta: Meta<typeof Toggle> = {
247240
248241 < Section heading = 'Related Components' >
249242 < RelatedComponentContainer >
250- < RelatedComponent name = 'Radio' >
243+ < RelatedComponent name = 'Radio' onClick = { linkTo ( 'Radio' ) } >
251244 < Box >
252245 < Label nowrap >
253246 < Radio />
254247 Radio
255248 </ Label >
256249 </ Box >
257250 </ RelatedComponent >
258- < RelatedComponent name = 'ChoiceChip' linkTo = 'core-chip-ChoiceChip' >
251+ < RelatedComponent name = 'ChoiceChip' onClick = { linkTo ( 'core-chip-ChoiceChip' ) } >
259252 < ChoiceChip > Choice Chip</ ChoiceChip >
260253 </ RelatedComponent >
261- < RelatedComponent name = 'CheckBox' >
254+ < RelatedComponent name = 'CheckBox' onClick = { linkTo ( 'Checkbox' ) } >
262255 < Box >
263256 < Label nowrap >
264257 < Checkbox />
0 commit comments