@7shifts/sous-chef 4.17.0 → 5.0.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.
@@ -1,16 +1,31 @@
1
1
  import React from 'react';
2
+ import { AvatarSize, AvatarType } from './types';
3
+ import Badge from '../Badge';
2
4
  type Props = {
3
- /** Content shown inside the avatar instead of the image, such as initials or an icon. */
4
- children?: React.ReactNode;
5
- size?: 'small' | 'medium' | 'large' | 'extra-large';
6
- color?: string;
5
+ /** The entity the avatar represents. It decides the shape, colour, icon and whether an image can be shown. */
6
+ type: AvatarType;
7
+ /** How big the avatar is: `small` (20px), `medium` (30px), `large` (40px) or `extra-large` (80px). Use `medium` in table cells and list rows. */
8
+ size?: AvatarSize;
9
+ /** Name of the user or entity. Used as the accessible name, and `type="role"` shows its first letter. Without it the avatar is decorative. */
10
+ name?: string;
11
+ /** Image URL, lazy-loaded when the avatar enters the viewport. Only used by `user`, `company` and `enterprise`: for `role`, `department` and `location` it is ignored. A role shows its colour and initial, and a department or location its colour and icon. If the image fails to load, the avatar falls back to its default: the silhouette for `user`, the colour and icon for `company` and `enterprise`. */
7
12
  url?: string;
8
- badge?: React.ReactNode;
9
- alt?: string;
13
+ /**
14
+ * Only used by `type="role"`: the role's assigned colour. Accepts a colour token name like `seq-1`, or any CSS colour.
15
+ * @default surface-on-color-subtle
16
+ */
17
+ color?: string;
18
+ /**
19
+ * A `Badge` shown at the bottom-right of the avatar, e.g. `<Badge theme="danger">9</Badge>`. Avatar always sets `hasBorder` on it.
20
+ * - `large` and `extra-large`: rendered as passed (text, a number or an icon).
21
+ * - `small` and `medium`: Avatar sets `size="small"`, so it becomes a dot that keeps the badge's `theme` and hides its content.
22
+ */
23
+ badge?: React.ReactElement<React.ComponentProps<typeof Badge>>;
10
24
  testId?: string;
11
25
  };
26
+ export declare const getRoleInitial: (name?: string) => string;
12
27
  /**
13
- * Avatar represents a person or entity — such as a company, location, department, or role — with a visual identifier. It appears wherever a person or entity's identity needs to be communicated at a glance.
28
+ * Avatar shows a photo, initials or an icon for a person or entity, such as a company, location, department or role.
14
29
  */
15
30
  declare const Avatar: React.FC<Props>;
16
31
  export default Avatar;
@@ -1,4 +1,17 @@
1
- export declare const PROFILE_IMAGES: {
2
- backgroundColor: string;
3
- avatarColor: string;
4
- }[];
1
+ import { AvatarSize, AvatarType, UserPlaceholderColor } from './types';
2
+ /**
3
+ * User placeholder colours: a background and a silhouette colour per pair.
4
+ *
5
+ * These are intentionally hardcoded hex values, not design tokens. They pre-date
6
+ * the Sous Chef design system and are kept unchanged on purpose, so a user's
7
+ * placeholder looks the same as it always has. Don't map them to tokens.
8
+ */
9
+ export declare const USER_PLACEHOLDER_COLORS: Record<UserPlaceholderColor, {
10
+ background: string;
11
+ silhouette: string;
12
+ }>;
13
+ export declare const USER_PLACEHOLDER_COLOR_NAMES: UserPlaceholderColor[];
14
+ /** Types that can show an image. For every other type `url` is ignored. */
15
+ export declare const IMAGE_AVATAR_TYPES: AvatarType[];
16
+ /** Sizes that always render the badge as a dot, whatever was passed. */
17
+ export declare const DOT_BADGE_SIZES: AvatarSize[];
@@ -1 +1,2 @@
1
1
  export { default } from './Avatar';
