-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add Svelte + React stepper components
- Loading branch information
1 parent
4c98734
commit 06bd895
Showing
7 changed files
with
112 additions
and
19 deletions.
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 |
---|---|---|
|
@@ -76,6 +76,7 @@ const buildTypes = type => { | |
'Icon', | ||
'Rating', | ||
'Spinner', | ||
'Stepper', | ||
'Table', | ||
'Progress' | ||
] | ||
|
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
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 |
---|---|---|
@@ -1,14 +1,59 @@ | ||
<script lang="ts"> | ||
import type { StepperProps } from './stepper' | ||
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte' | ||
import { classNames } from '../../utils/classNames' | ||
import styles from './stepper.module.scss' | ||
export let items: StepperProps['items'] = [] | ||
export let color: StepperProps['color'] = '' | ||
export let completedColor: StepperProps['completedColor'] = '' | ||
export let activeColor: StepperProps['activeColor'] = '' | ||
export let borderless: StepperProps['vertical'] = false | ||
export let vertical: StepperProps['vertical'] = false | ||
export let className: StepperProps['className'] = '' | ||
const classes = classNames([ | ||
styles.stepper, | ||
borderless && styles.borderless, | ||
vertical && styles.vertical, | ||
className | ||
]) | ||
</script> | ||
const styleVariables = [ | ||
color && `--w-stepper-color-border: ${color}`, | ||
completedColor && `--w-stepper-color-complete: ${completedColor}`, | ||
activeColor && `--w-stepper-color-active: ${activeColor}` | ||
].filter(Boolean).join(';') | ||
</script> | ||
|
||
<ol class={classes} style={styleVariables || null}> | ||
{#each items as item, index} | ||
<li class={classNames([ | ||
index !== 0 && styles.connect, | ||
item.active && styles.active, | ||
item.completed && styles.completed | ||
])}> | ||
<span class={styles.number}> | ||
{#if item.icon} | ||
{@html item.icon} | ||
{:else} | ||
{index + 1} | ||
{/if} | ||
</span> | ||
<ConditionalWrapper | ||
condition={!!(item.title && item.subTitle)} | ||
class={styles.container} | ||
> | ||
{#if item.title} | ||
<span>{item.title}</span> | ||
{/if} | ||
{#if item.subTitle} | ||
<span class={styles.muted}>{item.subTitle}</span> | ||
{/if} | ||
</ConditionalWrapper> | ||
</li> | ||
{/each} | ||
</ol> |
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 |
---|---|---|
@@ -1,19 +1,60 @@ | ||
import React from 'react' | ||
import type { StepperProps } from './stepper' | ||
|
||
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx' | ||
|
||
import { classNames } from '../../utils/classNames' | ||
|
||
import styles from './stepper.module.scss' | ||
|
||
const Stepper = ({ | ||
items, | ||
color, | ||
completedColor, | ||
activeColor, | ||
borderless, | ||
vertical, | ||
className | ||
}: StepperProps) => { | ||
const classes = classNames([ | ||
styles.stepper, | ||
borderless && styles.borderless, | ||
vertical && styles.vertical, | ||
className | ||
]) | ||
|
||
return <div>Stepper</div> | ||
const styleVariables = { | ||
...(color && { '--w-stepper-color-border': color }), | ||
...(completedColor && { '--w-stepper-color-complete': completedColor }), | ||
...(activeColor && { '--w-stepper-color-active': activeColor }) | ||
} as React.CSSProperties | ||
|
||
return ( | ||
<ol className={classes} style={styleVariables}> | ||
{items?.map((item, index) => ( | ||
<li className={classNames([ | ||
index !== 0 && styles.connect, | ||
item.active && styles.active, | ||
item.completed && styles.completed | ||
])} key={index}> | ||
<span | ||
className={styles.number} | ||
dangerouslySetInnerHTML={{ __html: item.icon | ||
? item.icon | ||
: index + 1 | ||
}} | ||
/> | ||
<ConditionalWrapper | ||
condition={!!(item.title && item.subTitle)} | ||
wrapper={children => <div className={styles.container}>{children}</div>} | ||
> | ||
{item.title && <span>{item.title}</span>} | ||
{item.subTitle && <span className={styles.muted}>{item.subTitle}</span>} | ||
</ConditionalWrapper> | ||
</li> | ||
))} | ||
</ol> | ||
) | ||
} | ||
|
||
export default Stepper | ||
export default 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
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
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