@liguelead/design-system 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Button/Button.appearance.ts +62 -62
- package/components/Button/Button.sizes.ts +41 -41
- package/components/Button/Button.styles.ts +50 -50
- package/components/Button/Button.tsx +76 -76
- package/components/Button/Button.types.ts +23 -23
- package/components/Button/index.ts +1 -1
- package/components/Checkbox/Checkbox.styles.ts +66 -66
- package/components/Checkbox/Checkbox.tsx +40 -40
- package/components/Checkbox/Checkbox.types.ts +11 -11
- package/components/Checkbox/index.tsx +2 -2
- package/components/DatePicker/DatePicker.styles.ts +66 -66
- package/components/DatePicker/DatePicker.tsx +135 -135
- package/components/DatePicker/DatePicker.types.ts +29 -29
- package/components/DatePicker/index.ts +1 -1
- package/components/IconButton/IconButton.sizes.ts +41 -41
- package/components/IconButton/IconButton.tsx +70 -70
- package/components/IconButton/index.ts +1 -1
- package/components/PageWrapper/PageWrapper.tsx +31 -31
- package/components/PageWrapper/index.ts +1 -1
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
- package/components/SegmentedButton/SegmentedButton.tsx +49 -49
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
- package/components/SegmentedButton/index.ts +1 -1
- package/components/Select/Select.sizes.ts +56 -56
- package/components/Select/Select.states.tsx +69 -69
- package/components/Select/Select.styles.ts +148 -148
- package/components/Select/Select.tsx +145 -144
- package/components/Select/Select.types.ts +36 -36
- package/components/Select/index.ts +1 -1
- package/components/Text/Text.styles.ts +43 -43
- package/components/Text/Text.tsx +27 -27
- package/components/Text/Text.types.ts +42 -42
- package/components/Text/index.ts +1 -1
- package/components/TextField/TextField.sizes.ts +58 -58
- package/components/TextField/TextField.states.tsx +53 -76
- package/components/TextField/TextField.styles.ts +81 -98
- package/components/TextField/TextField.tsx +105 -108
- package/components/TextField/TextField.types.ts +22 -21
- package/components/TextField/index.ts +2 -2
- package/components/TextField/utils/getState.ts +7 -0
- package/components/ThemeProvider/ThemeProvider.tsx +21 -21
- package/components/ThemeProvider/index.ts +1 -1
- package/components/ThemeProvider/style.ts +969 -969
- package/components/Wizard/StepContent.tsx +28 -28
- package/components/Wizard/StepMenuItem.tsx +33 -33
- package/components/Wizard/Wizard.context.tsx +76 -76
- package/components/Wizard/Wizard.styles.ts +126 -126
- package/components/Wizard/Wizard.tsx +55 -55
- package/components/Wizard/index.ts +1 -1
- package/components/index.ts +11 -11
- package/package.json +41 -39
- package/scripts/createTypes.js +70 -70
- package/utils/colorDarken.ts +10 -10
- package/utils/colorLighten.ts +10 -10
- package/utils/darkenOrLighen.ts +19 -19
- package/utils/getTextColor.ts +12 -12
- package/utils/index.ts +5 -5
- package/utils/parseColor.ts +7 -7
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useWizard } from './Wizard.context'
|
|
4
|
-
|
|
5
|
-
interface IChildrenFunctionParams {
|
|
6
|
-
nextStep: () => void
|
|
7
|
-
prevStep: () => void
|
|
8
|
-
}
|
|
9
|
-
interface StepContentProps {
|
|
10
|
-
children: ((params: IChildrenFunctionParams) => ReactNode) | ReactNode
|
|
11
|
-
stepNumber?: number
|
|
12
|
-
label?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function StepContent({ children, stepNumber }: StepContentProps) {
|
|
16
|
-
const { state, nextStep, prevStep } = useWizard()
|
|
17
|
-
const notActive = stepNumber !== state.currentStep
|
|
18
|
-
|
|
19
|
-
if (notActive) return null
|
|
20
|
-
|
|
21
|
-
if (typeof children === 'function') {
|
|
22
|
-
return <div>{children({ nextStep, prevStep })}</div>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return <>{children}</>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default StepContent
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useWizard } from './Wizard.context'
|
|
4
|
+
|
|
5
|
+
interface IChildrenFunctionParams {
|
|
6
|
+
nextStep: () => void
|
|
7
|
+
prevStep: () => void
|
|
8
|
+
}
|
|
9
|
+
interface StepContentProps {
|
|
10
|
+
children: ((params: IChildrenFunctionParams) => ReactNode) | ReactNode
|
|
11
|
+
stepNumber?: number
|
|
12
|
+
label?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function StepContent({ children, stepNumber }: StepContentProps) {
|
|
16
|
+
const { state, nextStep, prevStep } = useWizard()
|
|
17
|
+
const notActive = stepNumber !== state.currentStep
|
|
18
|
+
|
|
19
|
+
if (notActive) return null
|
|
20
|
+
|
|
21
|
+
if (typeof children === 'function') {
|
|
22
|
+
return <div>{children({ nextStep, prevStep })}</div>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return <>{children}</>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default StepContent
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { useWizard } from './Wizard.context'
|
|
2
|
-
import { WizardMenuItem, StepNumber, StepLabel } from './Wizard.styles'
|
|
3
|
-
|
|
4
|
-
interface StepMenuItemProps {
|
|
5
|
-
stepNumber: number
|
|
6
|
-
label?: string
|
|
7
|
-
menuNavigation?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function StepMenuItem({ stepNumber, label, menuNavigation }: StepMenuItemProps) {
|
|
11
|
-
const { setState, state } = useWizard()
|
|
12
|
-
|
|
13
|
-
const active = stepNumber === state.currentStep
|
|
14
|
-
const completed = state.currentStep > stepNumber
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<WizardMenuItem
|
|
18
|
-
$active={active}
|
|
19
|
-
$completed={completed}
|
|
20
|
-
$menuNavigation={menuNavigation}
|
|
21
|
-
onClick={() => {
|
|
22
|
-
if (menuNavigation) {
|
|
23
|
-
setState((curr) => ({ ...curr, currentStep: stepNumber }))
|
|
24
|
-
}
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<StepNumber>{completed ? <span>C</span> : stepNumber}</StepNumber>
|
|
28
|
-
<StepLabel>{label}</StepLabel>
|
|
29
|
-
</WizardMenuItem>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default StepMenuItem
|
|
1
|
+
import { useWizard } from './Wizard.context'
|
|
2
|
+
import { WizardMenuItem, StepNumber, StepLabel } from './Wizard.styles'
|
|
3
|
+
|
|
4
|
+
interface StepMenuItemProps {
|
|
5
|
+
stepNumber: number
|
|
6
|
+
label?: string
|
|
7
|
+
menuNavigation?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function StepMenuItem({ stepNumber, label, menuNavigation }: StepMenuItemProps) {
|
|
11
|
+
const { setState, state } = useWizard()
|
|
12
|
+
|
|
13
|
+
const active = stepNumber === state.currentStep
|
|
14
|
+
const completed = state.currentStep > stepNumber
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<WizardMenuItem
|
|
18
|
+
$active={active}
|
|
19
|
+
$completed={completed}
|
|
20
|
+
$menuNavigation={menuNavigation}
|
|
21
|
+
onClick={() => {
|
|
22
|
+
if (menuNavigation) {
|
|
23
|
+
setState((curr) => ({ ...curr, currentStep: stepNumber }))
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<StepNumber>{completed ? <span>C</span> : stepNumber}</StepNumber>
|
|
28
|
+
<StepLabel>{label}</StepLabel>
|
|
29
|
+
</WizardMenuItem>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default StepMenuItem
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import React, { createContext, ReactNode, useContext, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
interface IWizardState {
|
|
4
|
-
currentStep: number
|
|
5
|
-
totalSteps: number
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IWizardContext {
|
|
9
|
-
state: IWizardState
|
|
10
|
-
setState: React.Dispatch<React.SetStateAction<IWizardState>>
|
|
11
|
-
nextStep: () => void
|
|
12
|
-
prevStep: () => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface IWizardContextProvider {
|
|
16
|
-
children: ReactNode
|
|
17
|
-
totalSteps: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const INITIAL_VALUE = {
|
|
21
|
-
state: {
|
|
22
|
-
currentStep: 0,
|
|
23
|
-
totalSteps: 0
|
|
24
|
-
},
|
|
25
|
-
setState: () => {},
|
|
26
|
-
nextStep: () => {},
|
|
27
|
-
prevStep: () => {}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const WizardContext = createContext<IWizardContext>(INITIAL_VALUE)
|
|
31
|
-
|
|
32
|
-
function WizardContextProvider({ children, totalSteps }: IWizardContextProvider) {
|
|
33
|
-
const [state, setState] = useState({
|
|
34
|
-
currentStep: 1,
|
|
35
|
-
totalSteps
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
function nextStep() {
|
|
39
|
-
const nextStep = state.currentStep + 1
|
|
40
|
-
|
|
41
|
-
if (nextStep > state.totalSteps) {
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setState((curr) => ({
|
|
46
|
-
...curr,
|
|
47
|
-
currentStep: nextStep
|
|
48
|
-
}))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function prevStep() {
|
|
52
|
-
const prevStep = state.currentStep - 1
|
|
53
|
-
|
|
54
|
-
if (prevStep === 0) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setState((curr) => ({
|
|
59
|
-
...curr,
|
|
60
|
-
currentStep: prevStep
|
|
61
|
-
}))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const value = { state, setState, nextStep, prevStep }
|
|
65
|
-
return <WizardContext.Provider value={value}>{children}</WizardContext.Provider>
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function useWizard() {
|
|
69
|
-
const context = useContext(WizardContext)
|
|
70
|
-
if (context === undefined) {
|
|
71
|
-
throw new Error('useWizard must be used within a WizardContextProvider')
|
|
72
|
-
}
|
|
73
|
-
return context
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { WizardContextProvider, useWizard }
|
|
1
|
+
import React, { createContext, ReactNode, useContext, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
interface IWizardState {
|
|
4
|
+
currentStep: number
|
|
5
|
+
totalSteps: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IWizardContext {
|
|
9
|
+
state: IWizardState
|
|
10
|
+
setState: React.Dispatch<React.SetStateAction<IWizardState>>
|
|
11
|
+
nextStep: () => void
|
|
12
|
+
prevStep: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IWizardContextProvider {
|
|
16
|
+
children: ReactNode
|
|
17
|
+
totalSteps: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const INITIAL_VALUE = {
|
|
21
|
+
state: {
|
|
22
|
+
currentStep: 0,
|
|
23
|
+
totalSteps: 0
|
|
24
|
+
},
|
|
25
|
+
setState: () => {},
|
|
26
|
+
nextStep: () => {},
|
|
27
|
+
prevStep: () => {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const WizardContext = createContext<IWizardContext>(INITIAL_VALUE)
|
|
31
|
+
|
|
32
|
+
function WizardContextProvider({ children, totalSteps }: IWizardContextProvider) {
|
|
33
|
+
const [state, setState] = useState({
|
|
34
|
+
currentStep: 1,
|
|
35
|
+
totalSteps
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function nextStep() {
|
|
39
|
+
const nextStep = state.currentStep + 1
|
|
40
|
+
|
|
41
|
+
if (nextStep > state.totalSteps) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setState((curr) => ({
|
|
46
|
+
...curr,
|
|
47
|
+
currentStep: nextStep
|
|
48
|
+
}))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function prevStep() {
|
|
52
|
+
const prevStep = state.currentStep - 1
|
|
53
|
+
|
|
54
|
+
if (prevStep === 0) {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setState((curr) => ({
|
|
59
|
+
...curr,
|
|
60
|
+
currentStep: prevStep
|
|
61
|
+
}))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const value = { state, setState, nextStep, prevStep }
|
|
65
|
+
return <WizardContext.Provider value={value}>{children}</WizardContext.Provider>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function useWizard() {
|
|
69
|
+
const context = useContext(WizardContext)
|
|
70
|
+
if (context === undefined) {
|
|
71
|
+
throw new Error('useWizard must be used within a WizardContextProvider')
|
|
72
|
+
}
|
|
73
|
+
return context
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { WizardContextProvider, useWizard }
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
import {parseColor} from '../../utils'
|
|
2
|
-
import styled, {css, DefaultTheme} from 'styled-components'
|
|
3
|
-
import Text from '../Text'
|
|
4
|
-
|
|
5
|
-
interface WizardMenuItemProps {
|
|
6
|
-
$active?: boolean
|
|
7
|
-
$completed?: boolean
|
|
8
|
-
$menuNavigation?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const WizardWrapper = styled.div`
|
|
12
|
-
display: flex;
|
|
13
|
-
width: 100%;
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
const WizardMenu = styled.div`
|
|
17
|
-
flex: 1;
|
|
18
|
-
padding: 32px 24px;
|
|
19
|
-
border-radius: 4px 0 0 4px;
|
|
20
|
-
border: 1px solid #ddd;
|
|
21
|
-
border-right: 0;
|
|
22
|
-
background-color: #efefef;
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
const WizardContent = styled.div`
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
flex: 3;
|
|
29
|
-
padding: 32px 24px;
|
|
30
|
-
border-radius: 0 4px 4px 0;
|
|
31
|
-
border: 1px solid #ddd;
|
|
32
|
-
border-left: 0;
|
|
33
|
-
background-color: ${({theme}) => parseColor(theme.colors.white)};
|
|
34
|
-
|
|
35
|
-
& > div {
|
|
36
|
-
height: 100%;
|
|
37
|
-
}
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
const itemActive = (theme: DefaultTheme) => {
|
|
41
|
-
return css`
|
|
42
|
-
.step-number {
|
|
43
|
-
background-color: ${parseColor(theme.colors.primary)};
|
|
44
|
-
border-color: ${parseColor(theme.colors.primary)};
|
|
45
|
-
color: ${parseColor(theme.colors.neutral100)};
|
|
46
|
-
}
|
|
47
|
-
.step-number::after {
|
|
48
|
-
border-left: 1px dashed ${parseColor(theme.colors.primary)};
|
|
49
|
-
}
|
|
50
|
-
`
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const itemCompleted = (theme: DefaultTheme) => {
|
|
54
|
-
return css`
|
|
55
|
-
.step-number {
|
|
56
|
-
background-color: ${parseColor(theme.colors.primary)};
|
|
57
|
-
border-color: ${parseColor(theme.colors.primary)};
|
|
58
|
-
color: ${parseColor(theme.colors.neutral200)};
|
|
59
|
-
}
|
|
60
|
-
.step-number::after {
|
|
61
|
-
background-color: ${parseColor(theme.colors.primary)};
|
|
62
|
-
border-left: 1px solid ${parseColor(theme.colors.primary)};
|
|
63
|
-
}
|
|
64
|
-
`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const WizardMenuList = styled.ul``
|
|
68
|
-
const WizardMenuItem = styled.li<WizardMenuItemProps>`
|
|
69
|
-
cursor: ${({$menuNavigation}) => ($menuNavigation ? 'pointer' : 'default')};
|
|
70
|
-
display: flex;
|
|
71
|
-
gap: 16px;
|
|
72
|
-
align-items: center;
|
|
73
|
-
& + li {
|
|
74
|
-
margin-top: 30px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
${({theme, $active}) => $active && itemActive(theme)}
|
|
78
|
-
${({theme, $completed}) => $completed && itemCompleted(theme)}
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
const StepNumber = styled(Text).attrs({
|
|
82
|
-
tag: 'span',
|
|
83
|
-
size: 'body01',
|
|
84
|
-
className: 'step-number'
|
|
85
|
-
})`
|
|
86
|
-
position: relative;
|
|
87
|
-
display: flex;
|
|
88
|
-
justify-content: center;
|
|
89
|
-
align-items: center;
|
|
90
|
-
width: 32px;
|
|
91
|
-
height: 32px;
|
|
92
|
-
border-radius: 50%;
|
|
93
|
-
background-color: ${({theme}) => parseColor(theme.colors.neutral300)};
|
|
94
|
-
border: 1px dashed ${({theme}) => parseColor(theme.colors.primary)};
|
|
95
|
-
color: ${({theme}) => parseColor(theme.colors.primary)};
|
|
96
|
-
|
|
97
|
-
&::after {
|
|
98
|
-
content: '';
|
|
99
|
-
position: absolute;
|
|
100
|
-
top: 31px;
|
|
101
|
-
height: 32px;
|
|
102
|
-
width: 1px;
|
|
103
|
-
border-left: 1px dashed ${({theme}) => parseColor(theme.colors.primary)};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
${WizardMenuItem}:last-child &::after {
|
|
107
|
-
display: none;
|
|
108
|
-
}
|
|
109
|
-
`
|
|
110
|
-
const StepLabel = styled(Text).attrs({
|
|
111
|
-
tag: 'p',
|
|
112
|
-
size: 'body01',
|
|
113
|
-
className: 'step-label'
|
|
114
|
-
})`
|
|
115
|
-
color: ${({theme}) => parseColor(theme.colors.neutral900)};
|
|
116
|
-
`
|
|
117
|
-
|
|
118
|
-
export {
|
|
119
|
-
WizardWrapper,
|
|
120
|
-
WizardMenu,
|
|
121
|
-
WizardContent,
|
|
122
|
-
WizardMenuList,
|
|
123
|
-
WizardMenuItem,
|
|
124
|
-
StepNumber,
|
|
125
|
-
StepLabel
|
|
126
|
-
}
|
|
1
|
+
import {parseColor} from '../../utils'
|
|
2
|
+
import styled, {css, DefaultTheme} from 'styled-components'
|
|
3
|
+
import Text from '../Text'
|
|
4
|
+
|
|
5
|
+
interface WizardMenuItemProps {
|
|
6
|
+
$active?: boolean
|
|
7
|
+
$completed?: boolean
|
|
8
|
+
$menuNavigation?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const WizardWrapper = styled.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
width: 100%;
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
const WizardMenu = styled.div`
|
|
17
|
+
flex: 1;
|
|
18
|
+
padding: 32px 24px;
|
|
19
|
+
border-radius: 4px 0 0 4px;
|
|
20
|
+
border: 1px solid #ddd;
|
|
21
|
+
border-right: 0;
|
|
22
|
+
background-color: #efefef;
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
const WizardContent = styled.div`
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
flex: 3;
|
|
29
|
+
padding: 32px 24px;
|
|
30
|
+
border-radius: 0 4px 4px 0;
|
|
31
|
+
border: 1px solid #ddd;
|
|
32
|
+
border-left: 0;
|
|
33
|
+
background-color: ${({theme}) => parseColor(theme.colors.white)};
|
|
34
|
+
|
|
35
|
+
& > div {
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
const itemActive = (theme: DefaultTheme) => {
|
|
41
|
+
return css`
|
|
42
|
+
.step-number {
|
|
43
|
+
background-color: ${parseColor(theme.colors.primary)};
|
|
44
|
+
border-color: ${parseColor(theme.colors.primary)};
|
|
45
|
+
color: ${parseColor(theme.colors.neutral100)};
|
|
46
|
+
}
|
|
47
|
+
.step-number::after {
|
|
48
|
+
border-left: 1px dashed ${parseColor(theme.colors.primary)};
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const itemCompleted = (theme: DefaultTheme) => {
|
|
54
|
+
return css`
|
|
55
|
+
.step-number {
|
|
56
|
+
background-color: ${parseColor(theme.colors.primary)};
|
|
57
|
+
border-color: ${parseColor(theme.colors.primary)};
|
|
58
|
+
color: ${parseColor(theme.colors.neutral200)};
|
|
59
|
+
}
|
|
60
|
+
.step-number::after {
|
|
61
|
+
background-color: ${parseColor(theme.colors.primary)};
|
|
62
|
+
border-left: 1px solid ${parseColor(theme.colors.primary)};
|
|
63
|
+
}
|
|
64
|
+
`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const WizardMenuList = styled.ul``
|
|
68
|
+
const WizardMenuItem = styled.li<WizardMenuItemProps>`
|
|
69
|
+
cursor: ${({$menuNavigation}) => ($menuNavigation ? 'pointer' : 'default')};
|
|
70
|
+
display: flex;
|
|
71
|
+
gap: 16px;
|
|
72
|
+
align-items: center;
|
|
73
|
+
& + li {
|
|
74
|
+
margin-top: 30px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
${({theme, $active}) => $active && itemActive(theme)}
|
|
78
|
+
${({theme, $completed}) => $completed && itemCompleted(theme)}
|
|
79
|
+
`
|
|
80
|
+
|
|
81
|
+
const StepNumber = styled(Text).attrs({
|
|
82
|
+
tag: 'span',
|
|
83
|
+
size: 'body01',
|
|
84
|
+
className: 'step-number'
|
|
85
|
+
})`
|
|
86
|
+
position: relative;
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
align-items: center;
|
|
90
|
+
width: 32px;
|
|
91
|
+
height: 32px;
|
|
92
|
+
border-radius: 50%;
|
|
93
|
+
background-color: ${({theme}) => parseColor(theme.colors.neutral300)};
|
|
94
|
+
border: 1px dashed ${({theme}) => parseColor(theme.colors.primary)};
|
|
95
|
+
color: ${({theme}) => parseColor(theme.colors.primary)};
|
|
96
|
+
|
|
97
|
+
&::after {
|
|
98
|
+
content: '';
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 31px;
|
|
101
|
+
height: 32px;
|
|
102
|
+
width: 1px;
|
|
103
|
+
border-left: 1px dashed ${({theme}) => parseColor(theme.colors.primary)};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
${WizardMenuItem}:last-child &::after {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
`
|
|
110
|
+
const StepLabel = styled(Text).attrs({
|
|
111
|
+
tag: 'p',
|
|
112
|
+
size: 'body01',
|
|
113
|
+
className: 'step-label'
|
|
114
|
+
})`
|
|
115
|
+
color: ${({theme}) => parseColor(theme.colors.neutral900)};
|
|
116
|
+
`
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
WizardWrapper,
|
|
120
|
+
WizardMenu,
|
|
121
|
+
WizardContent,
|
|
122
|
+
WizardMenuList,
|
|
123
|
+
WizardMenuItem,
|
|
124
|
+
StepNumber,
|
|
125
|
+
StepLabel
|
|
126
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react'
|
|
2
|
-
|
|
3
|
-
import StepContent from './StepContent'
|
|
4
|
-
import StepMenuItem from './StepMenuItem'
|
|
5
|
-
import { WizardContextProvider } from './Wizard.context'
|
|
6
|
-
import { WizardWrapper, WizardMenu, WizardContent, WizardMenuList } from './Wizard.styles'
|
|
7
|
-
|
|
8
|
-
type StepProps = {
|
|
9
|
-
label?: string
|
|
10
|
-
stepNumber?: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type WizardStep = ReactElement<StepProps>
|
|
14
|
-
|
|
15
|
-
interface WizardProps {
|
|
16
|
-
children: WizardStep[]
|
|
17
|
-
menuNavigation?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function Wizard({ menuNavigation = true, children }: Readonly<WizardProps>) {
|
|
21
|
-
if (!children) {
|
|
22
|
-
return <div>Necessário criar os Wizards Steps</div>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const totalSteps = children.length
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<WizardContextProvider totalSteps={totalSteps}>
|
|
29
|
-
<WizardWrapper>
|
|
30
|
-
<WizardMenu>
|
|
31
|
-
<WizardMenuList>
|
|
32
|
-
{children.map((item, index) => (
|
|
33
|
-
<StepMenuItem
|
|
34
|
-
menuNavigation={menuNavigation}
|
|
35
|
-
key={index}
|
|
36
|
-
stepNumber={index + 1}
|
|
37
|
-
label={item.props.label}
|
|
38
|
-
/>
|
|
39
|
-
))}
|
|
40
|
-
</WizardMenuList>
|
|
41
|
-
</WizardMenu>
|
|
42
|
-
<WizardContent>
|
|
43
|
-
{React.Children.map(children, (child, index) => {
|
|
44
|
-
return React.cloneElement(child, {
|
|
45
|
-
stepNumber: index + 1
|
|
46
|
-
})
|
|
47
|
-
})}
|
|
48
|
-
</WizardContent>
|
|
49
|
-
</WizardWrapper>
|
|
50
|
-
</WizardContextProvider>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
Wizard.Step = StepContent
|
|
55
|
-
export default Wizard
|
|
1
|
+
import React, { ReactElement } from 'react'
|
|
2
|
+
|
|
3
|
+
import StepContent from './StepContent'
|
|
4
|
+
import StepMenuItem from './StepMenuItem'
|
|
5
|
+
import { WizardContextProvider } from './Wizard.context'
|
|
6
|
+
import { WizardWrapper, WizardMenu, WizardContent, WizardMenuList } from './Wizard.styles'
|
|
7
|
+
|
|
8
|
+
type StepProps = {
|
|
9
|
+
label?: string
|
|
10
|
+
stepNumber?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type WizardStep = ReactElement<StepProps>
|
|
14
|
+
|
|
15
|
+
interface WizardProps {
|
|
16
|
+
children: WizardStep[]
|
|
17
|
+
menuNavigation?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function Wizard({ menuNavigation = true, children }: Readonly<WizardProps>) {
|
|
21
|
+
if (!children) {
|
|
22
|
+
return <div>Necessário criar os Wizards Steps</div>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const totalSteps = children.length
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<WizardContextProvider totalSteps={totalSteps}>
|
|
29
|
+
<WizardWrapper>
|
|
30
|
+
<WizardMenu>
|
|
31
|
+
<WizardMenuList>
|
|
32
|
+
{children.map((item, index) => (
|
|
33
|
+
<StepMenuItem
|
|
34
|
+
menuNavigation={menuNavigation}
|
|
35
|
+
key={index}
|
|
36
|
+
stepNumber={index + 1}
|
|
37
|
+
label={item.props.label}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</WizardMenuList>
|
|
41
|
+
</WizardMenu>
|
|
42
|
+
<WizardContent>
|
|
43
|
+
{React.Children.map(children, (child, index) => {
|
|
44
|
+
return React.cloneElement(child, {
|
|
45
|
+
stepNumber: index + 1
|
|
46
|
+
})
|
|
47
|
+
})}
|
|
48
|
+
</WizardContent>
|
|
49
|
+
</WizardWrapper>
|
|
50
|
+
</WizardContextProvider>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Wizard.Step = StepContent
|
|
55
|
+
export default Wizard
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './Wizard'
|
|
1
|
+
export { default } from './Wizard'
|
package/components/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { default as Button } from './Button'
|
|
2
|
-
export { default as Checkbox } from './Checkbox'
|
|
3
|
-
export { default as DatePicker } from './DatePicker'
|
|
4
|
-
export { default as IconButton } from './IconButton'
|
|
5
|
-
export { default as PageWrapper } from './PageWrapper'
|
|
6
|
-
export { default as Text } from './Text'
|
|
7
|
-
export { default as TextField } from './TextField'
|
|
8
|
-
export { default as ThemeProvider } from './ThemeProvider'
|
|
9
|
-
export { default as Wizard } from './Wizard'
|
|
10
|
-
export { default as Select } from './Select'
|
|
11
|
-
export { default as SegmentedButton } from './SegmentedButton'
|
|
1
|
+
export { default as Button } from './Button'
|
|
2
|
+
export { default as Checkbox } from './Checkbox'
|
|
3
|
+
export { default as DatePicker } from './DatePicker'
|
|
4
|
+
export { default as IconButton } from './IconButton'
|
|
5
|
+
export { default as PageWrapper } from './PageWrapper'
|
|
6
|
+
export { default as Text } from './Text'
|
|
7
|
+
export { default as TextField } from './TextField'
|
|
8
|
+
export { default as ThemeProvider } from './ThemeProvider'
|
|
9
|
+
export { default as Wizard } from './Wizard'
|
|
10
|
+
export { default as Select } from './Select'
|
|
11
|
+
export { default as SegmentedButton } from './SegmentedButton'
|