@7shifts/sous-chef 4.17.0 → 5.0.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,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';
@@ -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.0",
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';