Skip to content

Commit

Permalink
feat(SwitchThin): add new colors
Browse files Browse the repository at this point in the history
  • Loading branch information
driss-chelouati committed Feb 19, 2024
1 parent df0c3ea commit c1291fd
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/plugins/components/switch-thin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ export default plugin(({ addComponents, theme }) => {
[`@apply bg-${config.color.danger.light} dark:bg-${config.color.danger.dark}`]:
{},
},
//color:dark
'&.nui-switch-thin-dark .nui-switch-thin-input:checked ~ .nui-switch-thin-track':
{
[`@apply bg-${config.color.dark.light} dark:bg-${config.color.dark.dark}`]:
{},
},
//color:black
'&.nui-switch-thin-black .nui-switch-thin-input:checked ~ .nui-switch-thin-track':
{
[`@apply bg-${config.color.black.light} dark:bg-${config.color.black.dark}`]:
{},
},
},
})
}, config)
8 changes: 8 additions & 0 deletions src/plugins/components/switch-thin/switch-thin.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ export const defaultConfig = {
light: 'danger-400',
dark: 'danger-400',
},
dark: {
light: 'muted-900',
dark: 'muted-100',
},
black: {
light: 'black',
dark: 'white',
},
},
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/components/switch-thin/switch-thin.doc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Switches can have different active colors.
<Story of={SwitchThinStories.ColorSuccess} />
<Story of={SwitchThinStories.ColorWarning} />
<Story of={SwitchThinStories.ColorDanger} />
<Story of={SwitchThinStories.ColorDark} />
<Story of={SwitchThinStories.ColorBlack} />
</div>

<br />
Expand Down
30 changes: 29 additions & 1 deletion src/plugins/components/switch-thin/switch-thin.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ const meta = {
},
color: {
control: { type: 'select' },
options: ['primary', 'info', 'success', 'warning', 'danger'],
options: [
'primary',
'info',
'success',
'warning',
'danger',
'dark',
'black',
],
defaultValue: 'primary',
},
'?disabled': {
Expand Down Expand Up @@ -105,6 +113,26 @@ export const ColorDanger: Story = {
checked: 'true',
},
}

export const ColorDark: Story = {
name: 'Color: dark',
args: {
label: 'Thin switch',
color: 'dark',
id: 'switch-thin-dark',
checked: 'true',
},
}

export const ColorBlack: Story = {
name: 'Color: black',
args: {
label: 'Thin switch',
color: 'black',
id: 'switch-thin-black',
checked: 'true',
},
}
// #endregion

// #region Colors
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/components/switch-thin/switch-thin.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ export interface SwitchThinProps extends Record<string, unknown> {
id?: string
label?: string
sublabel?: string
color?: 'primary' | 'info' | 'success' | 'warning' | 'danger'
color?:
| 'primary'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'dark'
| 'black'
classes?: {
wrapper?: string | string[]
outer?: string | string[]
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/components/switch-thin/switch-thin.variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export const color = {
success: 'nui-switch-thin-success',
warning: 'nui-switch-thin-warning',
danger: 'nui-switch-thin-danger',
dark: 'nui-switch-thin-dark',
black: 'nui-switch-thin-black',
} as const satisfies SwitchThinVariant<'color'>

0 comments on commit c1291fd

Please sign in to comment.