File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
packages/wizard/src/WizardStep Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change
1
+ import React , { PropsWithChildren } from 'react' ;
2
+ import { Polymorph , PolymorphicAs } from '@leafygreen-ui/polymorphic' ;
3
+
4
+ /**
5
+ * Wraps a string in the provided `as` component,
6
+ * or renders the provided `ReactNode`.
7
+ *
8
+ * Useful when rendering `children` props that can be any react node
9
+ *
10
+ * @example
11
+ * ```
12
+ * <TextNode as={h1}>Hello!</TextNode> // <h1>Hello!</h1>
13
+ * ```
14
+ *
15
+ * @example
16
+ * ```
17
+ * <TextNode><h2>Hello!</h2></TextNode> // <h2>Hello!</h2>
18
+ * ```
19
+ *
20
+ */
21
+ // TODO: Move to `Typography`
22
+ export const TextNode = ( {
23
+ children,
24
+ as,
25
+ } : PropsWithChildren < { as ?: PolymorphicAs } > ) => {
26
+ return typeof children === 'string' || typeof children === 'number' ? (
27
+ < Polymorph as = { as } > { children } </ Polymorph >
28
+ ) : (
29
+ children
30
+ ) ;
31
+ } ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
3
- import { Description , H3 } from '@leafygreen-ui/typography' ;
3
+ import { TextNode , Description , H3 } from '@leafygreen-ui/typography' ;
4
4
5
5
import { stepStyles } from './WizardStep.styles' ;
6
6
import { WizardStepProps } from './WizardStep.types' ;
7
+ import { WizardSubComponentProperties } from '../constants' ;
7
8
8
9
export function WizardStep ( { title, description, children } : WizardStepProps ) {
9
10
return (
10
11
< div className = { stepStyles } >
11
- < H3 > { title } </ H3 >
12
- { description && < Description > { description } </ Description > }
12
+ < TextNode as = { H3 } > { title } </ TextNode >
13
+ { description && < TextNode as = { Description } > { description } </ TextNode > }
13
14
< div > { children } </ div >
14
15
</ div >
15
16
) ;
16
17
}
17
18
18
19
WizardStep . displayName = 'WizardStep' ;
20
+ WizardStep [ WizardSubComponentProperties . Step ] = true ;
You can’t perform that action at this time.
0 commit comments