-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stepper #205
Merged
Stepper #205
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { FC, PropsWithChildren } from 'react'; | ||
|
||
export interface StepProps extends PropsWithChildren { | ||
/** | ||
* Optional Text of the marker | ||
*/ | ||
markerLabel?: string; | ||
|
||
/** | ||
* CSS Classname to applied to the step | ||
*/ | ||
className?: string; | ||
} | ||
|
||
export const Step: FC<StepProps> = ({ children, className }) => ( | ||
<div className={className}>{children}</div> | ||
); |
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,231 @@ | ||
import { Stepper } from './Stepper'; | ||
import { Step } from './Step'; | ||
|
||
export default { | ||
title: 'Components/Layout/Stepper', | ||
component: Stepper | ||
}; | ||
|
||
export const Markers = () => ( | ||
<Stepper activeStep={2}> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin{' '} | ||
<span className="text-gray-400 light:text-gray-600"> | ||
created ticket | ||
</span> | ||
</span> | ||
</div> | ||
</Step> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
Backlog | ||
<span className="text-gray-400 light:text-gray-600"> to </span>In | ||
Progress | ||
</span> | ||
<div className="px-4 py-2 border border-solid border-blue-700 bg-surface rounded-md"> | ||
This looks fine, might've missed it but maybe we can add a link to the | ||
website where we also have the video of how to use the plug in? | ||
Otherwise this is a nice addition. | ||
</div> | ||
</div> | ||
</Step> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
In Progress | ||
<span className="text-gray-400 light:text-gray-600"> to </span>Done | ||
</span> | ||
</div> | ||
</Step> | ||
</Stepper> | ||
); | ||
|
||
export const Numbered = () => ( | ||
<Stepper numbered activeStep={2}> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin{' '} | ||
<span className="text-gray-400 light:text-gray-600"> | ||
created ticket | ||
</span> | ||
</span> | ||
</div> | ||
</Step> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
Backlog | ||
<span className="text-gray-400 light:text-gray-600"> to </span>In | ||
Progress | ||
</span> | ||
<div className="px-4 py-2 border border-solid border-blue-700 bg-surface rounded-md"> | ||
This looks fine, might've missed it but maybe we can add a link to the | ||
website where we also have the video of how to use the plug in? | ||
Otherwise this is a nice addition. | ||
</div> | ||
</div> | ||
</Step> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
In Progress | ||
<span className="text-gray-400 light:text-gray-600"> to </span>Done | ||
</span> | ||
</div> | ||
</Step> | ||
</Stepper> | ||
); | ||
|
||
export const Labels = () => ( | ||
<Stepper> | ||
<Step markerLabel="v6.8"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin{' '} | ||
<span className="text-gray-400 light:text-gray-600"> | ||
created ticket | ||
</span> | ||
</span> | ||
</div> | ||
</Step> | ||
<Step markerLabel="v6.9"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
Backlog | ||
<span className="text-gray-400 light:text-gray-600"> to </span>In | ||
Progress | ||
</span> | ||
<div className="px-4 py-2 border border-solid border-blue-700 bg-surface rounded-md"> | ||
This looks fine, might've missed it but maybe we can add a link to the | ||
website where we also have the video of how to use the plug in? | ||
Otherwise this is a nice addition. | ||
</div> | ||
</div> | ||
</Step> | ||
<Step markerLabel="v7.0"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
In Progress | ||
<span className="text-gray-400 light:text-gray-600"> to </span>Done | ||
</span> | ||
</div> | ||
</Step> | ||
</Stepper> | ||
); | ||
|
||
export const Mixed = () => ( | ||
<Stepper activeStep={3}> | ||
<Step markerLabel="v6.8"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin{' '} | ||
<span className="text-gray-400 light:text-gray-600"> | ||
created ticket | ||
</span> | ||
</span> | ||
</div> | ||
</Step> | ||
<Step> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
Backlog | ||
<span className="text-gray-400 light:text-gray-600"> to </span>In | ||
Progress | ||
</span> | ||
<div className="px-4 py-2 border border-solid border-blue-700 bg-surface rounded-md"> | ||
This looks fine, might've missed it but maybe we can add a link to the | ||
website where we also have the video of how to use the plug in? | ||
Otherwise this is a nice addition. | ||
</div> | ||
</div> | ||
</Step> | ||
<Step markerLabel="v7.0"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="text-sm text-gray-400 light:text-gray-600"> | ||
03/01/2024, 8:00 AM | ||
</span> | ||
<span> | ||
Austin | ||
<span className="text-gray-400 light:text-gray-600"> | ||
{' '} | ||
changed statues from{' '} | ||
</span> | ||
In Progress | ||
<span className="text-gray-400 light:text-gray-600"> to </span>Done | ||
</span> | ||
</div> | ||
</Step> | ||
</Stepper> | ||
); |
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,91 @@ | ||
import { StepperTheme } from '@/layout'; | ||
import { cn, useComponentTheme } from '@/utils'; | ||
import React, { Children, FC, Fragment, PropsWithChildren } from 'react'; | ||
|
||
import { Step, StepProps } from './Step'; | ||
|
||
export interface StepperProps extends PropsWithChildren { | ||
/** | ||
* Currently active step | ||
*/ | ||
activeStep?: number; | ||
|
||
/** | ||
* Theme for the Stepper. | ||
*/ | ||
theme?: StepperTheme; | ||
|
||
/** | ||
* Show number for every step | ||
*/ | ||
numbered?: boolean; | ||
} | ||
export const Stepper: FC<StepperProps> = ({ | ||
amcdnl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
activeStep = 0, | ||
children, | ||
numbered = false, | ||
theme: customTheme | ||
}) => { | ||
const theme: StepperTheme = useComponentTheme('stepper', customTheme); | ||
|
||
const childrenStepProps = Children.toArray(children) | ||
.filter((child: any) => child.type?.name === Step.name) | ||
.map((child: any) => child.props); | ||
|
||
const totalSteps = childrenStepProps.length - 1; | ||
|
||
return ( | ||
<div className={theme.base}> | ||
{childrenStepProps.map((props: StepProps, index) => ( | ||
<Fragment key={index}> | ||
<div | ||
className={cn(theme.step.base, { | ||
'border-transparent': index === totalSteps, | ||
[theme.step.active]: index < activeStep - 1 | ||
})} | ||
> | ||
<div className={theme.step.marker.container}> | ||
{/* Numbered marker */} | ||
{numbered && ( | ||
<div | ||
className={cn(theme.step.marker.label.base, { | ||
[theme.step.marker.label.active]: index < activeStep | ||
})} | ||
> | ||
{index + 1} | ||
</div> | ||
)} | ||
{/* Labeled marker */} | ||
{!numbered && props.markerLabel && ( | ||
<div | ||
className={cn(theme.step.marker.label.base, { | ||
[theme.step.marker.label.active]: index < activeStep | ||
})} | ||
> | ||
<div | ||
className={cn(theme.step.marker.base, { | ||
[theme.step.marker.active]: index < activeStep | ||
})} | ||
/> | ||
{props.markerLabel} | ||
</div> | ||
)} | ||
{/* Dot marker */} | ||
{!numbered && !props.markerLabel && ( | ||
<div | ||
className={cn(theme.step.marker.base, { | ||
[theme.step.marker.active]: index < activeStep | ||
})} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<Step | ||
className={cn(theme.step.content, props.className)} | ||
{...props} | ||
/> | ||
</Fragment> | ||
))} | ||
</div> | ||
); | ||
}; |
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,38 @@ | ||
export interface StepperTheme { | ||
base: string; | ||
step: { | ||
base: string; | ||
marker: { | ||
container: string; | ||
base: string; | ||
active: string; | ||
label: { | ||
base: string; | ||
active: string; | ||
}; | ||
}; | ||
active: string; | ||
content: string; | ||
}; | ||
} | ||
|
||
export const stepperTheme: StepperTheme = { | ||
base: 'grid grid-cols-[min-content_1fr] gap-x-3', | ||
step: { | ||
base: 'border-l border-solid border-panel-accent translate-x-1/2', | ||
marker: { | ||
base: 'rounded-full w-[9px] h-[9px] bg-surface', | ||
container: | ||
'w-max pt-1 pb-0.5 backdrop-blur-md -translate-x-[calc(50%+0.5px)]', | ||
active: 'bg-info', | ||
label: { | ||
base: 'flex flex-row items-center gap-1 border border-solid border-surface px-3 py-1 rounded-[20px]', | ||
active: 'border-info bg-info-background' | ||
} | ||
}, | ||
active: 'border-primary', | ||
content: 'pb-6' | ||
} | ||
}; | ||
|
||
export const legacyStepperTheme: StepperTheme = stepperTheme; |
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,2 @@ | ||
export * from './Stepper'; | ||
export * from './StepperTheme'; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs a role?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean this one https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably
listitem
but I'm not sure