Skip to content

Commit

Permalink
test: update workshop stories
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Nov 28, 2024
1 parent a98a7b9 commit 92a4fdb
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/core/__workshop__/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ export const WORKSHOP_TEXT_INPUT_TYPE_OPTIONS: {[key: string]: TextInputType} =
'color': 'color',
}

export const WORKSHOP_TEXT_OVERFLOW_OPTIONS: {[key: string]: 'ellipsis' | ''} = {
None: '',
export const WORKSHOP_TEXT_OVERFLOW_OPTIONS: {[key: string]: 'ellipsis' | 'none'} = {
None: 'none',
Ellipsis: 'ellipsis',
}

Expand Down
58 changes: 58 additions & 0 deletions src/core/components/breadcrumbs/__workshop__/buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {ChevronRightIcon} from '@sanity/icons'
import {Box, Breadcrumbs, Button, Card, Flex, Text} from '@sanity/ui'
import {useSelect} from '@sanity/ui-workshop'

const BREADCRUMBS_MAX_LENGTH_OPTIONS = {
'(none)': 0,
'1': 1,
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
}

export default function Example() {
const maxLength =
useSelect('Max. length', BREADCRUMBS_MAX_LENGTH_OPTIONS, 0, 'Props') || undefined

return (
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
<Card padding={1} radius={3} shadow={1}>
<Breadcrumbs
gapX={0}
expandButton={{padding: 2}}
maxLength={maxLength}
separator={
<Box paddingY={2} style={{opacity: 0.5}}>
<Text muted size={1}>
<ChevronRightIcon />
</Text>
</Box>
}
// space={0}
>
<Button href="#" mode="bleed" padding={2} text="Root" />
<Button href="#" mode="bleed" padding={2} text="Category A of some length" />
<Button href="#" mode="bleed" padding={2} text="Category B" />
<Button href="#" mode="bleed" padding={2} text="Category C" />
<Button
href="#"
mode="bleed"
padding={2}
text="Category D of an every larger and more extended length"
textOverflow="none"
/>
<Button href="#" mode="bleed" padding={2} text="Category E" />
<Button href="#" mode="bleed" padding={2} text="Category F" />
<Box padding={2}>
<Text size={1} weight="semibold">
Item
</Text>
</Box>
</Breadcrumbs>
</Card>
</Flex>
)
}
6 changes: 4 additions & 2 deletions src/core/components/breadcrumbs/__workshop__/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ export default function Example() {
useSelect('Max. length', BREADCRUMBS_MAX_LENGTH_OPTIONS, 0, 'Props') || undefined

return (
<Flex align="center" height="fill" justify="center">
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
<Breadcrumbs
gapX={1}
gapY={3}
maxLength={maxLength}
separator={
<Text muted size={1}>
/
</Text>
}
space={2}
// space={2}
>
<Text size={1}>
<a href="#">Root</a>
Expand Down
5 changes: 5 additions & 0 deletions src/core/components/breadcrumbs/__workshop__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ export default defineScope({
title: 'Example',
component: lazy(() => import('./example')),
},
{
name: 'buttons',
title: 'Buttons',
component: lazy(() => import('./buttons')),
},
],
})
7 changes: 4 additions & 3 deletions src/core/primitives/button/__workshop__/custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import {WORKSHOP_BUTTON_TONE_OPTIONS} from '../../../__workshop__/constants'

export default function CustomStory() {
const tones = Object.entries(WORKSHOP_BUTTON_TONE_OPTIONS)
const len = tones.length

return (
<Flex align="center" height="fill" justify="center">
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
<Stack space={2}>
<Grid columns={5} gap={1}>
<Grid columns={len} gap={1}>
{tones.map(([title, tone]) => (
<Button key={tone} mode="ghost" padding={3} tone={tone}>
<Stack space={2}>
Expand All @@ -24,7 +25,7 @@ export default function CustomStory() {
</Button>
))}
</Grid>
<Grid columns={5} gap={1}>
<Grid columns={len} gap={1}>
{tones.map(([title, tone]) => (
<Button key={tone} mode="default" padding={3} tone={tone}>
<Stack space={2}>
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/button/__workshop__/mixedChildren.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function MixedChildrenStory() {
return (
<Flex align="center" height="fill" justify="center">
<Button fontSize={[2, 2, 3]} icon={AddIcon} mode="ghost" padding={[3, 3, 4]} text="Create">
<span style={{display: 'none'}}>test</span>
<span style={{opacity: 0.5}}>raw span</span>
</Button>
</Flex>
)
Expand Down
12 changes: 10 additions & 2 deletions src/core/primitives/button/__workshop__/props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import {
WORKSHOP_ICON_SYMBOL_OPTIONS,
WORKSHOP_TEXT_SIZE_OPTIONS,
WORKSHOP_SPACE_OPTIONS,
WORKSHOP_TEXT_OVERFLOW_OPTIONS,
} from '../../../__workshop__/constants'

export default function ButtonStory() {
const disabled = useBoolean('Disabled', false, 'Props')
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props')
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 1, 'Props')
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
Expand All @@ -26,9 +27,15 @@ export default function ButtonStory() {
const textAlign =
useSelect('Text align', WORKSHOP_BUTTON_TEXT_ALIGN_OPTIONS, undefined, 'Props') || undefined
const textProp = useText('Text', 'Label', 'Props')
const textOverflow = useSelect(
'Text overflow',
WORKSHOP_TEXT_OVERFLOW_OPTIONS,
'ellipsis',
'Props',
)

return (
<Flex align="center" height="fill" justify="center">
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
<Button
disabled={disabled}
fontSize={fontSize}
Expand All @@ -42,6 +49,7 @@ export default function ButtonStory() {
selected={selected}
space={space}
textAlign={textAlign}
textOverflow={textOverflow}
text={textProp}
tone={tone}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SanityUploadButton = styled(Button).attrs({forwardedAs: 'label'})`
width: stretch;
}
& span:nth-child(2) {
& > span:nth-child(2) {
width: 0;
flex: none;
padding: 0;
Expand Down
6 changes: 3 additions & 3 deletions src/core/primitives/button/__workshop__/stacked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
export default function StackedStory() {
const tones = Object.entries(WORKSHOP_BUTTON_TONE_OPTIONS)
const disabled = useBoolean('Disabled', false, 'Props')
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props')
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 1, 'Props')
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
const mode = useSelect('Mode', WORKSHOP_BUTTON_MODE_OPTIONS, 'default', 'Props')
const onClick = useAction('onClick')
const paddingX = useSelect('Padding X', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
const paddingY = useSelect('Padding Y', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
const paddingX = useSelect('Padding X', WORKSHOP_SPACE_OPTIONS, 2, 'Props')
const paddingY = useSelect('Padding Y', WORKSHOP_SPACE_OPTIONS, 2, 'Props')
const selected = useBoolean('Selected', false, 'Props')
const space = useSelect('Space', WORKSHOP_SPACE_OPTIONS, 3, 'Props')

Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/label/__workshop__/plain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function PlainStory() {
const size = useSelect('Size', WORKSHOP_LABEL_FONT_SIZE_OPTIONS, undefined, 'Props')
const textChild = useText('Text', 'Label text', 'Props')
const textOverflow =
useSelect('Text overflow', WORKSHOP_TEXT_OVERFLOW_OPTIONS, '', 'Props') || undefined
useSelect('Text overflow', WORKSHOP_TEXT_OVERFLOW_OPTIONS, 'none', 'Props') || undefined
const weight = useSelect('Weight', WORKSHOP_FONT_WEIGHT_OPTIONS, undefined, 'Props')

return (
Expand Down

0 comments on commit 92a4fdb

Please sign in to comment.