@recursica/mui-adapter 0.4.0 → 0.6.0

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 (177) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/mui-adapter.cjs +74 -1
  3. package/dist/mui-adapter.cjs.map +1 -1
  4. package/dist/mui-adapter.css +1 -1
  5. package/dist/mui-adapter.js +6651 -201
  6. package/dist/mui-adapter.js.map +1 -1
  7. package/dist/src/components/Accordion/Accordion.d.ts +63 -2
  8. package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
  9. package/dist/src/components/Autocomplete/Autocomplete.d.ts +17 -0
  10. package/dist/src/components/Autocomplete/index.d.ts +1 -0
  11. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  12. package/dist/src/components/Badge/Badge.d.ts +13 -3
  13. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  14. package/dist/src/components/Button/Button.d.ts +1 -1
  15. package/dist/src/components/Card/Card.d.ts +40 -3
  16. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  17. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  18. package/dist/src/components/Checkbox/index.d.ts +5 -1
  19. package/dist/src/components/Chip/Chip.d.ts +18 -2
  20. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  21. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  22. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  23. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  24. package/dist/src/components/Label/Label.d.ts +13 -2
  25. package/dist/src/components/Link/Link.d.ts +1 -1
  26. package/dist/src/components/Menu/Menu.d.ts +99 -3
  27. package/dist/src/components/Modal/Modal.d.ts +36 -2
  28. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  29. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  30. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  31. package/dist/src/components/Panel/Panel.d.ts +65 -3
  32. package/dist/src/components/Radio/Radio.d.ts +13 -3
  33. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  35. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  36. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  37. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  38. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  39. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  40. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  41. package/dist/src/components/Slider/Slider.d.ts +28 -2
  42. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  43. package/dist/src/components/Switch/Switch.d.ts +10 -3
  44. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  45. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  46. package/dist/src/components/Text/Text.d.ts +1 -1
  47. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  48. package/dist/src/components/TextField/TextField.d.ts +16 -2
  49. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  50. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  51. package/dist/src/components/Title/Title.d.ts +1 -1
  52. package/dist/src/components/Toast/Toast.d.ts +25 -2
  53. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  54. package/dist/src/components/Typography/Typography.d.ts +1 -1
  55. package/dist/src/components/index.d.ts +1 -0
  56. package/package.json +12 -2
  57. package/src/GlobalExemptions.modules.css +13 -0
  58. package/src/components/Accordion/Accordion.module.css +295 -0
  59. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  60. package/src/components/Accordion/Accordion.tsx +264 -4
  61. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -0
  62. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  63. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -4
  64. package/src/components/Autocomplete/Autocomplete.module.css +325 -0
  65. package/src/components/Autocomplete/Autocomplete.stories.tsx +196 -0
  66. package/src/components/Autocomplete/Autocomplete.tsx +201 -0
  67. package/src/components/Autocomplete/index.ts +1 -0
  68. package/src/components/Avatar/Avatar.module.css +344 -0
  69. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  70. package/src/components/Avatar/Avatar.tsx +110 -5
  71. package/src/components/Badge/Badge.module.css +127 -0
  72. package/src/components/Badge/Badge.stories.tsx +65 -22
  73. package/src/components/Badge/Badge.tsx +70 -5
  74. package/src/components/Breadcrumb/Breadcrumb.module.css +26 -0
  75. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  76. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -5
  77. package/src/components/Button/Button.module.css +113 -20
  78. package/src/components/Button/Button.stories.tsx +3 -0
  79. package/src/components/Button/Button.tsx +10 -3
  80. package/src/components/Card/Card.module.css +118 -0
  81. package/src/components/Card/Card.stories.tsx +117 -19
  82. package/src/components/Card/Card.tsx +179 -4
  83. package/src/components/Checkbox/Checkbox.module.css +232 -0
  84. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  85. package/src/components/Checkbox/Checkbox.tsx +146 -4
  86. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  87. package/src/components/Checkbox/index.ts +6 -1
  88. package/src/components/Chip/Chip.module.css +236 -0
  89. package/src/components/Chip/Chip.stories.tsx +101 -21
  90. package/src/components/Chip/Chip.tsx +138 -5
  91. package/src/components/DatePicker/DatePicker.module.css +42 -0
  92. package/src/components/DatePicker/DatePicker.tsx +1 -0
  93. package/src/components/Dropdown/Dropdown.module.css +296 -0
  94. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  95. package/src/components/Dropdown/Dropdown.tsx +182 -5
  96. package/src/components/FileInput/FileInput.module.css +47 -0
  97. package/src/components/FileInput/FileInput.tsx +1 -0
  98. package/src/components/FileUpload/FileUpload.module.css +40 -0
  99. package/src/components/FileUpload/FileUpload.tsx +1 -0
  100. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  101. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  102. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  103. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  104. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  105. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  106. package/src/components/HoverCard/HoverCard.module.css +91 -0
  107. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  108. package/src/components/HoverCard/HoverCard.tsx +150 -4
  109. package/src/components/Label/Label.module.css +136 -0
  110. package/src/components/Label/Label.stories.tsx +98 -17
  111. package/src/components/Label/Label.tsx +88 -4
  112. package/src/components/Link/Link.module.css +8 -0
  113. package/src/components/Menu/Menu.module.css +287 -0
  114. package/src/components/Menu/Menu.stories.tsx +307 -21
  115. package/src/components/Menu/Menu.tsx +318 -4
  116. package/src/components/Modal/Modal.module.css +172 -0
  117. package/src/components/Modal/Modal.stories.tsx +66 -22
  118. package/src/components/Modal/Modal.tsx +216 -3
  119. package/src/components/NumberInput/NumberInput.module.css +281 -0
  120. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  121. package/src/components/NumberInput/NumberInput.tsx +148 -5
  122. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  123. package/src/components/Pagination/Pagination.module.css +307 -0
  124. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  125. package/src/components/Pagination/Pagination.tsx +193 -4
  126. package/src/components/Panel/Panel.module.css +206 -0
  127. package/src/components/Panel/Panel.stories.tsx +214 -22
  128. package/src/components/Panel/Panel.tsx +153 -4
  129. package/src/components/Radio/Radio.module.css +220 -0
  130. package/src/components/Radio/Radio.stories.tsx +77 -19
  131. package/src/components/Radio/Radio.tsx +178 -4
  132. package/src/components/Radio/RadioGroup.tsx +111 -0
  133. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  134. package/src/components/ReadOnlyField/ReadOnlyField.module.css +54 -0
  135. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  136. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -4
  137. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  138. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  139. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  140. package/src/components/ReadOnlyField/index.ts +1 -0
  141. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -0
  142. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  143. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -5
  144. package/src/components/Slider/Slider.module.css +542 -0
  145. package/src/components/Slider/Slider.stories.tsx +157 -19
  146. package/src/components/Slider/Slider.tsx +282 -4
  147. package/src/components/Stepper/Stepper.module.css +410 -0
  148. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  149. package/src/components/Stepper/Stepper.tsx +145 -5
  150. package/src/components/Switch/Switch.module.css +238 -0
  151. package/src/components/Switch/Switch.stories.tsx +98 -19
  152. package/src/components/Switch/Switch.tsx +153 -5
  153. package/src/components/Switch/SwitchGroup.tsx +111 -0
  154. package/src/components/Tabs/Tabs.module.css +422 -0
  155. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  156. package/src/components/Tabs/Tabs.tsx +103 -5
  157. package/src/components/TextArea/TextArea.module.css +160 -0
  158. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  159. package/src/components/TextArea/TextArea.tsx +156 -5
  160. package/src/components/TextField/TextField.module.css +266 -0
  161. package/src/components/TextField/TextField.stories.tsx +168 -15
  162. package/src/components/TextField/TextField.tsx +171 -5
  163. package/src/components/TimePicker/TimePicker.module.css +41 -0
  164. package/src/components/TimePicker/TimePicker.tsx +1 -0
  165. package/src/components/Timeline/Timeline.module.css +367 -0
  166. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  167. package/src/components/Timeline/Timeline.tsx +80 -4
  168. package/src/components/Timeline/TimelineItem.tsx +101 -0
  169. package/src/components/Toast/Toast.module.css +170 -0
  170. package/src/components/Toast/Toast.stories.tsx +54 -22
  171. package/src/components/Toast/Toast.tsx +90 -4
  172. package/src/components/Tooltip/Tooltip.module.css +90 -0
  173. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  174. package/src/components/Tooltip/Tooltip.tsx +114 -4
  175. package/src/components/TransferList/TransferList.module.css +38 -0
  176. package/src/components/TransferList/TransferList.tsx +1 -0
  177. package/src/components/index.ts +1 -0
