@musecat/uikit 0.1.1

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 (180) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +51 -0
  3. package/index.ts +78 -0
  4. package/package.json +103 -0
  5. package/packages/Components/Box/Box.tsx +173 -0
  6. package/packages/Components/Box/Box.types.ts +48 -0
  7. package/packages/Components/Button/Button.tsx +275 -0
  8. package/packages/Components/Button/Button.types.ts +44 -0
  9. package/packages/Components/Card/Card.default.tsx +180 -0
  10. package/packages/Components/Card/Card.foldable.tsx +383 -0
  11. package/packages/Components/Card/Card.module.scss +23 -0
  12. package/packages/Components/Card/Card.tsx +8 -0
  13. package/packages/Components/Card/Card.types.ts +91 -0
  14. package/packages/Components/Card/Card.utils.ts +66 -0
  15. package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
  16. package/packages/Components/Checkbox/Checkbox.tsx +104 -0
  17. package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
  18. package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
  19. package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
  20. package/packages/Components/CodeBox/CodeBox.tsx +91 -0
  21. package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
  22. package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
  23. package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
  24. package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
  25. package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
  26. package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
  27. package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
  28. package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
  29. package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
  30. package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
  31. package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
  32. package/packages/Components/DatePicker/DatePicker.tsx +786 -0
  33. package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
  34. package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
  35. package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
  36. package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
  37. package/packages/Components/Divider/Divider.tsx +46 -0
  38. package/packages/Components/Divider/Divider.types.ts +12 -0
  39. package/packages/Components/Header/Header.module.scss +74 -0
  40. package/packages/Components/Header/Header.tsx +47 -0
  41. package/packages/Components/Header/Header.types.ts +8 -0
  42. package/packages/Components/Icon/Icon.group.tsx +122 -0
  43. package/packages/Components/Icon/Icon.group.types.ts +20 -0
  44. package/packages/Components/Icon/Icon.tsx +341 -0
  45. package/packages/Components/Icon/Icon.types.ts +59 -0
  46. package/packages/Components/Icon/SVG/data.tsx +232 -0
  47. package/packages/Components/Input/Input.module.scss +5 -0
  48. package/packages/Components/Input/Input.tsx +87 -0
  49. package/packages/Components/Input/Input.types.ts +14 -0
  50. package/packages/Components/Label/Label.module.scss +19 -0
  51. package/packages/Components/Label/Label.tsx +115 -0
  52. package/packages/Components/Label/Label.types.ts +28 -0
  53. package/packages/Components/Layout/Layout.docs.module.scss +42 -0
  54. package/packages/Components/Layout/Layout.docs.tsx +150 -0
  55. package/packages/Components/Layout/Layout.docs.types.ts +18 -0
  56. package/packages/Components/Layout/Layout.module.scss +91 -0
  57. package/packages/Components/Layout/Layout.tsx +306 -0
  58. package/packages/Components/Layout/Layout.types.ts +71 -0
  59. package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
  60. package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
  61. package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
  62. package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
  63. package/packages/Components/Nav/Nav.module.scss +137 -0
  64. package/packages/Components/Nav/Nav.tsx +304 -0
  65. package/packages/Components/Nav/Nav.types.ts +32 -0
  66. package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
  67. package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
  68. package/packages/Components/Pagination/Pagination.tsx +254 -0
  69. package/packages/Components/Pagination/Pagination.types.ts +18 -0
  70. package/packages/Components/Pill/Pill.tsx +127 -0
  71. package/packages/Components/Pill/Pill.types.ts +33 -0
  72. package/packages/Components/Profile/Profile.shared.ts +74 -0
  73. package/packages/Components/Profile/Profile.tsx +382 -0
  74. package/packages/Components/Profile/Profile.types.ts +55 -0
  75. package/packages/Components/Progress/Progress.module.scss +15 -0
  76. package/packages/Components/Progress/Progress.tsx +88 -0
  77. package/packages/Components/Progress/Progress.types.ts +22 -0
  78. package/packages/Components/Radio/Radio.module.scss +11 -0
  79. package/packages/Components/Radio/Radio.tsx +121 -0
  80. package/packages/Components/Radio/Radio.types.ts +20 -0
  81. package/packages/Components/Select/Select.keyboard.tsx +76 -0
  82. package/packages/Components/Select/Select.trigger.tsx +88 -0
  83. package/packages/Components/Select/Select.tsx +11 -0
  84. package/packages/Components/Select/Select.types.ts +38 -0
  85. package/packages/Components/Select/Select.utils.ts +84 -0
  86. package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
  87. package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
  88. package/packages/Components/Select/hooks/useSelectState.ts +314 -0
  89. package/packages/Components/Select/select.control.tsx +228 -0
  90. package/packages/Components/Select/select.inner.tsx +312 -0
  91. package/packages/Components/Skeleton/Skeleton.tsx +30 -0
  92. package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
  93. package/packages/Components/Spinner/Spinner.module.scss +78 -0
  94. package/packages/Components/Spinner/Spinner.tsx +125 -0
  95. package/packages/Components/Spinner/Spinner.types.ts +19 -0
  96. package/packages/Components/Text/Text.module.scss +7 -0
  97. package/packages/Components/Text/Text.tsx +49 -0
  98. package/packages/Components/Text/Text.types.ts +33 -0
  99. package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
  100. package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
  101. package/packages/Components/TimePicker/TimePicker.tsx +511 -0
  102. package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
  103. package/packages/Components/Timeline/Timeline.tsx +111 -0
  104. package/packages/Components/Timeline/Timeline.types.ts +23 -0
  105. package/packages/Components/Title/Title.tsx +305 -0
  106. package/packages/Components/Title/Title.types.ts +64 -0
  107. package/packages/Components/Toggle/Toggle.module.scss +32 -0
  108. package/packages/Components/Toggle/Toggle.tsx +272 -0
  109. package/packages/Components/Toggle/Toggle.types.ts +17 -0
  110. package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
  111. package/packages/Components/Tooltip/Tooltip.tsx +340 -0
  112. package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
  113. package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
  114. package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
  115. package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
  116. package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
  117. package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
  118. package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
  119. package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
  120. package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
  121. package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
  122. package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
  123. package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
  124. package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
  125. package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
  126. package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
  127. package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
  128. package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
  129. package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
  130. package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
  131. package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
  132. package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
  133. package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
  134. package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
  135. package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
  136. package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
  137. package/packages/Frameworks/Theme/Radius.types.ts +55 -0
  138. package/packages/Frameworks/Theme/Theme.types.ts +325 -0
  139. package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
  140. package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
  141. package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
  142. package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
  143. package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
  144. package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
  145. package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
  146. package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
  147. package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
  148. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
  149. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
  150. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
  151. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
  152. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
  153. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
  154. package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
  155. package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
  156. package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
  157. package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
  158. package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
  159. package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
  160. package/packages/Frameworks/View/View.module.scss +34 -0
  161. package/packages/Frameworks/View/View.tsx +200 -0
  162. package/packages/Frameworks/View/View.types.ts +36 -0
  163. package/packages/Frameworks/_shared/Padding.types.ts +52 -0
  164. package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
  165. package/packages/Frameworks/_shared/Wind.types.ts +17 -0
  166. package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
  167. package/packages/Frameworks/_shared/layer.constants.ts +8 -0
  168. package/packages/Frameworks/_shared/normalize.ts +39 -0
  169. package/packages/Frameworks/_shared/sizing.ts +55 -0
  170. package/packages/Frameworks/_shared/useControllableState.ts +29 -0
  171. package/packages/Styles/_animation.scss +42 -0
  172. package/packages/Styles/_color.scss +131 -0
  173. package/packages/Styles/_font.scss +30 -0
  174. package/packages/Styles/_icon.scss +782 -0
  175. package/packages/Styles/_importer.scss +9 -0
  176. package/packages/Styles/_system.scss +69 -0
  177. package/packages/Styles/_textstyle.scss +111 -0
  178. package/packages/Styles/_theme.scss +452 -0
  179. package/packages/Styles/_viewport-global.scss +99 -0
  180. package/packages/Styles/_viewport.scss +108 -0
