Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions packages/core/src/Stepper/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type BaseProps = HTMLAttributes<BaseElement>

export interface StepContent extends BaseProps {
/* Step's label */
readonly label: string
readonly label: ReactNode
/* Step's content */
readonly content: ReactNode
/* Indicates whether the step has errors that should be resolved */
Expand Down Expand Up @@ -109,8 +109,9 @@ const StepHeader = styled.div`
position: relative;
margin-top: -${spacing.large};
`
export const StepLabel = styled(Typography).attrs({ variant: 'default-text' })``

const StepLabel = styled(Typography)<{
const StepLabelWrapper = styled.div<{
readonly active: boolean
readonly completed: boolean
}>`
Expand Down Expand Up @@ -277,9 +278,9 @@ export const Step: FC<StepProps> = ({
{lastStep ? null : (
<StepDivider active={active} completed={completed} />
)}
<StepLabel variant="default-text" active={active} completed={completed}>
<StepLabelWrapper active={active} completed={completed}>
{label}
</StepLabel>
</StepLabelWrapper>
{active ? (
<StepContentContainer>{children}</StepContentContainer>
) : null}
Expand Down
72 changes: 48 additions & 24 deletions packages/core/src/Stepper/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,15 @@ exports[`Stepper Stepper 1`] = `
<span
className="c9"
/>
<p
className="c7 c10"
<div
className="c10"
>
Step 1 Title
</p>
<p
className="c7"
>
Step 1 Title
</p>
</div>
<div
className="c11"
>
Expand Down Expand Up @@ -359,11 +363,15 @@ exports[`Stepper Stepper 1`] = `
<span
className="c18"
/>
<p
className="c7 c19"
<div
className="c19"
>
Step 2 Title
</p>
<p
className="c7"
>
Step 2 Title
</p>
</div>
</div>
</div>
<div
Expand All @@ -386,11 +394,15 @@ exports[`Stepper Stepper 1`] = `
<div
className="c8"
>
<p
className="c7 c19"
<div
className="c19"
>
Step 3 Title (done)
</p>
<p
className="c7"
>
Step 3 Title (done)
</p>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -697,11 +709,15 @@ exports[`Stepper Stepper 2`] = `
<span
className="c9"
/>
<p
className="c7 c10"
<div
className="c10"
>
Step 1 Title
</p>
<p
className="c7"
>
Step 1 Title
</p>
</div>
<div
className="c11"
>
Expand Down Expand Up @@ -756,11 +772,15 @@ exports[`Stepper Stepper 2`] = `
<div
className="c8"
>
<p
className="c7 c18"
<div
className="c18"
>
Step 3 Title (done)
</p>
<p
className="c7"
>
Step 3 Title (done)
</p>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -1013,11 +1033,15 @@ exports[`Stepper Stepper 3`] = `
<div
className="c8"
>
<p
className="c7 c9"
<div
className="c9"
>
Step 1 Title
</p>
<p
className="c7"
>
Step 1 Title
</p>
</div>
<div
className="c10"
>
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/Stepper/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'jest-styled-components'
import { expect, test, describe } from '@jest/globals'

import { TestRender } from '../TestUtils'
import { Stepper } from '.'
import { Stepper, StepLabel } from '.'

const NOOP = () => {
/** */
Expand All @@ -14,16 +14,16 @@ describe('Stepper', () => {
<Stepper
steps={[
{
label: 'Step 1 Title',
label: <StepLabel>Step 1 Title</StepLabel>,
content: <div />,
},
{
label: 'Step 2 Title',
label: <StepLabel>Step 2 Title</StepLabel>,
content: <div />,
hasErrors: true,
},
{
label: 'Step 3 Title (done)',
label: <StepLabel>Step 3 Title (done)</StepLabel>,
content: <div />,
},
]}
Expand Down Expand Up @@ -51,11 +51,11 @@ describe('Stepper', () => {
<Stepper
steps={[
{
label: 'Step 1 Title',
label: <StepLabel>Step 1 Title</StepLabel>,
content: <div />,
},
{
label: 'Step 3 Title (done)',
label: <StepLabel>Step 3 Title (done)</StepLabel>,
content: <div />,
},
]}
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('Stepper', () => {
<Stepper
steps={[
{
label: 'Step 1 Title',
label: <StepLabel>Step 1 Title</StepLabel>,
content: <div />,
},
]}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Stepper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const StepperWrapper = styled(Paper)`
box-shadow: none;
`

export { StepContent, StepperAction } from './Step'
export { StepContent, StepperAction, StepLabel } from './Step'

type BaseElement = HTMLDivElement
type BaseProps = HTMLAttributes<BaseElement>
Expand Down
13 changes: 7 additions & 6 deletions packages/docs/src/mdx/coreComponents/Stepper.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Typography,
RadioButtonGroupField,
Stepper,
StepLabel,
} from 'practical-react-components-core'

# Stepper
Expand All @@ -35,7 +36,7 @@ export const DemoComponent = ({}) => {
className="my-stepper"
steps={[
{
label: 'Step 1 Title',
label: <StepLabel>Step 1 Title</StepLabel>,
content: (
<div>
<RadioButtonGroupField
Expand All @@ -50,15 +51,15 @@ export const DemoComponent = ({}) => {
className: 'my-step',
},
{
label: 'Step 2 Title',
label: <StepLabel>Step 2 Title</StepLabel>,
content: (
<div>
<TextInputField label="Name" value="" placeholder="First name" />
</div>
),
},
{
label: 'Step 3 Title (done)',
label: <StepLabel>Step 3 Title (done)</StepLabel>,
content: (
<Typography variant="navigation-label">You are now done</Typography>
),
Expand Down Expand Up @@ -92,7 +93,7 @@ export const DemoComponent = ({}) => {
<Stepper
steps={[
{
label: 'Step 1 Title',
label: <StepLabel>Step 1 Title</StepLabel>,
content: (
<div>
<RadioButtonGroupField
Expand All @@ -109,15 +110,15 @@ export const DemoComponent = ({}) => {
),
},
{
label: 'Step 2 Title',
label: <StepLabel>Step 2 Title</StepLabel>,
content: (
<div>
<TextInputField label="Name" value="" placeholder="First name" />
</div>
),
},
{
label: 'Step 3 Title (done)',
label: <StepLabel>Step 3 Title (done)</StepLabel>,
content: (
<Typography variant="navigation-label">You are now done</Typography>
),
Expand Down