2
+ export type { AvatarType } from './types';
@@ -0,0 +1,3 @@
1
+ export type AvatarType = 'user' | 'role' | 'department' | 'location' | 'company' | 'enterprise';
2
+ export type AvatarSize = 'small' | 'medium' | 'large' | 'extra-large';
3
+ export type UserPlaceholderColor = 'basil-dark' | 'basil-light' | 'plum-dark' | 'plum-light' | 'strawberry-dark' | 'strawberry-light' | 'blackberry-dark' | 'blackberry-light' | 'oregano-dark' | 'oregano-light' | 'mustard-dark' | 'mustard-light';
@@ -5,3 +5,4 @@ import Chip from './Chip';
5
5
  import Pill from './Pill';
6
6
  import ShortcutKey from './ShortcutKey';
7
7
  export { Badge, Avatar, Bullet, Chip, Pill, ShortcutKey };
8
+ export type { AvatarType } from './Avatar';
@@ -30,7 +30,7 @@ export type DraggableModalState = {
30
30
  * (react-draggable v4.7+ no longer accepts "window" as a string shorthand).
31
31
  *
32
32
  * Initial bounds are estimated from the numeric width/height props (falling
33
- * back to the CSS min-width/min-height defaults). After mount, the element is
33
+ * back to default size estimates). After mount, the element is
34
34
  * measured and bounds are corrected to the actual rendered dimensions so the
35
35
  * modal cannot be dragged outside the viewport even when width/height are CSS
36
36
  * strings or the content exceeds the fallback height.
@@ -3,7 +3,7 @@
3
3
  ## When to Use
4
4
 
5
5
  - To represent a person in a list, table row, or header — such as an employee name, a shift assignee, or a message sender
6
- - To represent an entity such as a role, department, location, or company alongside its name
6
+ - To represent an entity such as a role, department, location, company, or enterprise alongside its name
7
7
  - When a profile photo or brand image is available and adds recognition value
8
8
  - As an indicator of the current logged in user or account being viewed
9
9
 
@@ -11,67 +11,87 @@
11
11
 
12
12
  - As a decorative element with no connection to a real person or entity
13
13
  - In place of an icon when the context has nothing to do with identity
14
+ - As a bullet in a list or numbered steps in a flow — use `Bullet` instead
15
+ - To indicate a status or state that isn't associated with an entity — use `Pill` or `Badge` instead
14
16
 
15
17
  ## Usage
16
18
 
17
19
  ### Content
18
20
 
19
- Avatars can display different kinds of content. Within 7shifts, the entity being displayed defines the content displayed:
21
+ Avatars can display different kinds of content. Within 7shifts, the entity being displayed defines the content displayed. Set it with the `type` prop:
20
22
 
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
- - **For Roles** - Uses a single initial
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
23
+ - **For People** - Uses a photo if available. If not, falls back to the placeholder icon version
24
+ - **For Roles** - Uses the first character of the role as an initial
25
+ - **For Departments** - Static. Always uses the `IconSitemap` icon, which cannot be overridden
26
+ - **For Locations** - Static. Always uses the `IconMapMarker` icon, which cannot be overridden
27
+ - **For Companies** - Uses a photo if available. If not, falls back to the placeholder version that uses `IconKnifeFork`
28
+ - **For Enterprises** - Uses a photo if available. If not, falls back to the placeholder version that uses `IconBarsV`
29
+
30
+ The type also sets the shape: people are circles, roles use a scalloped shape, and departments, locations, companies and enterprises are rounded squares.
25
31
 
26
32
  ### Sizes
27
33
 
28
- Avatars come in four sizes: `small`, `medium`, `large`, and `extra-large`. Choose the size based on how prominent the identity needs to be and what works in your layout.
34
+ Avatars come in four sizes: `small` (20px), `medium` (30px), `large` (40px), and `extra-large` (80px). Choose the size based on how prominent the identity needs to be and what works in your layout.
29
35
  On table cells and list rows, `medium` is the most common size as `small` is quite small.
30
36
 
31
37
  ### Colour
32
38
 
33
- Colour communicates entity identity at a glance and reinforces visual continuity with how that entity appears elsewhere in the product.
39
+ Colour helps people tell entity types apart at a glance. Only roles take a colour from you, and they always need one — every other type's colour is built into the component.
34
40
 
35
41
  #### Users
36
42
 
