@gtivr4/a1-design-system-react 0.1.0 → 0.2.4

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.
Files changed (111) hide show
  1. package/guidelines/Guidelines.md +228 -0
  2. package/package.json +4 -1
  3. package/src/breakpoints.css +29 -0
  4. package/src/color-scheme.css +586 -24
  5. package/src/components/accordion/Accordion.jsx +80 -0
  6. package/src/components/accordion/accordion.css +118 -0
  7. package/src/components/banner/Banner.jsx +66 -0
  8. package/src/components/banner/banner.css +205 -0
  9. package/src/components/bleed/Bleed.jsx +27 -0
  10. package/src/components/bleed/bleed.css +5 -0
  11. package/src/components/blockquote/Blockquote.jsx +40 -0
  12. package/src/components/blockquote/blockquote.css +166 -0
  13. package/src/components/breadcrumb/Breadcrumb.jsx +82 -0
  14. package/src/components/breadcrumb/breadcrumb.css +133 -0
  15. package/src/components/button/button.css +42 -12
  16. package/src/components/button-container/ButtonContainer.jsx +20 -1
  17. package/src/components/button-container/button-container.css +19 -1
  18. package/src/components/calendar/Calendar.jsx +383 -0
  19. package/src/components/calendar/calendar.css +225 -0
  20. package/src/components/card/Card.jsx +50 -12
  21. package/src/components/card/card.css +178 -14
  22. package/src/components/checkbox-group/CheckboxGroup.jsx +120 -0
  23. package/src/components/checkbox-group/checkbox-group.css +304 -0
  24. package/src/components/cluster/Cluster.jsx +52 -0
  25. package/src/components/cluster/cluster.css +9 -0
  26. package/src/components/code/Code.jsx +135 -0
  27. package/src/components/code/code.css +60 -0
  28. package/src/components/data-table/DataTable.jsx +721 -0
  29. package/src/components/data-table/DataTableFilters.jsx +339 -0
  30. package/src/components/data-table/data-table-filters.css +259 -0
  31. package/src/components/data-table/data-table.css +425 -0
  32. package/src/components/dialog/Dialog.jsx +45 -2
  33. package/src/components/dialog/dialog.css +13 -4
  34. package/src/components/divider/Divider.jsx +64 -0
  35. package/src/components/divider/divider.css +170 -0
  36. package/src/components/field/CreditCardField.jsx +131 -0
  37. package/src/components/field/DateField.jsx +11 -0
  38. package/src/components/field/NumberField.jsx +11 -0
  39. package/src/components/field/PhoneField.jsx +107 -0
  40. package/src/components/field/SelectField.jsx +86 -0
  41. package/src/components/field/TextField.jsx +83 -0
  42. package/src/components/field/TextareaField.jsx +147 -0
  43. package/src/components/field/TimeField.jsx +11 -0
  44. package/src/components/field/ZipField.jsx +114 -0
  45. package/src/components/field/credit-card.css +30 -0
  46. package/src/components/field/field.css +380 -0
  47. package/src/components/field/textarea-field.css +185 -0
  48. package/src/components/field-row/FieldRow.jsx +23 -0
  49. package/src/components/field-row/field-row.css +51 -0
  50. package/src/components/fieldset/Fieldset.jsx +49 -0
  51. package/src/components/fieldset/fieldset.css +75 -0
  52. package/src/components/figure/Figure.jsx +63 -0
  53. package/src/components/figure/figure.css +97 -0
  54. package/src/components/grid/Grid.jsx +36 -2
  55. package/src/components/grid/grid.css +129 -4
  56. package/src/components/heading/Heading.jsx +41 -1
  57. package/src/components/heading/heading.css +65 -4
  58. package/src/components/icon/icon.css +1 -0
  59. package/src/components/icon-button/icon-button.css +1 -0
  60. package/src/components/inline/inline.css +51 -0
  61. package/src/components/inline-editable/InlineEditable.jsx +77 -0
  62. package/src/components/inline-editable/inline-editable.css +47 -0
  63. package/src/components/inset/Inset.jsx +27 -0
  64. package/src/components/inset/inset.css +6 -0
  65. package/src/components/labels/Labels.jsx +5 -5
  66. package/src/components/link/Link.jsx +2 -3
  67. package/src/components/link/link.css +30 -1
  68. package/src/components/list/List.jsx +92 -0
  69. package/src/components/list/list.css +178 -0
  70. package/src/components/menu/Menu.jsx +243 -10
  71. package/src/components/menu/menu.css +157 -17
  72. package/src/components/message/Message.jsx +25 -50
  73. package/src/components/message/message.css +50 -33
  74. package/src/components/notification/Notification.jsx +1 -1
  75. package/src/components/page-layout/PageLayout.jsx +16 -1
  76. package/src/components/page-layout/page-layout.css +97 -4
  77. package/src/components/page-nav/PageNav.jsx +110 -0
  78. package/src/components/page-nav/page-nav.css +167 -0
  79. package/src/components/paragraph/Paragraph.jsx +35 -2
  80. package/src/components/paragraph/paragraph.css +38 -1
  81. package/src/components/radio-group/RadioGroup.jsx +121 -0
  82. package/src/components/radio-group/radio-group.css +268 -0
  83. package/src/components/section/Section.jsx +108 -0
  84. package/src/components/section/section.css +280 -0
  85. package/src/components/segmented-control/SegmentedControl.jsx +4 -0
  86. package/src/components/segmented-control/segmented.css +13 -0
  87. package/src/components/side-nav/SideNav.jsx +29 -9
  88. package/src/components/side-nav/scrim.css +1 -1
  89. package/src/components/side-nav/side-nav.css +70 -32
  90. package/src/components/snackbar/Snackbar.jsx +56 -0
  91. package/src/components/snackbar/snackbar.css +113 -0
  92. package/src/components/spacer/Spacer.jsx +36 -0
  93. package/src/components/spacer/spacer.css +44 -0
  94. package/src/components/stack/Stack.jsx +100 -0
  95. package/src/components/stack/stack.css +37 -0
  96. package/src/components/switch/Switch.jsx +114 -0
  97. package/src/components/switch/switch.css +276 -0
  98. package/src/components/system-banner/SystemBanner.jsx +57 -0
  99. package/src/components/system-banner/system-banner.css +118 -0
  100. package/src/components/tabs/Tabs.jsx +96 -28
  101. package/src/components/tabs/tabs.css +352 -15
  102. package/src/components/token-select/TokenSelect.jsx +159 -0
  103. package/src/components/token-select/token-select.css +110 -0
  104. package/src/components/top-header/TopHeader.jsx +641 -0
  105. package/src/components/top-header/top-header.css +337 -0
  106. package/src/illustrations/ComponentThumbnails.jsx +227 -0
  107. package/src/index.js +41 -5
  108. package/src/themes.css +256 -5
  109. package/src/tokens.css +919 -0
  110. package/src/utilities/spacing.css +8 -0
  111. package/src/utilities/sr-only.css +16 -0
