@boostdev/design-system-components 0.1.15 → 0.1.16
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/dist/client.cjs +49 -47
- package/dist/client.css +431 -435
- package/dist/client.d.cts +3 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +49 -47
- package/dist/index.cjs +49 -47
- package/dist/index.css +431 -435
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +49 -47
- package/package.json +1 -1
- package/src/components/interaction/form/Switch/Switch.mdx +7 -2
- package/src/components/interaction/form/Switch/Switch.module.css +6 -6
- package/src/components/interaction/form/Switch/Switch.spec.tsx +23 -0
- package/src/components/interaction/form/Switch/Switch.stories.tsx +8 -0
- package/src/components/interaction/form/Switch/Switch.tsx +5 -2
- package/src/components/interaction/form/atoms/Label.module.css +0 -1
- package/src/components/ui/Progress/Progress.module.css +0 -4
|
@@ -19,6 +19,14 @@ export const WithError: Story = { args: { label: 'Required toggle', name: 'requi
|
|
|
19
19
|
export const Disabled: Story = { args: { label: 'Unavailable', name: 'unavailable', disabled: true } };
|
|
20
20
|
export const DisabledChecked: Story = { args: { label: 'Always on', name: 'always-on', defaultChecked: true, disabled: true } };
|
|
21
21
|
|
|
22
|
+
export const WithPrefix: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
label: 'On',
|
|
25
|
+
name: 'theme',
|
|
26
|
+
prefix: 'Off',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
22
30
|
export const AllSizes: Story = {
|
|
23
31
|
render: () => (
|
|
24
32
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {InputHTMLAttributes, ReactNode, useId} from 'react';
|
|
2
2
|
import css from './Switch.module.css';
|
|
3
3
|
import { cn } from '@boostdev/design-system-foundation';
|
|
4
4
|
import { InputContainer } from '../atoms/InputContainer';
|
|
5
5
|
import { Label } from '../atoms/Label';
|
|
6
6
|
import { Message } from '../atoms/Message';
|
|
7
7
|
|
|
8
|
-
interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
|
|
8
|
+
interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size' | 'prefix'> {
|
|
9
9
|
label: string;
|
|
10
10
|
name: string;
|
|
11
11
|
size?: 'small' | 'medium' | 'large';
|
|
12
12
|
error?: string;
|
|
13
13
|
hint?: string;
|
|
14
14
|
className?: string;
|
|
15
|
+
prefix?: ReactNode;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function Switch({
|
|
@@ -21,6 +22,7 @@ export function Switch({
|
|
|
21
22
|
error,
|
|
22
23
|
hint,
|
|
23
24
|
className,
|
|
25
|
+
prefix,
|
|
24
26
|
...props
|
|
25
27
|
}: Readonly<SwitchProps>) {
|
|
26
28
|
const id = name + useId();
|
|
@@ -31,6 +33,7 @@ export function Switch({
|
|
|
31
33
|
return (
|
|
32
34
|
<InputContainer className={cn(css.switchGroup, css[`--size_${size}`], className)}>
|
|
33
35
|
<div className={css.inputWrapper}>
|
|
36
|
+
{prefix && <Label id={id} label={prefix}/>}
|
|
34
37
|
<div className={css.trackWrapper}>
|
|
35
38
|
<input
|
|
36
39
|
type="checkbox"
|