-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(pills): add form and display pill docs
- Loading branch information
Showing
6 changed files
with
947 additions
and
1 deletion.
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
94 changes: 94 additions & 0 deletions
94
packages/paste-website/src/component-examples/FormPillGroup.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,94 @@ | ||
export const defaultExample = ` | ||
const BasicFormPillGroup = () => { | ||
const pillState = useFormPillState(); | ||
return ( | ||
<form> | ||
<FormPillGroup {...pillState} aria-label="Your favorite sports:"> | ||
<FormPill {...pillState}> | ||
<CalendarIcon decorative size="sizeIcon10" /> | ||
Tennis | ||
</FormPill> | ||
<FormPill {...pillState}> | ||
Baseball | ||
</FormPill> | ||
<FormPill {...pillState}>Football</FormPill> | ||
<FormPill {...pillState}> | ||
Soccer | ||
</FormPill> | ||
</FormPillGroup> | ||
</form> | ||
); | ||
}; | ||
render( | ||
<BasicFormPillGroup /> | ||
) | ||
`.trim(); | ||
|
||
export const selectableExample = ` | ||
const SelectableFormPillGroup = () => { | ||
const [pills] = React.useState(['Tennis', 'Baseball', 'Football', 'Soccer']); | ||
const [selectedSet, updateSelectedSet] = React.useState(new Set(['Football'])); | ||
const pillState = useFormPillState(); | ||
return ( | ||
<form> | ||
<FormPillGroup {...pillState} aria-label="Your favorite sports:"> | ||
{pills.map((pill) => ( | ||
<FormPill | ||
key={pill} | ||
{...pillState} | ||
selected={selectedSet.has(pill)} | ||
onSelect={() => { | ||
const newSelectedSet = new Set(selectedSet); | ||
if (newSelectedSet.has(pill)) { | ||
newSelectedSet.delete(pill); | ||
} else { | ||
newSelectedSet.add(pill); | ||
} | ||
updateSelectedSet(newSelectedSet); | ||
}} | ||
> | ||
{pill} | ||
</FormPill> | ||
))} | ||
</FormPillGroup> | ||
</form> | ||
); | ||
}; | ||
render( | ||
<SelectableFormPillGroup /> | ||
) | ||
`.trim(); | ||
|
||
export const removableExample = ` | ||
const RemovableFormPillGroup = () => { | ||
const [pills, setPills] = React.useState(['Tennis', 'Baseball', 'Football', 'Soccer']); | ||
const pillState = useFormPillState(); | ||
return ( | ||
<form> | ||
<FormPillGroup {...pillState} aria-label="Your favorite sports:"> | ||
{pills.map((pill, index) => ( | ||
<FormPill | ||
key={pill} | ||
{...pillState} | ||
onDismiss={() => { | ||
setPills(pills.filter((_, i) => i !== index)); | ||
}} | ||
> | ||
{pill} | ||
</FormPill> | ||
))} | ||
{pills.length === 0 ? <Text as="p">No sports remaining</Text> : null} | ||
</FormPillGroup> | ||
</form> | ||
); | ||
}; | ||
render( | ||
<RemovableFormPillGroup /> | ||
) | ||
`.trim(); |
109 changes: 109 additions & 0 deletions
109
packages/paste-website/src/components/FormPillVsDisplayPillTable.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,109 @@ | ||
import * as React from 'react'; | ||
import {Box} from '@twilio-paste/box'; | ||
import {Table, Tr, THead, Th, TBody, Td} from '@twilio-paste/table'; | ||
import {SuccessIcon} from '@twilio-paste/icons/esm/SuccessIcon'; | ||
|
||
export interface FormPillVsDisplayPillTableProps { | ||
children: NonNullable<React.ReactNode>; | ||
} | ||
|
||
const FormPillVsDisplayPillTable: React.FC<FormPillVsDisplayPillTableProps> = () => { | ||
return ( | ||
<Box marginBottom="space70"> | ||
<Table> | ||
<THead> | ||
<Tr> | ||
<Th> </Th> | ||
<Th textAlign="center">Display Pill</Th> | ||
<Th textAlign="center">Form Pill</Th> | ||
</Tr> | ||
</THead> | ||
<TBody> | ||
<Tr> | ||
<Td>Used to view data</Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
<Td> </Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Uses List, List Item semantic</Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
<Td> </Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Pills can link to a page</Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
<Td> </Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Used to edit data in a form</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Uses Listbox, Option semantic</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Provides keyboard navigation</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Pills are selectable</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Pills can perform an action</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
<Tr> | ||
<Td>Pills can be removed</Td> | ||
<Td> </Td> | ||
<Td> | ||
<Box display="flex" justifyContent="center"> | ||
<SuccessIcon color="colorTextIconSuccess" decorative={false} title="Supported feature" /> | ||
</Box> | ||
</Td> | ||
</Tr> | ||
</TBody> | ||
</Table> | ||
</Box> | ||
); | ||
}; | ||
|
||
export {FormPillVsDisplayPillTable}; |
Oops, something went wrong.