Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add size variants to Step #552

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-gorillas-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@status-im/components": patch
---

add size variants to Step
45 changes: 32 additions & 13 deletions packages/components/src/step/step.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,39 @@ export const AllVariants: Story = {
args: {},
render: () => (
<Stack space flexDirection="row">
<Stack space alignItems="center">
<Step type="neutral" value={1} />
<Step type="neutral" value={10} />
<Step type="neutral" value={999} />
<Stack space flexDirection="column">
<Stack space alignItems="center">
<Step size={18} type="neutral" value={1} />
<Step size={18} type="neutral" value={10} />
<Step size={18} type="neutral" value={999} />
</Stack>
<Stack space alignItems="center">
<Step size={18} type="complete" value={1} />
<Step size={18} type="complete" value={10} />
<Step size={18} type="complete" value={999} />
</Stack>
<Stack space alignItems="center">
<Step size={18} type="active" value={1} />
<Step size={18} type="active" value={10} />
<Step size={18} type="active" value={999} />
</Stack>
</Stack>
<Stack space alignItems="center">
<Step type="complete" value={1} />
<Step type="complete" value={10} />
<Step type="complete" value={999} />
</Stack>
<Stack space alignItems="center">
<Step type="active" value={1} />
<Step type="active" value={10} />
<Step type="active" value={999} />
<Stack space flexDirection="column">
<Stack space alignItems="center">
<Step size={22} type="neutral" value={1} />
<Step size={22} type="neutral" value={10} />
<Step size={22} type="neutral" value={999} />
</Stack>
<Stack space alignItems="center">
<Step size={22} type="complete" value={1} />
<Step size={22} type="complete" value={10} />
<Step size={22} type="complete" value={999} />
</Stack>
<Stack space alignItems="center">
<Step size={22} type="active" value={1} />
<Step size={22} type="active" value={10} />
<Step size={22} type="active" value={999} />
</Stack>
</Stack>
</Stack>
),
Expand Down
37 changes: 30 additions & 7 deletions packages/components/src/step/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import type { ColorTokens } from '@tamagui/core'
export type StepVariants = 'neutral' | 'complete' | 'active'

type Props = {
size: 18 | 22
value: number
type?: StepVariants
}

const Step = (props: Props) => {
const { value, type = 'neutral' } = props
const { size = 18, value, type = 'neutral' } = props

return (
<Base>
<Content type={type}>
<Base size={size}>
<Content size={size} type={type}>
<Text size={11} weight="medium" color={textColors[type]}>
{value}
</Text>
Expand All @@ -30,24 +31,34 @@ export { Step }
export type { Props as StepProps }

const Base = styled(Stack, {
paddingVertical: 1,
minWidth: 20,
maxWidth: 28,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
flexBasis: 'fit-content',
width: 'fit-content',

variants: {
size: {
18: {
paddingVertical: 1,
minWidth: 20,
maxWidth: 28,
},
22: {
minWidth: 24,
maxWidth: 32,
},
},
},
})

const Content = styled(Stack, {
backgroundColor: '$white-100',
paddingHorizontal: 3,
paddingVertical: 0,
borderRadius: '$6',
height: 18,
minWidth: 18,
maxWidth: 28,
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
Expand All @@ -66,6 +77,18 @@ const Content = styled(Stack, {
backgroundColor: '$blue/10',
},
},
size: {
18: {
height: 18,
minWidth: 18,
maxWidth: 28,
},
22: {
height: 22,
minWidth: 22,
maxWidth: 32,
},
},
},
})

Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ const TabsTrigger = (props: TriggerProps, ref: Ref<View>) => {
color,
})}

{props.type === 'step' && <Step type="complete" value={props.step} />}
{props.type === 'step' && (
<Step size={18} type="complete" value={props.step} />
)}

<Text size={textSize} weight="medium" color={color}>
{children}
Expand Down
Loading