@@ -0,0 +1,201 @@
1
+ import React, { forwardRef } from "react";
2
+ import {
3
+ Autocomplete as MuiAutocomplete,
4
+ type AutocompleteProps as MuiAutocompleteProps,
5
+ TextField as MuiTextField,
6
+ type InputWrapperProps,
7
+ } from "@mui/material";
8
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
9
+ import {
10
+ filterStylingProps,
11
+ type RecursicaOverStyled,
12
+ } from "../../utils/filterStylingProps";
13
+ import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
14
+ import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
15
+ import styles from "./Autocomplete.module.css";
16
+
17
+ export interface RecursicaAutocompleteProps
18
+ extends Omit<
19
+ MuiAutocompleteProps<any, any, any, any>,
20
+ "size" | "variant" | "radius" | "wrapperProps" | "renderInput"
21
+ >,
22
+ Pick<
23
+ InputWrapperProps,
24
+ "label" | "error" | "required" | "withAsterisk" | "id"
25
+ >,
26
+ Omit<
27
+ RecursicaFormControlWrapperProps,
28
+ "controlMaxWidth" | "controlMinWidth"
29
+ >,
30
+ ReadOnlyControlProps {
31
+ data?: any[];
32
+ leftSection?: React.ReactNode;
33
+ rightSection?: React.ReactNode;
34
+ placeholder?: string;
35
+ }
36
+
37
+ export type AutocompleteProps = RecursicaOverStyled<RecursicaAutocompleteProps>;
38
+
39
+ export const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(
40
+ function Autocomplete(props, ref) {
41
+ const {
42
+ overStyled = false,
43
+ formLayout = "stacked",
44
+
45
+ // Label & Wrapper Maps
46
+ labelSize,
47
+ labelAlignment,
48
+ labelOptionalText,
49
+ labelWithEditIcon,
50
+ onLabelEditClick,
51
+
52
+ label,
53
+ assistiveText,
54
+ assistiveWithIcon,
55
+ error,
56
+ required,
57
+ withAsterisk,
58
+ id,
59
+ className,
60
+ style,
61
+ disabled,
62
+ readOnly,
63
+ readOnlyComponent,
64
+ emptyValueComponent,
65
+ value,
66
+ defaultValue,
67
+ data,
68
+ leftSection,
69
+ rightSection,
70
+ placeholder,
71
+ ListboxProps,
72
+ ...rest
73
+ } = props;
74
+ const sanitizedProps = filterStylingProps(rest, overStyled);
75
+ const restRecord = sanitizedProps as Record<string, unknown>;
76
+
77
+ // Delete prohibited sizing hooks from bypassing variables natively
78
+ delete restRecord["size"];
79
+ delete restRecord["variant"];
80
+ delete restRecord["radius"];
81
+
82
+ // Securely map core native blocks down ensuring nested CSS modules map precisely
83
+ const mergedClassNames: Partial<Record<string, string>> = {
84
+ root: styles.root,
85
+ inputRoot: styles.input, // Map Mantine .input (wrapper) to MUI's inputRoot
86
+ listbox: styles.dropdown, // Map Mantine .dropdown to MUI's listbox
87
+ option: styles.option,
88
+ };
89
+
90
+ const classNamesProp = restRecord.classNames;
91
+ if (
92
+ classNamesProp &&
93
+ typeof classNamesProp === "object" &&
94
+ !Array.isArray(classNamesProp)
95
+ ) {
96
+ const o = classNamesProp as Partial<Record<string, string>>;
97
+ mergedClassNames.root = o.wrapper
98
+ ? `${styles.root} ${o.wrapper}`
99
+ : styles.root;
100
+ mergedClassNames.inputRoot = o.input
101
+ ? `${styles.input} ${o.input}`
102
+ : styles.input;
103
+ mergedClassNames.listbox = o.dropdown
104
+ ? `${styles.dropdown} ${o.dropdown}`
105
+ : styles.dropdown;
106
+ mergedClassNames.option = o.option
107
+ ? `${styles.option} ${o.option}`
108
+ : styles.option;
109
+ }
110
+
111
+ const wrapperClass = className
112
+ ? `${styles.layoutOverride} ${className}`
113
+ : styles.layoutOverride;
114
+
115
+ const sectionClass =
116
+ classNamesProp && (classNamesProp as any).section
117
+ ? `${styles.section} ${(classNamesProp as any).section}`
118
+ : styles.section;
119
+
120
+ return (
121
+ <WithReadOnlyWrapper
122
+ className={wrapperClass}
123
+ style={style as React.CSSProperties}
124
+ controlMaxWidth="var(--recursica_ui-kit_components_autocomplete_properties_max-width)"
125
+ controlMinWidth="var(--recursica_ui-kit_components_autocomplete_properties_min-width)"
126
+ overStyled={overStyled as true}
127
+ formLayout={formLayout}
128
+ labelSize={labelSize}
129
+ labelAlignment={labelAlignment}
130
+ labelOptionalText={labelOptionalText}
131
+ labelWithEditIcon={labelWithEditIcon}
132
+ onLabelEditClick={onLabelEditClick}
133
+ label={label}
134
+ assistiveText={assistiveText}
135
+ assistiveWithIcon={assistiveWithIcon}
136
+ error={error}
137
+ required={required}
138
+ withAsterisk={withAsterisk}
139
+ id={id}
140
+ readOnly={readOnly}
141
+ readOnlyComponent={readOnlyComponent}
142
+ emptyValueComponent={emptyValueComponent}
143
+ readOnlyType="text"
144
+ readOnlyValue={value !== undefined ? value : defaultValue}
145
+ readOnlyNativeProps={props}
146
+ activeComponent={
147
+ /* Naked Input execution safely decoupled from Mui's macro Input.Wrapper DOM hooks */
148
+ <MuiAutocomplete
149
+ ref={ref}
150
+ classes={mergedClassNames}
151
+ disabled={disabled}
152
+ value={value}
153
+ defaultValue={defaultValue}
154
+ forcePopupIcon={false}
155
+ disableClearable={true}
156
+ ListboxProps={{
157
+ ...ListboxProps,
158
+ className: mergedClassNames.listbox,
159
+ }}
160
+ options={data || []}
161
+ renderInput={(params) => {
162
+ const { InputProps, ...restParams } = params;
163
+ return (
164
+ <MuiTextField
165
+ {...restParams}
166
+ placeholder={placeholder}
167
+ variant="standard"
168
+ InputProps={{
169
+ ...InputProps,
170
+ disableUnderline: true,
171
+ startAdornment: leftSection ? (
172
+ <span className={sectionClass}>{leftSection}</span>
173
+ ) : (
174
+ InputProps.startAdornment
175
+ ),
176
+ endAdornment: rightSection ? (
177
+ <>
178
+ {InputProps.endAdornment}
179
+ <span className={sectionClass}>{rightSection}</span>
180
+ </>
181
+ ) : (
182
+ InputProps.endAdornment
183
+ ),
184
+ }}
185
+ />
186
+ );
187
+ }}
188
+ {...(sanitizedProps as unknown as MuiAutocompleteProps<
189
+ any,
190
+ any,
191
+ any,
192
+ any
193
+ >)}
194
+ />
195
+ }
196
+ />
197
+ );
198
+ },
199
+ );
200
+
201
+ Autocomplete.displayName = "Autocomplete";
@@ -0,0 +1 @@
1
+ export * from "./Autocomplete";
@@ -0,0 +1,344 @@
1
+ /*
2
+ HARDCODED VALUES:
3
+ - justify-content, align-items, display: Center content for custom internal spans
4
+ - Mantine overrides (--avatar-bd, --avatar-bg, --avatar-color): Remove default static themes
5
+ - Default object-fit for image
6
+ - Transitions and standard flex layouts
7
+ - Image has no explicit size tokens other than root size, assume it scales 100%
8
+ */
9
+
10
+ /* EXEMPTIONS:
11
+ The generic size variables below are defined in Figma but unused.
12
+ We explicitly style the avatar's dimensions using the dedicated width and height tokens
13
+ (e.g., small_properties_width and small_properties_height) for precise component layout. */
14
+ /* recursica-ignore: --recursica_ui-kit_components_avatar_variants_sizes_default_properties_size */
15
+ /* recursica-ignore: --recursica_ui-kit_components_avatar_variants_sizes_large_properties_size */
16
+ /* recursica-ignore: --recursica_ui-kit_components_avatar_variants_sizes_small_properties_size */
17
+
18
+ .root {
19
+ box-sizing: border-box;
20
+ margin: 0;
21
+ border-style: solid;
22
+ overflow: hidden;
23
+ position: relative;
24
+ transition: all 0.2s ease;
25
+ box-shadow: var(--recursica_ui-kit_components_avatar_properties_elevation);
26
+
27
+ /* HARDCODE: Remove internal Mantine custom props that interfere */
28
+ --avatar-bd: none;
29
+ --avatar-bg: transparent;
30
+ --avatar-color: inherit;
31
+ }
32
+
33
+ /* ==== SIZES ==== */
34
+ .root[data-size="small"] {
35
+ width: var(
36
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_width
37
+ );
38
+ height: var(
39
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_height
40
+ );
41
+ border-width: var(
42
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_border-size
43
+ );
44
+ }
45
+
46
+ .root[data-size="small"] .iconWrapper {
47
+ width: var(
48
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_icon-size
49
+ );
50
+ height: var(
51
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_icon-size
52
+ );
53
+ }
54
+
55
+ .root[data-size="small"] .textWrapper {
56
+ font-family: var(
57
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_font-family
58
+ );
59
+ font-size: var(
60
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_font-size
61
+ );
62
+ font-style: var(
63
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_font-style
64
+ );
65
+ font-weight: var(
66
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_font-weight
67
+ );
68
+ letter-spacing: var(
69
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_letter-spacing
70
+ );
71
+ line-height: var(
72
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_line-height
73
+ );
74
+ text-decoration: var(
75
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_text-decoration
76
+ );
77
+ text-transform: var(
78
+ --recursica_ui-kit_components_avatar_variants_sizes_small_properties_text_text-transform
79
+ );
80
+ }
81
+
82
+ .root[data-size="default"] {
83
+ width: var(
84
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_width
85
+ );
86
+ height: var(
87
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_height
88
+ );
89
+ border-width: var(
90
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_border-size
91
+ );
92
+ }
93
+
94
+ .root[data-size="default"] .iconWrapper {
95
+ width: var(
96
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_icon-size
97
+ );
98
+ height: var(
99
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_icon-size
100
+ );
101
+ }
102
+
103
+ .root[data-size="default"] .textWrapper {
104
+ font-family: var(
105
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_font-family
106
+ );
107
+ font-size: var(
108
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_font-size
109
+ );
110
+ font-style: var(
111
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_font-style
112
+ );
113
+ font-weight: var(
114
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_font-weight
115
+ );
116
+ letter-spacing: var(
117
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_letter-spacing
118
+ );
119
+ line-height: var(
120
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_line-height
121
+ );
122
+ text-decoration: var(
123
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_text-decoration
124
+ );
125
+ text-transform: var(
126
+ --recursica_ui-kit_components_avatar_variants_sizes_default_properties_text_text-transform
127
+ );
128
+ }
129
+
130
+ .root[data-size="large"] {
131
+ width: var(
132
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_width
133
+ );
134
+ height: var(
135
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_height
136
+ );
137
+ border-width: var(
138
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_border-size
139
+ );
140
+ }
141
+
142
+ .root[data-size="large"] .iconWrapper {
143
+ width: var(
144
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_icon-size
145
+ );
146
+ height: var(
147
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_icon-size
148
+ );
149
+ }
150
+
151
+ .root[data-size="large"] .textWrapper {
152
+ font-family: var(
153
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_font-family
154
+ );
155
+ font-size: var(
156
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_font-size
157
+ );
158
+ font-style: var(
159
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_font-style
160
+ );
161
+ font-weight: var(
162
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_font-weight
163
+ );
164
+ letter-spacing: var(
165
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_letter-spacing
166
+ );
167
+ line-height: var(
168
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_line-height
169
+ );
170
+ text-decoration: var(
171
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_text-decoration
172
+ );
173
+ text-transform: var(
174
+ --recursica_ui-kit_components_avatar_variants_sizes_large_properties_text_text-transform
175
+ );
176
+ }
177
+
178
+ /* ==== STYLES & VARIANTS ==== */
179
+
180
+ /* 1. IMAGE */
181
+ .root[data-style="image"] {
182
+ border-radius: var(
183
+ --recursica_ui-kit_components_avatar_variants_styles_image_properties_border-radius
184
+ );
185
+ border-width: var(
186
+ --recursica_ui-kit_components_avatar_variants_styles_image_properties_border-size
187
+ );
188
+ padding: var(
189
+ --recursica_ui-kit_components_avatar_variants_styles_image_properties_padding
190
+ );
191
+
192
+ /* Image variant styles */
193
+ background-color: var(
194
+ --recursica_ui-kit_components_avatar_variants_styles_image_properties_colors_background
195
+ );
196
+ border-color: var(
197
+ --recursica_ui-kit_components_avatar_variants_styles_image_properties_colors_border-color
198
+ );
199
+ }
200
+
201
+ /* Base styles for Internal Nodes */
202
+ .image {
203
+ object-fit: cover;
204
+ width: 100%;
205
+ height: 100%;
206
+ }
207
+
208
+ .placeholder {
209
+ display: flex;
210
+ align-items: center;
211
+ justify-content: center;
212
+ width: 100%;
213
+ height: 100%;
214
+ color: inherit;
215
+ background-color: transparent;
216
+ }
217
+
218
+ .iconWrapper {
219
+ display: flex;
220
+ align-items: center;
221
+ justify-content: center;
222
+ flex-shrink: 0;
223
+ }
224
+ .iconWrapper > * {
225
+ width: 100%;
226
+ height: 100%;
227
+ object-fit: contain;
228
+ }
229
+
230
+ .textWrapper {
231
+ display: inline-flex;
232
+ align-items: center;
233
+ justify-content: center;
234
+ }
235
+
236
+ /* 2. ICON */
237
+ .root[data-style="icon"] {
238
+ border-radius: var(
239
+ --recursica_ui-kit_components_avatar_variants_styles_icon_properties_border-radius
240
+ );
241
+ padding: var(
242
+ --recursica_ui-kit_components_avatar_variants_styles_icon_properties_padding
243
+ );
244
+ }
245
+
246
+ .root[data-style="icon"][data-variant="solid"] {
247
+ border-width: var(
248
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_solid_properties_border-size
249
+ );
250
+ background-color: var(
251
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_solid_properties_colors_background
252
+ );
253
+ border-color: var(
254
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_solid_properties_colors_border-color
255
+ );
256
+ color: var(
257
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_solid_properties_colors_icon-color
258
+ );
259
+ }
260
+
261
+ .root[data-style="icon"][data-variant="outline"] {
262
+ border-width: var(
263
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_outline_properties_border-size
264
+ );
265
+ background-color: var(
266
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_outline_properties_colors_background
267
+ );
268
+ border-color: var(
269
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_outline_properties_colors_border-color
270
+ );
271
+ color: var(
272
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_outline_properties_colors_icon-color
273
+ );
274
+ }
275
+
276
+ .root[data-style="icon"][data-variant="ghost"] {
277
+ border-width: var(
278
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_ghost_properties_border-size
279
+ );
280
+ background-color: var(
281
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_ghost_properties_colors_background
282
+ );
283
+ border-color: var(
284
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_ghost_properties_colors_border-color
285
+ );
286
+ color: var(
287
+ --recursica_ui-kit_components_avatar_variants_styles_icon_variants_types_ghost_properties_colors_icon-color
288
+ );
289
+ }
290
+
291
+ /* 3. TEXT */
292
+ .root[data-style="text"] {
293
+ border-radius: var(
294
+ --recursica_ui-kit_components_avatar_variants_styles_text_properties_border-radius
295
+ );
296
+ padding: var(
297
+ --recursica_ui-kit_components_avatar_variants_styles_text_properties_padding
298
+ );
299
+ }
300
+
301
+ .root[data-style="text"][data-variant="solid"] {
302
+ border-width: var(
303
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_solid_properties_border-size
304
+ );
305
+ background-color: var(
306
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_solid_properties_colors_background
307
+ );
308
+ border-color: var(
309
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_solid_properties_colors_border-color
310
+ );
311
+ color: var(
312
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_solid_properties_colors_text-color
313
+ );
314
+ }
315
+
316
+ .root[data-style="text"][data-variant="outline"] {
317
+ border-width: var(
318
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_outline_properties_border-size
319
+ );
320
+ background-color: var(
321
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_outline_properties_colors_background
322
+ );
323
+ border-color: var(
324
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_outline_properties_colors_border-color
325
+ );
326
+ color: var(
327
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_outline_properties_colors_text-color
328
+ );
329
+ }
330
+
331
+ .root[data-style="text"][data-variant="ghost"] {
332
+ border-width: var(
333
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_ghost_properties_border-size
334
+ );
335
+ background-color: var(
336
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_ghost_properties_colors_background
337
+ );
338
+ border-color: var(
339
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_ghost_properties_colors_border-color
340
+ );
341
+ color: var(
342
+ --recursica_ui-kit_components_avatar_variants_styles_text_variants_types_ghost_properties_colors_text-color
343
+ );
344
+ }
@@ -1,35 +1,107 @@
1
+ import React from "react";
1
2
  import type { Meta, StoryObj } from "@storybook/react";
