Skip to content

Commit

Permalink
feat: add steps component and its docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccox committed Feb 8, 2023
1 parent c8353c7 commit cf53d9f
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 0 deletions.
66 changes: 66 additions & 0 deletions apps/experiments/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2040,5 +2040,71 @@ <h2 class="text-xl">Ghost</h2>
</div>
</div>
</div>
<div class="grid grid-cols-2 gap-4 p-4 has-border rounded-xl">
<h1 class="text-3xl col-span-full">Steps</h1>
<div class="">
<h2 class="text-xl">horizontal</h2>
<div class="grid gap-4">
<div class="steps success top">
<div class="step">Register</div>
<div class="step">Choose plan</div>
<div class="step">Purchase</div>
<div class="step">Receive Product</div>
</div>
<div class="steps danger bottom">
<div class="step">Register</div>
<div class="step active-point">Choose plan</div>
<div class="step active">Purchase</div>
<div class="step">Receive Product</div>
</div>
</div>
</div>
<div class="">
<h2 class="text-xl">vertical</h2>
<div class="flex gap-4">
<div class="steps success left">
<div class="step active">Register</div>
<div class="step active">Choose plan</div>
<div class="step active">Purchase</div>
<div class="step">Receive Product</div>
</div>
<div class="steps danger right">
<div class="step">Register</div>
<div class="step">Choose plan</div>
<div class="step">Purchase</div>
<div class="step">Receive Product</div>
</div>
</div>
</div>
<div class="">
<h2 class="text-xl">shape</h2>
<div class="flex gap-4">
<div class="steps success left">
<div class="step square active">Register</div>
<div class="step square active">Choose plan</div>
<div class="step square">Purchase</div>
<div class="step square">Receive Product</div>
</div>
<div class="steps danger right">
<div class="step cornered active">Register</div>
<div class="step cornered active">Choose plan</div>
<div class="step cornered">Purchase</div>
<div class="step cornered">Receive Product</div>
</div>
</div>
</div>
<div class="">
<h2 class="text-xl">Content</h2>
<div class="grid gap-4">
<div class="steps success left">
<div class="step active" data-content="">Checked</div>
<div class="step active" data-content="">Empty</div>
<div class="step" data-content="">Star</div>
<div class="step" data-content="">circle</div>
<div class="step" data-content="💪">emoji</div>
</div>
</div>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions apps/website/pages/docs/components/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"prompt": "Prompt",
"radio": "Radio",
"select": "Select",
"steps": "Steps",
"switch": "Switch",
"table": "Table",
"tabs": "Tabs",
Expand Down
25 changes: 25 additions & 0 deletions apps/website/pages/docs/components/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,29 @@ import { ComponentOverviewCard } from '../../../components/ComponentOverview';
</>
}
/>
<ComponentOverviewCard
name={'Steps'}
href={'steps'}
component={
<>
<div class="steps danger top">
<div class="step active" data-content="">
Checked
</div>
<div class="step active" data-content="">
Empty
</div>
<div class="step" data-content="">
Star
</div>
<div class="step" data-content="">
circle
</div>
<div class="step" data-content="💪">
emoji
</div>
</div>
</>
}
/>
</div>
106 changes: 106 additions & 0 deletions apps/website/pages/docs/components/steps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { CodeDemo } from '../../../components/demo/code';

# Steps

## Position

Use `top` `bottom` `left` `right` classes to control the position of steps.

<CodeDemo>
<div class="steps success top">
<div class="step active">Register</div>
<div class="step active">Choose plan</div>
<div class="step">Purchase</div>
<div class="step">Receive Product</div>
</div>
</CodeDemo>

<CodeDemo>
<div class="steps success bottom">
<div class="step">Register</div>
<div class="step active-point">Choose plan</div>
<div class="step active">Purchase</div>
<div class="step">Receive Product</div>
</div>
</CodeDemo>

<CodeDemo>
<div class="steps success left">
<div class="step">Register</div>
<div class="step">Choose plan</div>
<div class="step active-point">Purchase</div>
<div class="step active">Receive Product</div>
</div>
</CodeDemo>

<CodeDemo>
<div class="steps success right">
<div class="step">Register</div>
<div class="step active-point">Choose plan</div>
<div class="step active">Purchase</div>
<div class="step">Receive Product</div>
</div>
</CodeDemo>

