Skip to content

Commit

Permalink
fix: stepper component (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
leduyhien152 authored Apr 16, 2024
1 parent 90daca5 commit e0cf264
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/brown-queens-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@mochi-ui/stepper": minor
"@mochi-ui/theme": minor
---

Fix Stepper component
9 changes: 5 additions & 4 deletions packages/components/stepper/src/step-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { stepper } from '@mochi-ui/theme'
import { CheckLine, CloseLine, SpinnerLine } from '@mochi-ui/icons'
import { useStepperContext } from './context'

const { stepIndicatorClsx } = stepper
const { stepIndicatorClsx, stepIndicatorIconClsx, stepIndicatorLoadingClsx } =
stepper

interface StepIndicatorProps extends PropsWithChildren {
className?: string
Expand All @@ -19,13 +20,13 @@ const StepIndicator = forwardRef<HTMLDivElement, StepIndicatorProps>(
let children = null
if (isLoading) {
status = 'loading'
children = <SpinnerLine className="w-full h-full text-primary-solid" />
children = <SpinnerLine className={stepIndicatorLoadingClsx()} />
} else if (isError) {
status = 'error'
children = <CloseLine className="w-4 h-4 text-text-contrast" />
children = <CloseLine className={stepIndicatorIconClsx()} />
} else if (stepStatus === 'complete') {
status = 'success'
children = <CheckLine className="w-4 h-4 text-text-contrast" />
children = <CheckLine className={stepIndicatorIconClsx()} />
} else {
status = stepStatus
children = step
Expand Down
2 changes: 1 addition & 1 deletion packages/components/stepper/src/step-separator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ const StepSeparator = forwardRef<HTMLDivElement, StepSeparatorProps>(
},
)

StepSeparator.displayName = 'StepTitle'
StepSeparator.displayName = 'StepSeparator'

export { StepSeparator, type StepSeparatorProps }
13 changes: 12 additions & 1 deletion packages/theme/src/components/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,23 @@ const stepIndicatorClsx = ({
className,
)

const stepIndicatorIconClsx = ({
className = '',
}: { className?: string } = {}) => clsx('w-4 h-4 text-text-contrast', className)

const stepIndicatorLoadingClsx = ({
className = '',
}: { className?: string } = {}) =>
clsx('w-full h-full text-primary-solid', className)

const stepContentClsx = ({ className = '' }: { className?: string } = {}) =>
clsx('flex flex-col space-y-0.5', className)

const stepTitleClsx = ({ className = '' }: { className?: string } = {}) =>
clsx('', className)

const stepDescriptionClsx = ({ className = '' }: { className?: string } = {}) =>
clsx('', className)
clsx('font-normal', className)

const stepSeparatorClsx = ({
className = '',
Expand All @@ -85,6 +94,8 @@ const stepper = {
stepperCva,
stepClsx,
stepIndicatorClsx,
stepIndicatorIconClsx,
stepIndicatorLoadingClsx,
stepContentClsx,
stepTitleClsx,
stepDescriptionClsx,
Expand Down

0 comments on commit e0cf264

Please sign in to comment.