37
- User avatars reflect the colour of the user's **Primary Role** for the department they are being displayed in. Pass it with the `color` prop:
43
+ Users no longer use their role colour.
38
44
 
39
- - **No photo uploaded** — the role colour fills the avatar background, behind the user's initials
40
- - **Photo uploaded** — the photo fills the avatar and the role colour is not shown. There is no coloured border.
41
- - **No assigned role** — leave `color` unset and 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
45
+ - **Photo uploaded** — the photo fills the avatar. There is no background colour or border.
46
+ - **No photo** — the avatar shows the placeholder silhouette in one of 12 colour pairs, picked at random: basil, plum, strawberry, blackberry, oregano or mustard, each as a light silhouette on a dark background or the reverse. The colour can't be set or overridden.
43
47
 
44
48
  #### Roles
45
49
 
46
- Use the colour associated with that role as the avatar background.
50
+ A role avatar must always use the role's assigned colour. Pass it with the `color` prop, as a colour token name like `seq-1`. This isn't optional and there is no fallback: never show a role avatar without its assigned colour, and don't substitute another colour. The initial is shown in `surface-on-inverse-bold`.
47
51
 
48
52
  #### Departments
49
53
 
50
- Use the `neutral` or `tertiary` colour palettes.
54
+ Static. Always a `tertiary-container` background with a `tertiary-on-container` icon.
51
55
 
52
56
  #### Locations
53
57
 
54
- When there is no user-uploaded photo, the avatar uses the pre-defined placeholder image for locations — no background colour applies.
58
+ Static. Always a `primary-container` background with a `primary-on-container` icon.
59
+
60
+ #### Companies
61
+
62
+ Uses the photo if one is available. Otherwise the placeholder uses a `secondary-container` background with a `secondary-on-container` icon.
63
+
64
+ #### Enterprises
65
+
66
+ Uses the photo if one is available. Otherwise the placeholder uses a `surface-inverse` background with a `surface-on-inverse` icon.
55
67
 
56
68
  ### Badge
57
69
 
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.
70
+ 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 and always has a border to separate it from the avatar.
71
+
72
+ Pass the badge with the `badge` prop, typically a `Badge` component. Badges render on all avatar sizes:
59
73
 
60
- Pass the badge with the `badge` prop, typically a `Badge` component. Badges render on `medium`, `large` and `extra-large` avatars. At `size="small"` the badge is not rendered at all, so don't rely on it to communicate anything important at that size.
74
+ - **`large` and `extra-large`** — the badge renders as passed: text, a number or an icon
75
+ - **`small` and `medium`** — the badge automatically renders as a `dot` badge so it doesn't cover the avatar. It keeps the badge's `theme`, but its content is hidden
61
76
 
62
77
  ## Tips & Tricks
63
78
 
64
- - When representing entities like roles or departments, using the entity's assigned colour as the avatar background creates immediate visual continuity with how that entity appears elsewhere in the product.
79
+ - Always pass `name` with the person's or entity's name. It's what screen readers announce, and for roles it's where the initial comes from.
65
80
  - Avoid using avatars on their own without a label if possible. In most cases an avatar on its own is not enough detail to identify a person or entity.
81
+ - A role avatar always uses the role's assigned colour, so it matches how that role appears elsewhere in the product, like on the schedule.
82
+ - On `small` and `medium` avatars a badge's count or icon is hidden, so let the badge's `theme` carry the meaning, and repeat anything important in the label or a tooltip.
83
+ - Don't rely on a user's placeholder colour to mean anything — it's random and is not tied to their role or department.
66
84
  - The `extra-large` size is best reserved for dedicated profile or detail contexts — a settings page, an employee profile, a company detail view. Using it in a list or table will overpower the surrounding content.
67
85
  - When pairing an avatar with a name in a row or list, the avatar should always sit to the left of the text. Use `Inline` with `alignItems="center"` to keep them vertically centred.
68
- - Always pass an `alt` prop when using a photo or image URL — use the person's name or entity name so screen readers can identify what is shown.
69
86
 
70
87
  ## Additional Rules
71
88
 
89
+ - `type` is required and decides the shape, colour, icon, and whether a photo can be shown.
72
90
  - `size` defaults to `medium` if not specified.