## Active waypoints

Use `active` `active-point` classes to control the activation of steps.

- `active`: will activate bar and dot of steps.
- `active-point`: will only activate dot part of the step.

<CodeDemo>
<div class="steps danger bottom">
<div class="step">Register</div>
<div class="step active-point">Choose plan</div>
<div class="step active">Purchase</div>
<div class="step">Receive Product</div>
</div>
</CodeDemo>

## Shape

Use `cornered` `square` classes to control the shape of step's waypoint.
Defaults to circle.

<CodeDemo>
<div class="flex gap-4">
<div class="steps success right">
<div class="step square active">Register</div>
<div class="step square active">Choose plan</div>
<div class="step square">Purchase</div>
<div class="step square">Receive Product</div>
</div>
<div class="steps danger left">
<div class="step cornered active">Register</div>
<div class="step cornered active">Choose plan</div>
<div class="step cornered">Purchase</div>
<div class="step cornered">Receive Product</div>
</div>
</div>
</CodeDemo>

## Custom content

And you can customize the content of step's waypoint.
Just add the `data-content` attribute on it.

<CodeDemo>
<div class="steps success left">
<div class="step active" data-content="">
Checked
</div>
<div class="step active" data-content="">
Empty
</div>
<div class="step" data-content="">
Star
</div>
<div class="step" data-content="">
circle
</div>
<div class="step" data-content="💪">
emoji
</div>
</div>
</CodeDemo>
1 change: 1 addition & 0 deletions packages/tailwind/src/style/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
@import 'components/table.css';
@import 'components/tooltip.css';
@import 'components/link.css';
@import 'components/steps.css';
93 changes: 93 additions & 0 deletions packages/tailwind/src/style/components/steps.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.steps {
@apply grid place-content-stretch place-items-stretch;
counter-reset: step;
}

.steps:where(.top, .bottom) {
@apply grid-flow-col auto-cols-fr w-full gap-5;
}

.steps:where(.left, .right) {
@apply grid-flow-row auto-rows-fr w-fit gap-3;
}

.steps .step {
@apply relative flex items-center gap-2 whitespace-nowrap;
@apply font-medium;
color: rgba(var(--sira-color-1000), var(--tw-text-opacity));
}
.steps.top .step {
@apply flex-col-reverse;
}
.steps.bottom .step {
@apply flex-col;
}
.steps.left .step {
@apply flex-row-reverse justify-end;
}
.steps.right .step {
@apply flex-row justify-end;
}

/* after element for dot */
.steps .step:after {
content: counter(step);
counter-increment: step;
z-index: 1;
@apply flex justify-center items-center h-8 w-8 rounded-full;
}
.steps .step[data-content]:after {
content: attr(data-content);
}
/* dot shape */
.steps .step.cornered:after {
@apply rounded-xl;
}
.steps .step.square:after {
@apply rounded-lg;
}

/* before element for bar */
.steps .step:first-child:before {
content: none;
}
.steps .step:before {
content: '';
@apply transform block absolute;
}

.steps:where(.top, .bottom) .step:before {
@apply h-2 w-full -translate-y-1/2 scale-x-110;
}
.steps.top .step:before {
left: -55%;
top: 25%;
}
.steps.bottom .step:before {
left: -55%;
top: 75%;
}

.steps:where(.left, .right) .step:before {
@apply w-2 h-full scale-y-110;
top: -75%;
}
.steps.left .step:before {
left: 0.75rem;
}
.steps.right .step:before {
right: 0.75rem;
}

/* color style */
.steps .step + .step:before,
.steps .step:after {
background-color: rgb(var(--sira-color-100));
color: rgb(var(--sira-color-800));
}
.steps .step + .step.active:before,
.steps .step.active:after,
/* only active dot (not bar) */
.steps .step.active-point:after {
background-color: rgb(var(--sira-color-300));
}

1 comment on commit cf53d9f

@vercel
Copy link

@vercel vercel bot commented on cf53d9f Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sira – ./

sira-git-main-riccox.vercel.app
sira.vercel.app
sira.riccox.com
sira-riccox.vercel.app

Please sign in to comment.