2
3
  import { Avatar } from "./Avatar";
3
- import { ComingSoon } from "@recursica/storybook-template";
4
+ import { Layer } from "@recursica/adapter-common";
4
5
 
5
- const meta: Meta<typeof Avatar> = {
6
- title: "UI-Kit/🚧 Avatar",
6
+ type AvatarStoryProps = React.ComponentProps<typeof Avatar>;
7
+
8
+ const meta: Meta<AvatarStoryProps> = {
9
+ title: "UI-Kit/Avatar",
7
10
  component: Avatar,
8
11
  tags: ["autodocs"],
9
- parameters: {
10
- controls: {
11
- include: [
12
- "layer",
13
- "withLayer",
14
- "children",
15
- "component",
16
- "variant",
17
- "size",
18
- "icon",
19
- "disabled",
20
- "href",
21
- "onClick",
22
- "onChange",
23
- "value",
24
- "checked",
25
- ],
12
+ argTypes: {
13
+ variant: {
14
+ control: "select",
15
+ options: ["solid", "outline", "ghost"],
16
+ description:
17
+ "The visual variant of the avatar (applies to icon/text styles)",
18
+ },
19
+ size: {
20
+ control: "radio",
21
+ options: ["default", "small", "large"],
22
+ description: "The size of the avatar",
23
+ },
24
+ src: {
25
+ control: "text",
26
+ description: "Image URL for the image style avatar",
27
+ },
28
+ icon: {
29
+ table: {
30
+ disable: true,
31
+ },
26
32
  },
27
33
  },
28
34
  };
29
35
 
30
36
  export default meta;
31
- type Story = StoryObj<typeof Avatar>;
37
+
38
+ type Story = StoryObj<AvatarStoryProps>;
32
39
 
33
40
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Avatar" />,
41
+ args: {
42
+ size: "default",
43
+ variant: "solid",
44
+ },
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
46
+ render: ({ withLayer, layer, ...args }: any) => {
47
+ return <Avatar {...args} />;
48
+ },
49
+ };
50
+
51
+ export const TextSolidDefault: Story = {
52
+ args: {
53
+ children: "JD",
54
+ variant: "solid",
55
+ size: "default",
56
+ },
57
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
58
+ render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
59
+ };
60
+
61
+ export const ImageLarge: Story = {
62
+ args: {
63
+ src: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=250&q=80",
64
+ size: "large",
65
+ },
66
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
67
+ render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
68
+ };
69
+
70
+ export const IconSmallGhost: Story = {
71
+ args: {
72
+ size: "small",
73
+ variant: "ghost",
74
+ icon: (
75
+ <svg
76
+ xmlns="http://www.w3.org/2000/svg"
77
+ width="16"
78
+ height="16"
79
+ viewBox="0 0 24 24"
80
+ fill="none"
81
+ stroke="currentColor"
82
+ strokeWidth="2"
83
+ strokeLinecap="round"
84
+ strokeLinejoin="round"
85
+ >
86
+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
87
+ <circle cx="12" cy="7" r="4"></circle>
88
+ </svg>
89
+ ),
90
+ },
91
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
92
+ render: ({ withLayer, layer, ...args }: any) => <Avatar {...args} />,
93
+ };
94
+
95
+ export const LayerOneOutline: Story = {
96
+ args: {
97
+ children: "L1",
98
+ variant: "outline",
99
+ size: "default",
100
+ },
101
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
102
+ render: ({ withLayer, layer, ...args }: any) => (
103
+ <Layer layer={1} style={{ padding: "24px", display: "inline-block" }}>
104
+ <Avatar {...args} />
105
+ </Layer>
106
+ ),
35
107
  };