@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.
@@ -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 { InputHTMLAttributes, useId } from 'react';
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"
@@ -3,7 +3,6 @@
3
3
  display: flex;
4
4
  align-items: center;
5
5
  font-family: var(--font_family--body);
6
- font-weight: var(--font_weight--semibold);
7
6
  color: var(--color_on-bg);
8
7
  cursor: pointer;
9
8
  }
@@ -14,10 +14,6 @@
14
14
  color: var(--color_on-bg);
15
15
  }
16
16
 
17
- .label {
18
- font-weight: var(--font_weight--semibold);
19
- }
20
-
21
17
  .value {
22
18
  font-variant-numeric: tabular-nums;
23
19
  }