@@ -0,0 +1,382 @@
1
+ "use client";
2
+
3
+ import Divider from "@/packages/Components/Divider/Divider";
4
+ import Icon from "@/packages/Components/Icon/Icon";
5
+ import { getProfileAvatarIconProps } from "@/packages/Components/Profile/Profile.shared";
6
+ import type {
7
+ ProfileProps,
8
+ ProfileRole,
9
+ ProfileSizeOptions,
10
+ } from "@/packages/Components/Profile/Profile.types";
11
+ import Text from "@/packages/Components/Text/Text";
12
+ import Pressable from "@/packages/Frameworks/Pressable/Pressable";
13
+ import View from "@/packages/Frameworks/View/View";
14
+
15
+ type ResolvedProfileSize = Required<
16
+ Pick<ProfileSizeOptions, "avatar" | "textType" | "badge" | "gap">
17
+ > &
18
+ Pick<ProfileSizeOptions, "textSize"> & {
19
+ fallbackPadding: number | string;
20
+ };
21
+
22
+ function resolveProfileSize(size?: ProfileSizeOptions): ResolvedProfileSize {
23
+ const avatar = size?.avatar ?? 20;
24
+
25
+ return {
26
+ avatar,
27
+ textType: size?.textType ?? "Subheadline",
28
+ textSize: size?.textSize,
29
+ badge: size?.badge ?? 16,
30
+ gap: size?.gap ?? 4,
31
+ fallbackPadding: size?.fallbackPadding ?? 6,
32
+ };
33
+ }
34
+
35
+ function ProfileCertifiedBadge({
36
+ certifiedAt,
37
+ role,
38
+ size,
39
+ }: {
40
+ certifiedAt?: string;
41
+ role?: ProfileRole;
42
+ size: number;
43
+ }) {
44
+ return (
45
+ <Icon
46
+ icon="iCheckCircle"
47
+ iconFill
48
+ size={size}
49
+ color={role?.color ?? (certifiedAt ? "Blue3" : undefined)}
50
+ />
51
+ );
52
+ }
53
+
54
+ function ProfileMetaList({
55
+ joinedAtText,
56
+ roles,
57
+ }: {
58
+ joinedAtText?: string;
59
+ roles?: ProfileRole[];
60
+ }) {
61
+ const items = [];
62
+ if (joinedAtText) {
63
+ items.push({
64
+ key: `joined-${joinedAtText}`,
65
+ icon: "iDateNote",
66
+ text: joinedAtText,
67
+ });
68
+ }
69
+
70
+ if (roles) {
71
+ for (const r of roles) {
72
+ items.push({
73
+ key: `role-${r.label}`,
74
+ icon: r.icon ?? "iCheckCircle",
75
+ iconFill: r.iconFill ?? true,
76
+ text: r.label,
77
+ color: r.color,
78
+ });
79
+ }
80
+ }
81
+
82
+ if (items.length === 0) return null;
83
+
84
+ return (
85
+ <View padding={[8, 12]}>
86
+ <View column gap={4}>
87
+ {items.map((item) => (
88
+ <View key={item.key} alignItems="center" gap={4}>
89
+ <Icon
90
+ icon={item.icon}
91
+ iconFill={item.iconFill}
92
+ color={item.color}
93
+ size={18}
94
+ />
95
+ <Text type="Caption1" verticalTrim>
96
+ {item.text}
97
+ </Text>
98
+ </View>
99
+ ))}
100
+ </View>
101
+ </View>
102
+ );
103
+ }
104
+
105
+ function ProfilePopoverReportButton({
106
+ href,
107
+ onClick,
108
+ reportLabel,
109
+ }: {
110
+ href?: string;
111
+ onClick?: () => void;
112
+ reportLabel?: string;
113
+ }) {
114
+ const label = reportLabel || "Report";
115
+
116
+ return (
117
+ <Icon
118
+ icon="iWarning"
119
+ box
120
+ size={20}
121
+ boxOptions={{ padding: 4 }}
122
+ themePreset="RedSoft"
123
+ pressable={{
124
+ title: label,
125
+ "aria-label": label,
126
+ href,
127
+ onClick,
128
+ }}
129
+ />
130
+ );
131
+ }
132
+
133
+ function ProfileInlineContent({
134
+ size,
135
+ displayName,
136
+ username,
137
+ extended,
138
+ isCertified,
139
+ certifiedAt,
140
+ primaryRole,
141
+ avatarIconProps,
142
+ }: {
143
+ size: ResolvedProfileSize;
144
+ displayName: string;
145
+ username?: string;
146
+ extended?: boolean;
147
+ isCertified?: boolean;
148
+ certifiedAt?: string;
149
+ primaryRole?: ProfileRole;
150
+ avatarIconProps: ReturnType<typeof getProfileAvatarIconProps>;
151
+ }) {
152
+ return (
153
+ <View alignItems="center" gap={size.gap}>
154
+ <Icon {...avatarIconProps} />
155
+ <View gap={4} alignItems="center">
156
+ <View gap={4} alignItems="center">
157
+ <Text
158
+ type={size.textType}
159
+ size={size.textSize}
160
+ verticalTrim
161
+ style={{
162
+ whiteSpace: "nowrap",
163
+ }}
164
+ >
165
+ {displayName}
166
+ </Text>
167
+ {isCertified || primaryRole ? (
168
+ <ProfileCertifiedBadge
169
+ certifiedAt={certifiedAt}
170
+ role={primaryRole}
171
+ size={size.badge}
172
+ />
173
+ ) : null}
174
+ </View>
175
+ {extended && username ? (
176
+ <Text type="Caption1" verticalTrim opacity={0.6}>
177
+ @{username}
178
+ </Text>
179
+ ) : null}
180
+ </View>
181
+ </View>
182
+ );
183
+ }
184
+
185
+ function ProfilePopoverContent({
186
+ profileHref,
187
+ displayName,
188
+ displayUsername,
189
+ displayBio,
190
+ hasAvatar,
191
+ popoverAvatarIconProps,
192
+ isCertified,
193
+ certifiedAt,
194
+ primaryRole,
195
+ canReport,
196
+ reportHref,
197
+ reportLabel,
198
+ onReport,
199
+ joinedAtText,
200
+ roles,
201
+ "data-color-mode": dataColorMode,
202
+ }: {
203
+ profileHref?: string | null;
204
+ displayName: string;
205
+ displayUsername?: string;
206
+ displayBio?: string;
207
+ hasAvatar: boolean;
208
+ popoverAvatarIconProps: ReturnType<typeof getProfileAvatarIconProps>;
209
+ isCertified?: boolean;
210
+ certifiedAt?: string;
211
+ primaryRole?: ProfileRole;
212
+ canReport?: boolean;
213
+ reportHref?: string | null;
214
+ reportLabel?: string;
215
+ onReport?: () => void;
216
+ joinedAtText?: string;
217
+ roles?: ProfileRole[];
218
+ "data-color-mode"?: string;
219
+ }) {
220
+ const hasHeaderContent = Boolean(
221
+ displayName || displayUsername || displayBio || hasAvatar,
222
+ );
223
+
224
+ return (
225
+ <View fullWidth column gap={0} data-color-mode={dataColorMode}>
226
+ {hasHeaderContent ? (
227
+ <View fullWidth style={{ position: "relative" }}>
228
+ <Pressable
229
+ radius="regular"
230
+ fullWidth
231
+ column
232
+ gap={12}
233
+ padding={[8, 12]}
234
+ style={{ minWidth: 0, transition: "var(--transition-surface)" }}
235
+ href={profileHref || undefined}
236
+ data-color-mode={dataColorMode}
237
+ >
238
+ <Icon {...popoverAvatarIconProps} />
239
+ <View gap={12} column>
240
+ <View gap={6} column>
241
+ <View gap={6} alignItems="center">
242
+ <Text type="Title1" weight={600} verticalTrim>
243
+ {displayName}
244
+ </Text>
245
+ {isCertified || primaryRole ? (
246
+ <ProfileCertifiedBadge
247
+ certifiedAt={certifiedAt}
248
+ role={primaryRole}
249
+ size={22}
250
+ />
251
+ ) : null}
252
+ </View>
253
+ {displayUsername ? (
254
+ <Text type="Subheadline" verticalTrim opacity={0.6}>
255
+ @{displayUsername}
256
+ </Text>
257
+ ) : null}
258
+ </View>
259
+ {displayBio ? (
260
+ <Text type="Footnote" opacity={0.6}>
261
+ {displayBio}
262
+ </Text>
263
+ ) : null}
264
+ </View>
265
+ </Pressable>
266
+ {canReport ? (
267
+ <View
268
+ style={{
269
+ position: "absolute",
270
+ top: ".4rem",
271
+ right: ".4rem",
272
+ zIndex: 2,
273
+ }}
274
+ >
275
+ <ProfilePopoverReportButton
276
+ href={reportHref || undefined}
277
+ onClick={onReport}
278
+ reportLabel={reportLabel}
279
+ />
280
+ </View>
281
+ ) : null}
282
+ </View>
283
+ ) : null}
284
+ <Divider />
285
+ <ProfileMetaList joinedAtText={joinedAtText} roles={roles} />
286
+ </View>
287
+ );
288
+ }
289
+
290
+ export default function Profile({
291
+ id,
292
+ displayName,
293
+ username,
294
+ avatarUrl,
295
+ avatarLoading,
296
+ bio,
297
+ isCertified,
298
+ certifiedAt,
299
+ roles,
300
+ joinedAtText,
301
+ profileHref,
302
+ canReport,
303
+ reportHref,
304
+ reportLabel,
305
+ onReport,
306
+ extended,
307
+ size,
308
+ popover,
309
+ "data-color-mode": dataColorMode,
310
+ }: ProfileProps) {
311
+ const resolvedSize = resolveProfileSize(size);
312
+ const primaryRole = roles?.[0];
313
+
314
+ const avatarIconProps = getProfileAvatarIconProps({
315
+ avatar: avatarUrl,
316
+ avatarLoading,
317
+ size: resolvedSize.avatar,
318
+ fallbackPadding: resolvedSize.fallbackPadding,
319
+ });
320
+
321
+ const popoverAvatarIconProps = getProfileAvatarIconProps({
322
+ avatar: avatarUrl,
323
+ avatarLoading,
324
+ size: 64,
325
+ fallbackPadding: 12,
326
+ });
327
+
328
+ const resolvedPopover = popover
329
+ ? {
330
+ escapeExit: true,
331
+ minWidth: "24rem",
332
+ "data-color-mode": dataColorMode,
333
+ content: popover,
334
+ }
335
+ : profileHref
336
+ ? {
337
+ escapeExit: true,
338
+ minWidth: "24rem",
339
+ "data-color-mode": dataColorMode,
340
+ content: (
341
+ <ProfilePopoverContent
342
+ profileHref={profileHref}
343
+ displayName={displayName}
344
+ displayUsername={username}
345
+ displayBio={bio}
346
+ hasAvatar={Boolean(avatarUrl?.trim())}
347
+ popoverAvatarIconProps={popoverAvatarIconProps}
348
+ isCertified={isCertified}
349
+ certifiedAt={certifiedAt}
350
+ primaryRole={primaryRole}
351
+ canReport={canReport}
352
+ reportHref={reportHref}
353
+ reportLabel={reportLabel}
354
+ onReport={onReport}
355
+ joinedAtText={joinedAtText}
356
+ roles={roles}
357
+ data-color-mode={dataColorMode}
358
+ />
359
+ ),
360
+ }
361
+ : undefined;
362
+
363
+ return (
364
+ <Pressable
365
+ padding={[4, 6]}
366
+ style={{ transition: "var(--transition-surface)", margin: "-4px -6px" }}
367
+ data-color-mode={dataColorMode}
368
+ popover={resolvedPopover}
369
+ >
370
+ <ProfileInlineContent
371
+ size={resolvedSize}
372
+ displayName={displayName}
373
+ username={username}
374
+ extended={extended}
375
+ isCertified={isCertified}
376
+ certifiedAt={certifiedAt}
377
+ primaryRole={primaryRole}
378
+ avatarIconProps={avatarIconProps}
379
+ />
380
+ </Pressable>
381
+ );
382
+ }
@@ -0,0 +1,55 @@
1
+ import type { IconProps } from "@/packages/Components/Icon/Icon.types";
2
+ import type { TextProps } from "@/packages/Components/Text/Text.types";
3
+ import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
4
+ import type { ThemePaint } from "@/packages/Frameworks/Theme/Theme.types";
5
+
6
+ export type ProfileAvatarLoading = "eager" | "lazy";
7
+
8
+ export type ProfileRole = {
9
+ label: string;
10
+ color?: ThemePaint;
11
+ icon?: string;
12
+ iconFill?: boolean;
13
+ };
14
+
15
+ export interface ProfileAvatarOptions {
16
+ avatar?: string | null;
17
+ avatarLoading?: ProfileAvatarLoading;
18
+ size: number;
19
+ imageWidth?: UIKitSizeValue;
20
+ imageHeight?: UIKitSizeValue;
21
+ fallbackPadding?: UIKitSizeValue;
22
+ border?: IconProps["border"];
23
+ background?: IconProps["background"];
24
+ }
25
+
26
+ export type ProfileSizeOptions = {
27
+ avatar?: number;
28
+ textType?: TextProps["type"];
29
+ textSize?: UIKitSizeValue;
30
+ badge?: number;
31
+ gap?: UIKitSizeValue;
32
+ fallbackPadding?: UIKitSizeValue;
33
+ };
34
+
35
+ export interface ProfileProps {
36
+ "data-color-mode"?: string;
37
+ id?: string;
38
+ displayName: string;
39
+ username?: string;
40
+ avatarUrl?: string | null;
41
+ avatarLoading?: ProfileAvatarLoading;
42
+ bio?: string;
43
+ isCertified?: boolean;
44
+ certifiedAt?: string;
45
+ roles?: ProfileRole[];
46
+ joinedAtText?: string;
47
+ profileHref?: string | null;
48
+ canReport?: boolean;
49
+ reportHref?: string | null;
50
+ reportLabel?: string;
51
+ onReport?: () => void;
52
+ extended?: boolean;
53
+ size?: ProfileSizeOptions;
54
+ popover?: React.ReactNode;
55
+ }
@@ -0,0 +1,15 @@
1
+ .Indicator {
2
+ position: absolute;
3
+ inset: 0 auto 0 0;
4
+ width: var(--progress-percent, 0%);
5
+ min-width: 0;
6
+ height: 100%;
7
+ background: currentcolor;
8
+ transition: width 140ms linear;
9
+ }
10
+
11
+ @media (prefers-reduced-motion: reduce) {
12
+ .Indicator {
13
+ transition: none;
14
+ }
15
+ }
@@ -0,0 +1,88 @@
1
+ import clsx from "clsx";
2
+ import type { CSSProperties } from "react";
3
+ import styles from "@/packages/Components/Progress/Progress.module.scss";
4
+ import type { ProgressProps } from "@/packages/Components/Progress/Progress.types";
5
+ import Spinner from "@/packages/Components/Spinner/Spinner";
6
+ import { resolveThemeClasses } from "@/packages/Frameworks/Theme/Theme.types";
7
+ import View from "@/packages/Frameworks/View/View";
8
+
9
+ function clampValue(value: number, min: number, max: number) {
10
+ return Math.max(min, Math.min(max, value));
11
+ }
12
+
13
+ function resolveProgressPercent(value: number, min: number, max: number) {
14
+ if (max <= min) return 0;
15
+ return ((clampValue(value, min, max) - min) / (max - min)) * 100;
16
+ }
17
+
18
+ export default function Progress({
19
+ value = 0,
20
+ min = 0,
21
+ max = 100,
22
+ indeterminate,
23
+ className,
24
+ style,
25
+ "data-color-mode": dataTheme,
26
+ "aria-hidden": ariaHidden,
27
+ "aria-label": ariaLabel,
28
+ background,
29
+ color,
30
+ trackClassName,
31
+ indicatorClassName,
32
+ radius,
33
+ }: ProgressProps) {
34
+ if (indeterminate) {
35
+ return (
36
+ <Spinner
37
+ data-color-mode={dataTheme}
38
+ aria-hidden={ariaHidden}
39
+ aria-label={ariaLabel}
40
+ className={className}
41
+ style={style}
42
+ />
43
+ );
44
+ } else {
45
+ const resolvedValue = clampValue(value, min, max);
46
+ const resolvedPercent = resolveProgressPercent(resolvedValue, min, max);
47
+ const trackStyle = {
48
+ "--progress-percent": `${resolvedPercent}%`,
49
+ } as CSSProperties;
50
+ const trackThemeClasses = resolveThemeClasses({
51
+ background: background ?? "Base6TP6",
52
+ });
53
+ const indicatorThemeClasses = resolveThemeClasses({
54
+ color: color ?? "Base1",
55
+ });
56
+
57
+ return (
58
+ <View
59
+ data-color-mode={dataTheme}
60
+ role="progressbar"
61
+ aria-valuemin={min}
62
+ aria-valuemax={max}
63
+ aria-valuenow={resolvedValue}
64
+ className={className}
65
+ style={style}
66
+ radius={radius ?? "Circle"}
67
+ fullWidth
68
+ >
69
+ <View
70
+ className={clsx(...trackThemeClasses, trackClassName)}
71
+ style={{ position: "relative", overflow: "hidden", ...trackStyle }}
72
+ radius={radius ?? "Circle"}
73
+ height={10}
74
+ fullWidth
75
+ >
76
+ <View
77
+ className={clsx(
78
+ styles.Indicator,
79
+ ...indicatorThemeClasses,
80
+ indicatorClassName,
81
+ )}
82
+ radius={radius ?? "Circle"}
83
+ />
84
+ </View>
85
+ </View>
86
+ );
87
+ }
88
+ }
@@ -0,0 +1,22 @@
1
+ import type { CSSProperties } from "react";
2
+ import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
3
+ import type {
4
+ ThemeBackgroundPaint,
5
+ ThemePaint,
6
+ } from "@/packages/Frameworks/Theme/Theme.types";
7
+
8
+ export interface ProgressProps extends RadiusProps {
9
+ "data-color-mode"?: string;
10
+ "aria-hidden"?: boolean;
11
+ "aria-label"?: string;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ value?: number;
15
+ min?: number;
16
+ max?: number;
17
+ indeterminate?: boolean;
18
+ background?: ThemeBackgroundPaint;
19
+ color?: ThemePaint;
20
+ trackClassName?: string;
21
+ indicatorClassName?: string;
22
+ }
@@ -0,0 +1,11 @@
1
+ .RadioWrapper {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 0.8rem;
5
+ width: max-content;
6
+ background: transparent;
7
+
8
+ .Input {
9
+ display: none;
10
+ }
11
+ }
@@ -0,0 +1,121 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef, useState } from "react";
4
+ import styles from "@/packages/Components/Radio/Radio.module.scss";
5
+ import type { RadioProps } from "@/packages/Components/Radio/Radio.types";
6
+ import Text from "@/packages/Components/Text/Text";
7
+ import { Size } from "@/packages/Frameworks/_shared/sizing";
8
+ import View from "@/packages/Frameworks/View/View";
9
+
10
+ export default function Radio({
11
+ title,
12
+ titleType,
13
+ titleSpaceBetween,
14
+ reversed,
15
+ readOnly,
16
+ border,
17
+ themePreset,
18
+ background,
19
+ color,
20
+ themeInteractive,
21
+ selected,
22
+ radius,
23
+ size,
24
+ ...props
25
+ }: RadioProps) {
26
+ const isControlled = props.checked !== undefined;
27
+ const [internalChecked, setInternalChecked] = useState(
28
+ Boolean(props.defaultChecked),
29
+ );
30
+ const isChecked = isControlled ? Boolean(props.checked) : internalChecked;
31
+ const isInteractive = themeInteractive ?? (!readOnly && !props.disabled);
32
+ const inputRef = useRef<HTMLInputElement>(null);
33
+
34
+ useEffect(() => {
35
+ if (!isControlled) return;
36
+ setInternalChecked(Boolean(props.checked));
37
+ }, [isControlled, props.checked]);
38
+
39
+ useEffect(() => {
40
+ const radioGroup = props.name
41
+ ? document.querySelectorAll(`input[type="radio"][name="${props.name}"]`)
42
+ : null;
43
+ if (!radioGroup) return;
44
+
45
+ const handleChange = (e: Event) => {
46
+ const target = e.target as HTMLInputElement;
47
+ if (target !== inputRef.current && target.checked) {
48
+ setInternalChecked(target.value === props.value);
49
+ }
50
+ };
51
+
52
+ radioGroup.forEach((radio) => {
53
+ radio.addEventListener("change", handleChange);
54
+ });
55
+
56
+ return () => {
57
+ radioGroup.forEach((radio) => {
58
+ radio.removeEventListener("change", handleChange);
59
+ });
60
+ };
61
+ }, [props.name, props.value]);
62
+
63
+ return (
64
+ <label
65
+ className={styles.RadioWrapper}
66
+ title={title}
67
+ style={{
68
+ gap: size ? `calc(${Size(size)} / 3)` : ".8rem",
69
+ justifyContent: titleSpaceBetween ? "space-between" : undefined,
70
+ width: titleSpaceBetween ? "100%" : undefined,
71
+ }}
72
+ >
73
+ <input
74
+ ref={inputRef}
75
+ type="radio"
76
+ readOnly={readOnly}
77
+ className={styles.Input}
78
+ aria-checked={isChecked}
79
+ {...props}
80
+ checked={isControlled ? props.checked : undefined}
81
+ defaultChecked={isControlled ? undefined : props.defaultChecked}
82
+ onChange={(event) => {
83
+ if (!isControlled) {
84
+ setInternalChecked(event.currentTarget.checked);
85
+ }
86
+ props.onChange?.(event);
87
+ }}
88
+ />
89
+ <View
90
+ alignItems="center"
91
+ justifyContent="center"
92
+ border={border}
93
+ themePreset={
94
+ themePreset ?? (isChecked ? "ReversedUISecondary" : "UIPrimary")
95
+ }
96
+ background={background}
97
+ color={color}
98
+ themeInteractive={isInteractive}
99
+ selected={selected}
100
+ radius={radius ?? "Circle"}
101
+ width={size ?? 24}
102
+ height={size ?? 24}
103
+ data-disabled={props.disabled ? "true" : undefined}
104
+ data-readonly={readOnly ? "true" : undefined}
105
+ style={{
106
+ position: "relative",
107
+ order: reversed ? 1 : undefined,
108
+ }}
109
+ >
110
+ <View
111
+ themePreset="UIPrimary"
112
+ opacity={isChecked ? 1 : 0}
113
+ radius={radius ?? "Circle"}
114
+ width={typeof size === "number" ? size * 0.33 : ".8rem"}
115
+ height={typeof size === "number" ? size * 0.33 : ".8rem"}
116
+ />
117
+ </View>
118
+ {title && <Text type={titleType ?? "Subheadline"}>{title}</Text>}
119
+ </label>
120
+ );
121
+ }