oneslash-design-system 2.22.0 → 2.23.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.
- package/README.md +1 -1
- package/dist/DESIGN.md +12 -1
- package/dist/cases/admin-inbox/split.jsx +22 -10
- package/dist/cases/admin-inbox.md +28 -23
- package/dist/cases/api-keys.md +1 -1
- package/dist/cases/breadcrumb/back-link.d.ts +1 -0
- package/dist/cases/breadcrumb/back-link.jsx +23 -0
- package/dist/cases/breadcrumb/trail.d.ts +1 -0
- package/dist/cases/breadcrumb/trail.jsx +28 -0
- package/dist/cases/breadcrumb.md +105 -0
- package/dist/cases/date-field/calendar.d.ts +1 -0
- package/dist/cases/date-field/calendar.jsx +80 -0
- package/dist/cases/date-field/typed.d.ts +1 -0
- package/dist/cases/date-field/typed.jsx +58 -0
- package/dist/cases/date-field.md +232 -0
- package/dist/cases/docs-component-page/reference.jsx +11 -1
- package/dist/cases/docs-component-page.md +19 -8
- package/dist/cases/file-upload/files.d.ts +1 -0
- package/dist/cases/file-upload/files.jsx +118 -0
- package/dist/cases/file-upload/picture.d.ts +1 -0
- package/dist/cases/file-upload/picture.jsx +50 -0
- package/dist/cases/file-upload.md +270 -0
- package/dist/cases/filter-menu.md +1 -1
- package/dist/cases/image-viewer/with-video.d.ts +1 -0
- package/dist/cases/image-viewer/with-video.jsx +42 -0
- package/dist/cases/image-viewer.md +72 -4
- package/dist/cases/master-detail/split.jsx +17 -10
- package/dist/cases/master-detail.md +26 -24
- package/dist/cases/message-reactions/picker.d.ts +1 -0
- package/dist/cases/message-reactions/picker.jsx +145 -0
- package/dist/cases/message-reactions/quick-pick.jsx +1 -1
- package/dist/cases/message-reactions.md +184 -3
- package/dist/cases/page-header.md +1 -1
- package/dist/cases/people-row/names.d.ts +1 -0
- package/dist/cases/people-row/names.jsx +20 -0
- package/dist/cases/people-row/stack.d.ts +1 -0
- package/dist/cases/people-row/stack.jsx +33 -0
- package/dist/cases/people-row.md +110 -0
- package/dist/cases/profile-form/form.jsx +21 -10
- package/dist/cases/profile-form.md +38 -9
- package/dist/cases.json +306 -25
- package/dist/components/avatarStack.d.ts +22 -0
- package/dist/components/avatarStack.jsx +32 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.jsx +24 -0
- package/dist/components/calendar.d.ts +19 -0
- package/dist/components/calendar.jsx +126 -0
- package/dist/components/dateField.d.ts +35 -0
- package/dist/components/dateField.jsx +76 -0
- package/dist/components/dropZone.d.ts +53 -0
- package/dist/components/dropZone.jsx +136 -0
- package/dist/components/emojiPicker.d.ts +22 -0
- package/dist/components/emojiPicker.jsx +161 -0
- package/dist/components/itemList.d.ts +31 -0
- package/dist/components/itemList.jsx +81 -0
- package/dist/components/lightbox.d.ts +33 -9
- package/dist/components/lightbox.jsx +58 -27
- package/dist/components/menuItem.d.ts +1 -1
- package/dist/components/menuItem.jsx +3 -3
- package/dist/internal/date.d.ts +35 -0
- package/dist/internal/date.js +122 -0
- package/dist/internal/dropZone.d.ts +28 -0
- package/dist/internal/dropZone.js +42 -0
- package/dist/internal/emoji.d.ts +13 -0
- package/dist/internal/emoji.js +182 -0
- package/dist/internal/overlayStack.js +1 -1
- package/dist/internal/people.d.ts +1 -0
- package/dist/internal/people.js +12 -0
- package/dist/native-mapping.json +45 -3
- package/dist/stories/AvatarStack.stories.d.ts +7 -0
- package/dist/stories/AvatarStack.stories.jsx +46 -0
- package/dist/stories/Breadcrumb.stories.d.ts +7 -0
- package/dist/stories/Breadcrumb.stories.jsx +26 -0
- package/dist/stories/Calendar.stories.d.ts +6 -0
- package/dist/stories/Calendar.stories.jsx +15 -0
- package/dist/stories/Cases.generated.stories.d.ts +10 -0
- package/dist/stories/Cases.generated.stories.jsx +20 -0
- package/dist/stories/DateField.stories.d.ts +10 -0
- package/dist/stories/DateField.stories.jsx +132 -0
- package/dist/stories/DropZone.stories.d.ts +12 -0
- package/dist/stories/DropZone.stories.jsx +151 -0
- package/dist/stories/EmojiPicker.stories.d.ts +6 -0
- package/dist/stories/EmojiPicker.stories.jsx +92 -0
- package/dist/stories/ItemList.stories.d.ts +9 -0
- package/dist/stories/ItemList.stories.jsx +86 -0
- package/dist/stories/Lightbox.stories.d.ts +4 -0
- package/dist/stories/Lightbox.stories.jsx +44 -0
- package/package.json +3 -2
|
@@ -17,6 +17,7 @@ A person changes how they appear and how they sign in: their picture, their name
|
|
|
17
17
|
- Show a problem with a field under it, as the rule 'A form error shows next to the problem' says: 'Enter your name.' and 'Use at least 8 characters.'
|
|
18
18
|
- Disable the field while its request runs, and keep what the person typed when the save fails.
|
|
19
19
|
- Use `UserImage` with the person's name as `userHandle`, so a person with no picture sees their initial.
|
|
20
|
+
- Follow the case 'File upload' for the picture.
|
|
20
21
|
|
|
21
22
|
## Don't
|
|
22
23
|
|
|
@@ -28,7 +29,7 @@ A person changes how they appear and how they sign in: their picture, their name
|
|
|
28
29
|
|
|
29
30
|
## Example: Picture, name and password
|
|
30
31
|
|
|
31
|
-
Uses: `
|
|
32
|
+
Uses: `Button`, `Center`, `Cluster`, `DropZone`, `Form`, `FormField`, `Heading`, `SettingsSection`, `Stack`, `TextField`, `UserImage`, `formatBytes`
|
|
32
33
|
|
|
33
34
|
```tsx
|
|
34
35
|
'use client';
|
|
@@ -38,8 +39,9 @@ import Form from 'oneslash-design-system/components/form';
|
|
|
38
39
|
import FormField from 'oneslash-design-system/components/formField';
|
|
39
40
|
import TextField from 'oneslash-design-system/components/textField';
|
|
40
41
|
import Button from 'oneslash-design-system/components/button';
|
|
41
|
-
import Alert from 'oneslash-design-system/components/alert';
|
|
42
42
|
import UserImage from 'oneslash-design-system/components/userImage';
|
|
43
|
+
import DropZone, { type FileRejection } from 'oneslash-design-system/components/dropZone';
|
|
44
|
+
import { formatBytes } from 'oneslash-design-system/components/formatNumber';
|
|
43
45
|
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
44
46
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
45
47
|
|
|
@@ -47,6 +49,17 @@ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout
|
|
|
47
49
|
const chosenPicture =
|
|
48
50
|
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E";
|
|
49
51
|
|
|
52
|
+
// 5 MB as formatBytes counts it (base 1024), so the words and the check agree
|
|
53
|
+
const maxPictureBytes = 5 * 1024 * 1024;
|
|
54
|
+
|
|
55
|
+
// The zone reports a reason. The words are this page's, shown under the picture.
|
|
56
|
+
function sayRejected(rejections: FileRejection[]) {
|
|
57
|
+
const reason = rejections[0].reason;
|
|
58
|
+
if (reason === 'type') return 'Choose a JPG, PNG or WebP picture.';
|
|
59
|
+
if (reason === 'size') return `Choose a picture under ${formatBytes(maxPictureBytes)}.`;
|
|
60
|
+
return 'Choose one picture.';
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
const minPasswordLength = 8;
|
|
51
64
|
// Stands in for the server's check. In this example every current password is right except this one.
|
|
52
65
|
const wrongCurrentPassword = 'incorrect';
|
|
@@ -157,16 +170,32 @@ export default function ProfileForm() {
|
|
|
157
170
|
<Heading level={1} size="h5">Profile</Heading>
|
|
158
171
|
|
|
159
172
|
<SettingsSection title="Picture" description="Shown beside your name in Acme.">
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
{/* The error shows under the picture and its Buttons, and is read with the zone. */}
|
|
174
|
+
<FormField id="profile-form-picture" label="New picture" error={pictureError}>
|
|
175
|
+
{(f) => (
|
|
163
176
|
<Cluster gap="small">
|
|
164
|
-
<
|
|
177
|
+
<DropZone
|
|
178
|
+
id={f.id}
|
|
179
|
+
size="compact"
|
|
180
|
+
label="Drop a picture here"
|
|
181
|
+
buttonLabel="Change Picture"
|
|
182
|
+
hint={`JPG, PNG or WebP, up to ${formatBytes(maxPictureBytes)}`}
|
|
183
|
+
accept={['image/jpeg', 'image/png', 'image/webp']}
|
|
184
|
+
maxBytes={maxPictureBytes}
|
|
185
|
+
loading={savingPicture === 'change'}
|
|
186
|
+
disabled={savingPicture === 'remove'}
|
|
187
|
+
aria-describedby={f['aria-describedby']}
|
|
188
|
+
aria-invalid={f['aria-invalid']}
|
|
189
|
+
status={pictureError || undefined}
|
|
190
|
+
onFiles={() => savePicture(chosenPicture, 'change')}
|
|
191
|
+
onReject={(rejections) => setPictureError(sayRejected(rejections))}
|
|
192
|
+
>
|
|
193
|
+
<UserImage userHandle={savedName} userImgUrl={picture} size={64} />
|
|
194
|
+
</DropZone>
|
|
165
195
|
{picture && <Button size="small" type="tertiary" state={savingPicture === 'change' ? 'disabled' : 'enabled'} label="Remove" aria-label="Remove picture" loading={savingPicture === 'remove'} onClickButton={() => savePicture(undefined, 'remove')} />}
|
|
166
196
|
</Cluster>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
</Cluster>
|
|
197
|
+
)}
|
|
198
|
+
</FormField>
|
|
170
199
|
</SettingsSection>
|
|
171
200
|
|
|
172
201
|
<SettingsSection title="Name" description="How people see you in messages and on tasks.">
|