73
- - `children` takes priority over `url` — if both are provided, the children render and the image is ignored.
74
- - When `size="small"`, the `badge` prop is ignored and nothing is rendered. On other sizes the badge is rendered as passed — there is no dot variant.
75
- - When a `url` is provided, the `color` prop is not applied — the avatar shows a light grey background while the image loads.
76
- - Images are lazy-loaded and only fetched when the avatar enters the viewport.
77
- - If the image URL returns an error, the avatar falls back to a generated illustrated placeholder — not a broken image.
91
+ - `url` is only used by `user`, `company` and `enterprise`. For `role`, `department` and `location` it is ignored.
92
+ - `color` is required for `role` and must be the role's assigned colour. Every other type ignores it.
93
+ - `name` is the avatar's accessible name. Without it, the avatar is treated as decorative and hidden from screen readers.
94
+ - The role initial is the first character of `name`, trimmed and uppercased.
95
+ - `badge` always renders with a border. On `small` and `medium` it is forced to a dot.
96
+ - Images are lazy-loaded and only fetched when the avatar enters the viewport. While an image loads, the avatar shows a `surface-container-highest` background.
97
+ - If the image fails to load, the avatar falls back to its placeholder — the silhouette for users, and the colour and icon for companies and enterprises — never a broken image.
@@ -0,0 +1,62 @@
1
+ <!-- AUTO-GENERATED by scripts/build-llms-guidelines.js. Do not edit manually. Run `yarn build-llms-guidelines` to regenerate. -->
2
+
3
+ ## When to Use
4
+
5
+ - As the marker for each item in a list, such as a list of features, benefits or requirements
6
+ - To number the steps in a flow, such as an onboarding checklist or a setup guide
7
+ - To give each item in a list a visual cue about what kind of item it is, using an icon
8
+ - On its own as a static visual decal, where it decorates the layout and doesn't carry any information
9
+
10
+ ## When Not to Use
11
+
12
+ - To represent a person or entity, such as an employee, role or location — use `Avatar` instead
13
+ - To show a count or status on top of another element — use `Badge` instead
14
+ - To label the status or category of something — use `Pill` instead
15
+ - On its own to communicate information — a bullet used as a decal is decorative only, so anything the reader needs to know must be in text
16
+ - For anything dynamic, such as a status, count or state that changes — use `Badge` or `Pill` instead
17
+
18
+ ## Usage
19
+
20
+ ### Content
21
+
22
+ Pass the content as `children`. A bullet holds one of two things:
23
+
24
+ - **An icon** — any Sous Chef icon, such as `IconCheck` or `IconClipboardList`. Bullet sizes the icon to fit the circle and colours it to match the theme, so you don't need to set the icon's `size` or `color`. In `small` bullets, use the solid icon (`variant="solid"`) rather than the outline one. At 12px, outline icons lose detail and become hard to read.
25
+ - **Text** — one or two characters, such as a step number (`1`, `2`) or a letter (`A`). Bullet shows the text exactly as you pass it. It doesn't uppercase or shorten it, so anything longer than two characters spills out of the circle.
26
+
27
+ ### Sizes
28
+
29
+ Bullet comes in four sizes: `small` (20px), `medium` (30px), `large` (40px) and `extra-large` (80px). These match the `Avatar` sizes, so a bullet lines up with an avatar of the same size.
30
+
31
+ `small` is the default and suits most lists. Use the larger sizes when the bullet introduces a bigger heading or block of content, such as the steps of a setup guide.
32
+
33
+ ### Theme and emphasis
34
+
35
+ Set the colour with `theme` and choose how strong it is with `emphasis`.
36
+
37
+ - **`theme`** — `default`, `primary`, `secondary`, `neutral`, `success`, `info`, `warning`, `danger` or `upsell`. Pick the theme that matches the meaning of the list, such as `success` for completed steps or `danger` for things to avoid.
38
+ - **`emphasis`** — `bold` fills the circle with the theme colour. `subtle` uses the theme's lighter container colour with darker content, for a bullet that draws less attention.
39
+
40
+ Use the same theme and emphasis for every bullet in a list, unless the colour is there to show a difference between items, such as completed and upcoming steps.
41
+
42
+ ### Dark mode
43
+
44
+ Bullet switches to the dark theme colours automatically when the page uses the dark theme. There's nothing to set on the bullet itself.
45
+
46
+ ## Tips & Tricks
47
+
48
+ - When a bullet sits next to text, put the meaning in the text. Icons inside a bullet are hidden from screen readers, so the icon alone tells them nothing.
49
+ - When a bullet is used on its own as a decal, keep it static. If removing it would leave the reader missing information, it isn't a decal — add text or use another component.
50
+ - Don't rely on colour alone to tell items apart. Pair a change of theme with a different icon or with wording that says what changed.
51
+ - For numbered steps, use the step number as the text so the order is clear without the surrounding layout.
52
+ - When pairing a bullet with text in a list, the bullet should sit to the left of the text. Use `Inline` with `alignItems="center"` for a single line of text, or align it to the top when the text wraps onto several lines.
53
+ - Keep bullets in a list the same size. Mixing sizes in one list makes it look uneven.
54
+
55
+ ## Additional Rules
56
+
57
+ - `children` is required. Pass either one icon or one or two characters of text.
58
+ - `theme` defaults to `default`, `emphasis` defaults to `bold`, and `size` defaults to `small`.
59
+ - When `children` is an icon, Bullet always sets the icon's size to fit (12px for `small`, 16px for `medium`, 20px for `large`, 40px for `extra-large`). A `size` set on the icon is ignored.
60
+ - Icons get `aria-hidden` and are hidden from screen readers. Text is read out as it is.
61
+ - The bullet is decorative and has no role or label of its own.
62
+ - Bullet accepts only `children`, `theme`, `emphasis`, `size` and `testId`.
@@ -250,7 +250,7 @@ Media components display compact visual or status information, such as avatars a
250
250
 