@@ -0,0 +1,100 @@
1
+ import "./stack.css";
2
+ import { resolveSpacing } from "../structure-utils.js";
3
+
4
+ const directions = ["column", "column-reverse", "row", "row-reverse"];
5
+ const alignments = ["stretch", "start", "center", "end", "baseline"];
6
+ const justifications = ["start", "center", "end", "between", "around", "evenly"];
7
+ const semanticGaps = ["xs", "sm", "md", "lg"];
8
+ const breakpoints = ["xs", "sm", "md", "lg", "xl"];
9
+
10
+ function resolveGap(gap) {
11
+ if (semanticGaps.includes(gap)) return `var(--semantic-spacing-gap-${gap})`;
12
+ return resolveSpacing(gap);
13
+ }
14
+
15
+ function isResponsive(value) {
16
+ return value !== null && typeof value === "object" && !Array.isArray(value);
17
+ }
18
+
19
+ function resolveBaseDirection(direction) {
20
+ if (!isResponsive(direction)) return directions.includes(direction) ? direction : "column";
21
+ return directions.includes(direction.xs) ? direction.xs : "column";
22
+ }
23
+
24
+ function getResponsiveDirectionStyle(direction) {
25
+ const base = resolveBaseDirection(direction);
26
+ let lastKnown = base;
27
+ return breakpoints.slice(1).reduce((style, bp) => {
28
+ if (isResponsive(direction) && directions.includes(direction[bp])) {
29
+ lastKnown = direction[bp];
30
+ }
31
+ style[`--a1-stack-direction-${bp}`] = lastKnown;
32
+ return style;
33
+ }, {});
34
+ }
35
+
36
+ function resolveBaseJustify(justify) {
37
+ if (!isResponsive(justify)) return justifications.includes(justify) ? justify : "start";
38
+ return justifications.includes(justify.xs) ? justify.xs : "start";
39
+ }
40
+
41
+ function getResponsiveJustifyStyle(justify) {
42
+ if (!isResponsive(justify)) return {};
43
+ const base = resolveBaseJustify(justify);
44
+ let lastKnown = base;
45
+ return breakpoints.slice(1).reduce((style, bp) => {
46
+ if (justifications.includes(justify[bp])) lastKnown = justify[bp];
47
+ style[`--a1-stack-justify-${bp}`] = justifyMap[lastKnown];
48
+ return style;
49
+ }, {});
50
+ }
51
+
52
+ const justifyMap = {
53
+ start: "flex-start",
54
+ center: "center",
55
+ end: "flex-end",
56
+ between: "space-between",
57
+ around: "space-around",
58
+ evenly: "space-evenly",
59
+ };
60
+
61
+ const alignMap = {
62
+ stretch: "stretch",
63
+ start: "flex-start",
64
+ center: "center",
65
+ end: "flex-end",
66
+ baseline: "baseline",
67
+ };
68
+
69
+ export function Stack({
70
+ as: Component = "div",
71
+ direction = "column",
72
+ gap = 16,
73
+ align = "stretch",
74
+ justify = "start",
75
+ wrap = false,
76
+ className = "",
77
+ children,
78
+ ...props
79
+ }) {
80
+ const resolvedDirection = resolveBaseDirection(direction);
81
+ const resolvedAlign = alignments.includes(align) ? align : "stretch";
82
+ const resolvedJustify = resolveBaseJustify(justify);
83
+
84
+ const style = {
85
+ "--a1-stack-direction": resolvedDirection,
86
+ "--a1-stack-gap": resolveGap(gap),
87
+ "--a1-stack-align": alignMap[resolvedAlign],
88
+ "--a1-stack-justify": justifyMap[resolvedJustify],
89
+ "--a1-stack-wrap": wrap ? "wrap" : "nowrap",
90
+ ...getResponsiveDirectionStyle(direction),
91
+ ...getResponsiveJustifyStyle(justify),
92
+ ...props.style,
93
+ };
94
+
95
+ return (
96
+ <Component className={["a1-stack", className].filter(Boolean).join(" ")} style={style} {...props}>
97
+ {children}
98
+ </Component>
99
+ );
100
+ }
@@ -0,0 +1,37 @@
1
+ .a1-stack {
2
+ display: flex;
3
+ flex-direction: var(--a1-stack-direction-responsive, var(--a1-stack-direction, column));
4
+ flex-wrap: var(--a1-stack-wrap, nowrap);
5
+ align-items: var(--a1-stack-align, stretch);
6
+ justify-content: var(--a1-stack-justify-responsive, var(--a1-stack-justify, flex-start));
7
+ gap: var(--a1-stack-gap, var(--base-spacing-16));
8
+ min-width: 0;
9
+ }
10
+
11
+ @media (--bp-sm-up) {
12
+ .a1-stack {
13
+ --a1-stack-direction-responsive: var(--a1-stack-direction-sm, var(--a1-stack-direction, column));
14
+ --a1-stack-justify-responsive: var(--a1-stack-justify-sm, var(--a1-stack-justify, flex-start));
15
+ }
16
+ }
17
+
18
+ @media (--bp-md-up) {
19
+ .a1-stack {
20
+ --a1-stack-direction-responsive: var(--a1-stack-direction-md, var(--a1-stack-direction-sm, var(--a1-stack-direction, column)));
21
+ --a1-stack-justify-responsive: var(--a1-stack-justify-md, var(--a1-stack-justify-sm, var(--a1-stack-justify, flex-start)));
22
+ }
23
+ }
24
+
25
+ @media (--bp-lg-up) {
26
+ .a1-stack {
27
+ --a1-stack-direction-responsive: var(--a1-stack-direction-lg, var(--a1-stack-direction-md, var(--a1-stack-direction-sm, var(--a1-stack-direction, column))));
28
+ --a1-stack-justify-responsive: var(--a1-stack-justify-lg, var(--a1-stack-justify-md, var(--a1-stack-justify-sm, var(--a1-stack-justify, flex-start))));
29
+ }
30
+ }
31
+
32
+ @media (--bp-xl) {
33
+ .a1-stack {
34
+ --a1-stack-direction-responsive: var(--a1-stack-direction-xl, var(--a1-stack-direction-lg, var(--a1-stack-direction-md, var(--a1-stack-direction-sm, var(--a1-stack-direction, column)))));
35
+ --a1-stack-justify-responsive: var(--a1-stack-justify-xl, var(--a1-stack-justify-lg, var(--a1-stack-justify-md, var(--a1-stack-justify-sm, var(--a1-stack-justify, flex-start)))));
36
+ }
37
+ }
@@ -0,0 +1,114 @@
1
+ import { useId, useState, useContext } from "react";
2
+ import { FieldsetContext } from "../fieldset/FieldsetContext.js";
3
+ import "./switch.css";
4
+
5
+ const SIZES = ["comfortable", "default", "compact"];
6
+ const LABEL_POSITIONS = ["end", "start"];
7
+
8
+ export function Switch({
9
+ label,
10
+ hint,
11
+ error,
12
+ size,
13
+ labelPosition,
14
+ disabled = false,
15
+ checked,
16
+ defaultChecked = false,
17
+ onChange,
18
+ id: providedId,
19
+ className = "",
20
+ name,
21
+ value,
22
+ ...props
23
+ }) {
24
+ const ctx = useContext(FieldsetContext);
25
+ const autoId = useId();
26
+ const id = providedId ?? autoId;
27
+ const hintId = `${id}-hint`;
28
+ const errorId = `${id}-error`;
29
+
30
+ const resolvedSize = SIZES.includes(size) ? size : (ctx?.size ?? "default");
31
+ const resolvedPosition = LABEL_POSITIONS.includes(labelPosition) ? labelPosition : "end";
32
+
33
+ const [internalChecked, setInternalChecked] = useState(defaultChecked);
34
+ const isChecked = checked !== undefined ? checked : internalChecked;
35
+
36
+ function handleChange(e) {
37
+ if (checked === undefined) setInternalChecked(e.target.checked);
38
+ onChange?.(e.target.checked, e);
39
+ }
40
+
41
+ const classes = [
42
+ "a1-switch",
43
+ `a1-switch--${resolvedSize}`,
44
+ label && `a1-switch--label-${resolvedPosition}`,
45
+ error && "a1-switch--error",
46
+ disabled && "a1-switch--disabled",
47
+ className,
48
+ ].filter(Boolean).join(" ");
49
+
50
+ const describedBy = [
51
+ error ? errorId : hint ? hintId : null,
52
+ ].filter(Boolean).join(" ") || undefined;
53
+
54
+ /* The input is sr-only — the <span className="a1-switch__track"> provides
55
+ all visual affordance. CSS uses input + track (adjacent sibling) to
56
+ respond to :checked, :focus-visible, :disabled, etc. on a real element
57
+ where ::before transitions are fully supported. */
58
+ const input = (
59
+ <input
60
+ type="checkbox"
61
+ role="switch"
62
+ id={id}
63
+ className="a1-switch__input"
64
+ checked={isChecked}
65
+ disabled={disabled}
66
+ onChange={handleChange}
67
+ aria-describedby={describedBy}
68
+ aria-invalid={error ? "true" : undefined}
69
+ name={name}
70
+ value={value}
71
+ {...props}
72
+ />
73
+ );
74
+
75
+ const track = (
76
+ <span
77
+ className={`a1-switch__track${isChecked ? " a1-switch__track--on" : ""}`}
78
+ aria-hidden="true"
79
+ />
80
+ );
81
+
82
+ return (
83
+ <div className={classes}>
84
+ {label ? (
85
+ <label className="a1-switch__row">
86
+ {input}
87
+ {track}
88
+ <div className="a1-switch__content">
89
+ <span className="a1-switch__label">{label}</span>
90
+ {hint && !error && (
91
+ <p className="a1-switch__message a1-switch__message--hint" id={hintId}>{hint}</p>
92
+ )}
93
+ {error && (
94
+ <p className="a1-switch__message a1-switch__message--error" id={errorId} role="alert">{error}</p>
95
+ )}
96
+ </div>
97
+ </label>
98
+ ) : (
99
+ <>
100
+ <label className="a1-switch__row">
101
+ {input}
102
+ {track}
103
+ </label>
104
+ {hint && !error && (
105
+ <p className="a1-switch__message a1-switch__message--hint" id={hintId}>{hint}</p>
106
+ )}
107
+ {error && (
108
+ <p className="a1-switch__message a1-switch__message--error" id={errorId} role="alert">{error}</p>
109
+ )}
110
+ </>
111
+ )}
112
+ </div>
113
+ );
114
+ }
@@ -0,0 +1,276 @@
1
+ /* ─── Switch ───────────────────────────────────────────────────────────────── */
2
+
3
+ .a1-switch {
4
+ /* Size tokens — default */
5
+ --a1-sw-track-width: var(--component-switch-track-width);
6
+ --a1-sw-track-height: var(--component-switch-track-height);
7
+ --a1-sw-thumb: var(--component-switch-thumb-size); /* track-height - 2*gap */
8
+ --a1-sw-gap: var(--component-switch-gap);
9
+ --a1-sw-row-gap: var(--component-switch-row-gap); /* gap between track and label content */
10
+ --a1-sw-row-py: var(--component-switch-row-padding-block);
11
+ --a1-sw-row-px: var(--component-switch-row-padding-inline);
12
+ --a1-sw-content-gap: var(--component-switch-content-gap); /* gap between label text and hint */
13
+ --a1-sw-group-gap: var(--component-switch-group-gap); /* outer flex gap (for no-label hint/error) */
14
+ --a1-sw-label-size: var(--semantic-font-size-body-md);
15
+ --a1-sw-msg-size: var(--semantic-font-size-body-xs);
16
+
17
+ display: flex;
18
+ flex-direction: column;
19
+ gap: var(--a1-sw-group-gap);
20
+ }
21
+
22
+ /* ─── Sizes ───────────────────────────────────────────────────────────────── */
23
+
24
+ .a1-switch--comfortable {
25
+ --a1-sw-track-width: var(--component-switch-comfortable-track-width);
26
+ --a1-sw-track-height: var(--component-switch-comfortable-track-height);
27
+ --a1-sw-thumb: var(--component-switch-comfortable-thumb-size);
28
+ --a1-sw-gap: var(--component-switch-comfortable-gap);
29
+ --a1-sw-row-gap: var(--component-switch-comfortable-row-gap);
30
+ --a1-sw-row-py: var(--component-switch-comfortable-row-padding-block);
31
+ --a1-sw-row-px: var(--component-switch-comfortable-row-padding-inline);
32
+ --a1-sw-content-gap: var(--component-switch-comfortable-content-gap);
33
+ --a1-sw-group-gap: var(--component-switch-comfortable-group-gap);
34
+ --a1-sw-label-size: var(--semantic-font-size-body-md);
35
+ --a1-sw-msg-size: var(--semantic-font-size-body-sm);
36
+ }
37
+
38
+ .a1-switch--comfortable .a1-switch__label {
39
+ font-weight: var(--base-font-weight-bold);
40
+ }
41
+
42
+ @media (--bp-md-up) {
43
+ .a1-switch--comfortable {
44
+ --a1-sw-label-size: var(--semantic-font-size-body-lg);
45
+ }
46
+ }
47
+
48
+ .a1-switch--compact {
49
+ --a1-sw-track-width: var(--component-switch-compact-track-width);
50
+ --a1-sw-track-height: var(--component-switch-compact-track-height);
51
+ --a1-sw-thumb: var(--component-switch-compact-thumb-size);
52
+ --a1-sw-gap: var(--component-switch-compact-gap);
53
+ --a1-sw-row-gap: var(--component-switch-compact-row-gap);
54
+ --a1-sw-row-py: var(--component-switch-compact-row-padding-block);
55
+ --a1-sw-row-px: var(--component-switch-compact-row-padding-inline);
56
+ --a1-sw-content-gap: var(--component-switch-compact-content-gap);
57
+ --a1-sw-group-gap: var(--component-switch-compact-group-gap);
58
+ --a1-sw-label-size: var(--semantic-font-size-body-sm);
59
+ --a1-sw-msg-size: var(--semantic-font-size-body-xs);
60
+ }
61
+
62
+ /* ─── Input — sr-only ────────────────────────────────────────────────────────
63
+ Hidden from sighted users; the adjacent .a1-switch__track span provides all
64
+ visual affordance. Keyboard and screen-reader users interact with the input
65
+ directly. position:absolute removes it from flex flow without hiding it from
66
+ assistive technology.
67
+ ─────────────────────────────────────────────────────────────────────────── */
68
+
69
+ .a1-switch__input {
70
+ position: absolute;
71
+ width: 1px;
72
+ height: 1px;
73
+ padding: 0;
74
+ margin: -1px;
75
+ overflow: hidden;
76
+ clip: rect(0, 0, 0, 0);
77
+ white-space: nowrap;
78
+ border: 0;
79
+ }
80
+
81
+ /* ─── Label row ───────────────────────────────────────────────────────────── */
82
+
83
+ .a1-switch__row {
84
+ display: inline-flex;
85
+ align-items: center;
86
+ gap: var(--a1-sw-row-gap);
87
+ cursor: pointer;
88
+ padding: var(--a1-sw-row-py) var(--a1-sw-row-px);
89
+ margin-inline: calc(-1 * var(--a1-sw-row-px));
90
+ border-radius: var(--base-radius-md);
91
+ transition: background-color var(--semantic-motion-duration-fast);
92
+ }
93
+
94
+ .a1-switch--disabled .a1-switch__row {
95
+ cursor: not-allowed;
96
+ }
97
+
98
+ .a1-switch--label-start .a1-switch__row {
99
+ flex-direction: row-reverse;
100
+ }
101
+
102
+ /* ─── Hover — row background ─────────────────────────────────────────────── */
103
+
104
+ .a1-switch:not(.a1-switch--disabled) .a1-switch__row:hover {
105
+ background-color: var(--a1-field-hover-background);
106
+ }
107
+
108
+ /* ─── Active — checked state deepens the row ─────────────────────────────── */
109
+
110
+ .a1-switch:not(.a1-switch--disabled) .a1-switch__row:has(.a1-switch__track--on):active {
111
+ background-color: var(--a1-field-active-background);
112
+ }
113
+
114
+ /* ─── Label content block ─────────────────────────────────────────────────── */
115
+
116
+ .a1-switch__content {
117
+ display: flex;
118
+ flex-direction: column;
119
+ gap: var(--a1-sw-content-gap);
120
+ }
121
+
122
+ /* ─── Label text ──────────────────────────────────────────────────────────── */
123
+
124
+ .a1-switch__label {
125
+ font-family: var(--component-paragraph-font-family);
126
+ font-size: var(--a1-sw-label-size);
127
+ font-weight: var(--base-font-weight-regular);
128
+ color: var(--semantic-color-text-default);
129
+ line-height: var(--semantic-font-line-height-body);
130
+ user-select: none;
131
+ }
132
+
133
+ .a1-switch--disabled .a1-switch__label {
134
+ color: var(--semantic-color-text-muted);
135
+ }
136
+
137
+ /* ─── Track ───────────────────────────────────────────────────────────────────
138
+ box-sizing: content-box keeps the thumb travel formula correct:
139
+ travel = track-width − track-height
140
+ The 1px border adds to the outer visual size without affecting the content
141
+ area used for positioning ::before (the thumb).
142
+ ─────────────────────────────────────────────────────────────────────────── */
143
+
144
+ .a1-switch__track {
145
+ box-sizing: content-box;
146
+ display: block;
147
+ position: relative;
148
+ flex-shrink: 0;
149
+ width: var(--a1-sw-track-width);
150
+ height: var(--a1-sw-track-height);
151
+ border-radius: var(--a1-sw-track-height);
152
+ border: var(--component-field-border-width) solid var(--semantic-color-border-strong);
153
+ background-color: var(--semantic-color-surface-page);
154
+ cursor: pointer;
155
+ transition:
156
+ background-color var(--semantic-motion-duration-normal) var(--semantic-motion-easing-standard),
157
+ border-color var(--semantic-motion-duration-normal) var(--semantic-motion-easing-standard);
158
+ }
159
+
160
+ /* ─── Thumb ───────────────────────────────────────────────────────────────── */
161
+
162
+ .a1-switch__track::before {
163
+ content: "";
164
+ position: absolute;
165
+ top: var(--a1-sw-gap);
166
+ left: var(--a1-sw-gap);
167
+ width: var(--a1-sw-thumb);
168
+ height: var(--a1-sw-thumb);
169
+ border-radius: 50%;
170
+ background-color: var(--semantic-color-status-info-background);
171
+ box-shadow: var(--component-switch-thumb-shadow);
172
+ transform: translateX(0);
173
+ transition:
174
+ transform var(--semantic-motion-duration-normal) var(--semantic-motion-easing-standard),
175
+ background-color var(--semantic-motion-duration-normal) var(--semantic-motion-easing-standard);
176
+ }
177
+
178
+ /* ─── Hover — off-state border darkens ───────────────────────────────────── */
179
+
180
+ .a1-switch:not(.a1-switch--disabled) .a1-switch__row:hover
181
+ .a1-switch__track:not(.a1-switch__track--on) {
182
+ border-color: var(--a1-field-hover-border-color);
183
+ }
184
+
185
+ /* ─── Checked ─────────────────────────────────────────────────────────────── */
186
+
187
+ .a1-switch__track--on {
188
+ background-color: var(--semantic-color-status-info-background);
189
+ border-color: var(--semantic-color-status-info-background);
190
+ }
191
+
192
+ .a1-switch__track--on::before {
193
+ background-color: var(--base-color-neutral-0);
194
+ transform: translateX(calc(var(--a1-sw-track-width) - var(--a1-sw-track-height)));
195
+ }
196
+
197
+ /* ─── Focus ring on track ─────────────────────────────────────────────────── */
198
+
199
+ .a1-switch__input:focus-visible + .a1-switch__track {
200
+ outline: var(--component-field-focus-ring-width) solid var(--component-field-focus-ring-color);
201
+ outline-offset: var(--component-field-focus-ring-offset);
202
+ }
203
+
204
+ /* ─── Error ───────────────────────────────────────────────────────────────── */
205
+
206
+ .a1-switch--error:not(.a1-switch--disabled) .a1-switch__track:not(.a1-switch__track--on) {
207
+ border-color: var(--semantic-color-status-error-border);
208
+ }
209
+
210
+ /* ─── Disabled ────────────────────────────────────────────────────────────── */
211
+
212
+ .a1-switch__input:disabled + .a1-switch__track {
213
+ background-color: var(--semantic-color-surface-raised);
214
+ border-color: var(--semantic-color-border-subtle);
215
+ cursor: not-allowed;
216
+ }
217
+
218
+ .a1-switch__input:disabled + .a1-switch__track::before {
219
+ background-color: var(--semantic-color-border-default);
220
+ box-shadow: none;
221
+ }
222
+
223
+ .a1-switch__input:checked:disabled + .a1-switch__track {
224
+ background-color: var(--semantic-color-border-default);
225
+ border-color: var(--semantic-color-border-default);
226
+ }
227
+
228
+ .a1-switch__input:checked:disabled + .a1-switch__track::before {
229
+ background-color: var(--semantic-color-surface-raised);
230
+ }
231
+
232
+ /* ─── Hint / error messages ───────────────────────────────────────────────── */
233
+
234
+ .a1-switch__message {
235
+ margin: 0;
236
+ font-family: var(--component-paragraph-font-family);
237
+ font-size: var(--a1-sw-msg-size);
238
+ line-height: var(--semantic-font-line-height-body);
239
+ }
240
+
241
+ .a1-switch__message--hint { color: var(--semantic-color-text-muted); }
242
+ .a1-switch__message--error {
243
+ color: var(--semantic-color-status-error-background);
244
+ font-weight: var(--component-switch-message-error-font-weight);
245
+ }
246
+
247
+ /* ─── Accessible theme — on/off icon stamped onto the thumb ──────────────────
248
+ Off = "O" (open circle / power-off); On = "|" (vertical bar / power-on).
249
+ The ::after travels with the thumb using the same translateX transition.
250
+ ─────────────────────────────────────────────────────────────────────────── */
251
+
252
+ .a1-theme-accessible .a1-switch__track::after {
253
+ content: "O";
254
+ position: absolute;
255
+ top: var(--a1-sw-gap);
256
+ left: var(--a1-sw-gap);
257
+ width: var(--a1-sw-thumb);
258
+ height: var(--a1-sw-thumb);
259
+ border-radius: 50%;
260
+ color: var(--semantic-color-status-info-foreground);
261
+ font-family: var(--component-paragraph-font-family);
262
+ font-size: var(--component-switch-accessible-icon-size);
263
+ font-weight: var(--base-font-weight-bold);
264
+ line-height: 1;
265
+ display: flex;
266
+ align-items: center;
267
+ justify-content: center;
268
+ pointer-events: none;
269
+ transition: transform var(--semantic-motion-duration-normal) var(--semantic-motion-easing-standard);
270
+ }
271
+
272
+ .a1-theme-accessible .a1-switch__track--on::after {
273
+ content: "|";
274
+ transform: translateX(calc(var(--a1-sw-track-width) - var(--a1-sw-track-height)));
275
+ color: var(--semantic-color-status-info-background);
276
+ }
@@ -0,0 +1,57 @@
1
+ import "./system-banner.css";
2
+ import { Icon } from "../icon/Icon.jsx";
3
+ import { IconButton } from "../icon-button/IconButton.jsx";
4
+
5
+ const STATUS_ICONS = {
6
+ neutral: "campaign",
7
+ info: "info",
8
+ success: "check_circle",
9
+ warn: "warning",
10
+ error: "error",
11
+ };
12
+
13
+ const STATUSES = ["neutral", "info", "success", "warn", "error"];
14
+
15
+ export function SystemBanner({
16
+ status = "neutral",
17
+ title,
18
+ icon,
19
+ action,
20
+ onDismiss,
21
+ children,
22
+ }) {
23
+ const resolvedStatus = STATUSES.includes(status) ? status : "neutral";
24
+ const resolvedIcon = icon ?? STATUS_ICONS[resolvedStatus];
25
+
26
+ return (
27
+ <div
28
+ className={`a1-system-banner a1-system-banner--${resolvedStatus}`}
29
+ role="alert"
30
+ aria-live="polite"
31
+ >
32
+ <div className="a1-system-banner__inner">
33
+ <span className="a1-system-banner__icon" aria-hidden="true">
34
+ <Icon name={resolvedIcon} />
35
+ </span>
36
+
37
+ <div className="a1-system-banner__content">
38
+ {title && <span className="a1-system-banner__title">{title}</span>}
39
+ {children && <span className="a1-system-banner__body">{children}</span>}
40
+ </div>
41
+
42
+ {action && (
43
+ <div className="a1-system-banner__action">{action}</div>
44
+ )}
45
+
46
+ {onDismiss && (
47
+ <IconButton
48
+ icon="close"
49
+ label="Dismiss"
50
+ onClick={onDismiss}
51
+ className="a1-system-banner__dismiss"
52
+ />
53
+ )}
54
+ </div>
55
+ </div>
56
+ );
57
+ }