@7shifts/sous-chef 4.13.0 → 4.14.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.
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  type Props = {
3
- url: string;
3
+ url?: string;
4
+ color?: string;
4
5
  alt?: string;
5
6
  onImageFallbackError: () => void;
6
- onImageLoad: () => void;
7
7
  };
8
8
  declare const AvatarImage: React.FC<Props>;
9
9
  export default AvatarImage;
@@ -4,11 +4,6 @@ type Props = {
4
4
  theme?: 'success' | 'danger' | 'warning' | 'info';
5
5
  /** This will show a black tooltip when the user hover the badge */
6
6
  title?: string;
7
- /**
8
- * `default` renders the badge with its content. `dot` renders a
9
- * small solid circle with no content — used by small/medium Avatars.
10
- */
11
- size?: 'dot' | 'default';
12
7
  testId?: string;
13
8
  };
14
9
  /**
@@ -18,9 +18,10 @@
18
18
 
19
19
  Avatars can display different kinds of content. Within 7shifts, the entity being displayed defines the content displayed:
20
20
 
21
- - **For people** - Uses a photo if available. If not, fallback to the `default`
21
+ - **For people** - Uses a photo if available. If not, falls back to the user's initials — the first letter of their first name and the first letter of their last name
22
22
  - **For Roles** - Uses a single initial
23
23
  - **For Departments** - Use an icon
24
+ - **For Locations** - Uses a photo if available. If not, falls back to the default placeholder image for locations
24
25
 
25
26
  ### Sizes
26
27
 
@@ -29,11 +30,34 @@ On table cells and list rows, `medium` is the most common size as `small` is qui
29
30
 
30
31
  ### Colour
31
32
 
32
- When showing initials or an icon, a background colour can be applied to the avatar. For entities like roles and departments that already have an assigned colour in the system, use that colour here to reinforce the visual identity and aid quick recognition. `default` avatars for users who have not added a photo are random.
33
+ Colour communicates entity identity at a glance and reinforces visual continuity with how that entity appears elsewhere in the product.
34
+
35
+ #### Users
36
+
37
+ User avatars reflect the colour of the user's **Primary Role** for the department they are being displayed in:
38
+
39
+ - **No photo uploaded** — the role colour fills the avatar background, behind the user's initials
40
+ - **Photo uploaded** — the role colour appears as a coloured border around the avatar
41
+ - **No assigned role** — the avatar appears grey
42
+ - **Multiple roles** — the Primary Role's colour is always used. If the user has multiple roles but none is set as primary, the colour of their oldest assigned role is shown instead
43
+
44
+ #### Roles
45
+
46
+ Use the colour associated with that role as the avatar background.
47
+
48
+ #### Departments
49
+
50
+ Use the `neutral` or `tertiary` colour palettes.
51
+
52
+ #### Locations
53
+
54
+ When there is no user-uploaded photo, the avatar uses the pre-defined placeholder image for locations — no background colour applies.
33
55
 
34
56
  ### Badge
35
57
 
36
- A badge can be overlaid on the avatar to surface supplementary information — an action, a status indicator, or a count. The badge sits in the bottom-right corner of the avatar. Badges are not shown on `small` avatars as there is not enough space.
58
+ A badge can be overlaid on the avatar to surface supplementary information — an action, a status indicator, or a count. The badge sits in the bottom-right corner of the avatar.
59
+
60
+ Badges are supported on all sizes. When the avatar is set to `small` or `medium`, the badge automatically renders in its dot variant so it doesn't obscure the avatar content. On `large` and `extra-large` avatars, the full badge is shown.
37
61
 
38
62
  ## Tips & Tricks
39
63
 
@@ -47,6 +71,6 @@ A badge can be overlaid on the avatar to surface supplementary information — a
47
71
 
48
72
  - `size` defaults to `medium` if not specified.
49
73
  - `children` takes priority over `url` — if both are provided, the children render and the image is ignored.
50
- - Badges do not render when `size="small"`. This is intentional and cannot be overridden.
74
+ - When `size="small"` or `size="medium"`, any badge passed to the avatar is automatically forced into its dot variant. This is intentional and cannot be overridden.
51
75
  - Images are lazy-loaded and only fetched when the avatar enters the viewport.
52
76
  - If the image URL returns an error, the avatar falls back to a generated illustrated placeholder — not a broken image.
@@ -22,6 +22,12 @@ Badge accepts any content — a number, an icon, or short text. Numbers are the
22
22
 
23
23
  Badge supports 5 themes that change its background colour: `default`, `success`, `danger`, `warning`, and `info`. Use these to reinforce the meaning of what the badge is communicating.
24
24
 
25
+ ### Size
26
+
27
+ Badge supports two sizes via the `size` property: `default` and `dot`.
28
+
29
+ The `dot` variant reduces the badge to a single coloured circle with no content. It trades information density for space efficiency — the colour alone signals presence or status. Use `dot` when attaching a badge to a small element where the full badge would overwhelm the host, such as an icon or a `small` or `medium` sized avatar.
30
+
25
31
  ### Tooltip
26
32
 
27
33
  When a badge contains only an icon or a number that may not be self-explanatory, a tooltip should be added to clarify what it means.
@@ -31,6 +37,7 @@ When a badge contains only an icon or a number that may not be self-explanatory,
31
37
  - Badges with numbers work best for counts under 100 — if the count can go higher, consider capping the display at "99+" to prevent the badge from growing too wide.
32
38
  - Icon badges are ideal for edit or camera actions on avatars — they communicate "you can change this" without needing any text.
33
39
  - Badge is intentionally minimal — resist the urge to put too much inside it. If you need more than a number or a single icon, you probably want a `Pill` or `chip` instead.
40
+ - Be conscious when using dot badges — they carry much less information, and relying on colour alone to distinguish statuses is not accessible. Use dot badges in a binary sense, where the presence or absence of the badge is enough to communicate a status change. Avoid dot badges when you have multiple distinct states to communicate.
34
41
 
35
42
  ## Additional Rules
36
43
 
@@ -38,3 +45,4 @@ When a badge contains only an icon or a number that may not be self-explanatory,
38
45
  - When `children` is a React element (e.g. an icon), the badge height is set to match its width to keep it circular.
39
46
  - `theme` is optional — without it the badge renders in its default neutral colour.
40
47
  - `title` renders as a `Tooltip` overlay on hover. It does not render any visible label at rest.
48
+ - When `size="dot"`, any children passed to the badge are ignored — the dot renders as a plain coloured circle regardless of content.
@@ -47,6 +47,21 @@ This image has a fixed height of `200px` and the width matches the width of the
47
47
 
48
48
  Note that the close `button` and icons in the icon bar have a distinct transparent fill in order to ensure they are still visible over the chosen image.
49
49
 
50
+ #### Icon Bar
51
+
52
+ The `iconBar` prop places one or more icon buttons in the top bar of the modal, sitting alongside the close button. Use it for secondary, contextual actions that are specific to the modal's content — things like opening a help article, accessing settings, or copying a link.
53
+
54
+ Keep these rules in mind when using the icon bar:
55
+
56
+ - Use icon-only buttons. Labels don't fit and the close button sets the visual precedent.
57
+ - Limit to 2–3 icons at most. More than that and the header becomes cluttered.
58
+ - The icon bar is not the place for primary actions — those belong in the `ModalFooter`.
59
+ - When `imageSrc` is also set, the icon bar buttons automatically adopt a transparent fill to remain visible over the image.
60
+
61
+ #### Tabs
62
+
63
+ Use the `tabList` prop to pin a `TabList` below the modal header. This keeps the tab bar anchored while the content in `ModalBody` scrolls independently — a cleaner pattern than putting a `TabList` inside a scrolling body.
64
+
50
65
  #### Draggable modals
51
66
 
52
67
  `draggable` modals allow the user to move the modal around the canvas and do not apply an overlay to the rest of the canvas allowing users to keep interacting with it while the modal is open. Use these when the function of the modal is critically connected to the content of the page. For example, creating or editing a shift on the schedule, where the user may need to reference information on the schedule while creating their new shift.
@@ -60,6 +75,7 @@ Note that the close `button` and icons in the icon bar have a distinct transpare
60
75
 
61
76
  ## Additional Rules
62
77
 
78
+ - When using `tabList`, wrap the entire `Modal` in a `Tabs` component (where `defaultValue` or `value` lives), pass a `TabList` to the `tabList` prop, and place `TabPanel` components inside `ModalBody`. Set a fixed `height` on the modal — it won't automatically resize when switching tabs, so a fixed height prevents layout shifts.
63
79
  - `Modal` requires `Modal.setAppElement('#root')` (or equivalent) to be called once in the app, or `rootElementId` to be passed per instance, for correct accessibility behaviour.
64
80
  - `ModalBody` and `ModalFooter` are required sub-components — do not render content directly as children of `Modal` without them.
65
81
  - Use `loading={true}` during async operations to disable the close button and prevent users from interrupting a save or delete in progress.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7shifts/sous-chef",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
4
4
  "description": "7shifts component library",
5
5
  "author": "7shifts",
6
6
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- type AvatarContextType = {
2
- size: 'small' | 'medium' | 'large' | 'extra-large' | null;
3
- };
4
- declare const AvatarContext: import("react").Context<AvatarContextType>;
5
- export declare const useAvatarContext: () => AvatarContextType;
6
- export default AvatarContext;