251
251
  ### Avatar
252
252
 
253
- Avatar represents a person or entity — such as a company, location, department, or role — with a visual identifier. It appears wherever a person or entity's identity needs to be communicated at a glance.
253
+ Avatar represents a person or entity — such as an enterprise, company, location, department, or role — with a visual identifier. It appears wherever a person or entity's identity needs to be communicated at a glance.
254
254
 
255
255
  ### Badge
256
256
 
@@ -258,7 +258,7 @@ Badge is a small circular indicator used to draw attention to something associat
258
258
 
259
259
  ### Bullet
260
260
 
261
- Bullet shows a single icon, or one or two characters of text, inside a small coloured circle.
261
+ Bullet is a small coloured circle that holds a single icon, or one or two characters of text. It marks the start of an item in a list or a step in a flow, and can also be used on its own as a static visual decal.
262
262
 
263
263
  ### Chip
264
264
 
@@ -774,7 +774,7 @@ const ITEMS: Item[] = [
774
774
  employeeName: 'Steve Lawrence',
775
775
  date: 'Jun 22, 2019',
776
776
  hours: 15
777
- // No image: the Avatar shows a placeholder
777
+ // No image: the Avatar shows the user silhouette
778
778
  },
779
779
  {
780
780
  employeeName: 'Alex Andrade',
@@ -790,7 +790,7 @@ const CustomItemComponent = (props: DataTableCustomComponent<Item>) => {
790
790
  <DataTableRow>
791
791
  <DataTableCell columnIndex={0}>
792
792
  <Inline alignItems="center">
793
- <Avatar url={image} />
793
+ <Avatar type="user" url={image} />
794
794
  {employeeName}
795
795
  </Inline>
796
796
  </DataTableCell>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7shifts/sous-chef",
3
- "version": "4.17.0",
3
+ "version": "5.0.1",
4
4
  "description": "7shifts component library",
5
5
  "author": "7shifts",
6
6
  "license": "MIT",
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- type Props = {
3
- url?: string;
4
- color?: string;
5
- alt?: string;
6
- onImageFallbackError: () => void;
7
- };
8
- declare const AvatarImage: React.FC<Props>;
9
- export default AvatarImage;
@@ -1 +0,0 @@
1
- export { default } from './AvatarImage';