Skip to content

Commit

Permalink
Merge branch 'main' into nojira/RichSelectList-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jliotta committed Mar 15, 2024
2 parents 0ef36c4 + d3b8b72 commit 28a5bcb
Show file tree
Hide file tree
Showing 40 changed files with 740 additions and 168 deletions.
7 changes: 7 additions & 0 deletions apps/storybook/CHANGELOG.md
@@ -1,5 +1,12 @@
# @syntax/storybook

## 0.13.5

### Patch Changes

- Updated dependencies [cbcfc85]
- @cambly/syntax-core@10.12.0

## 0.13.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@syntax/storybook",
"version": "0.13.4",
"version": "0.13.5",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider storybook dev -p 6006",
Expand All @@ -9,7 +9,7 @@
"clean": "rm -rf .turbo && rm -rf node_modules"
},
"dependencies": {
"@cambly/syntax-core": "workspace:10.11.0",
"@cambly/syntax-core": "workspace:10.12.0",
"@cambly/syntax-design-tokens": "workspace:0.11.1",
"@cambly/syntax-floating-components": "workspace:^0.5.0",
"react": "18.2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/syntax-core/CHANGELOG.md
@@ -1,5 +1,11 @@
# @cambly/syntax-core

## 10.12.0

### Minor Changes

- cbcfc85: Cambio: add Avatar & AvatarGroup updates

## 10.11.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/syntax-core/package.json
@@ -1,7 +1,7 @@
{
"name": "@cambly/syntax-core",
"description": "Cambly design system core components",
"version": "10.11.0",
"version": "10.12.0",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand All @@ -14,7 +14,7 @@
"scripts": {
"build": "tsup",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"dev": "tsup --watch",
"dev": "NODE_OPTIONS=--max_old_space_size=4096 tsup --watch",
"lint": "TIMING=1 eslint \"src/**/*.ts*\" --max-warnings 0",
"stylelint": "stylelint \"**/*.css\"",
"stylelint:fix": "npm run stylelint --fix",
Expand Down
27 changes: 27 additions & 0 deletions packages/syntax-core/src/Avatar/Avatar.module.css
Expand Up @@ -8,9 +8,16 @@
background-size: cover;
background-repeat: no-repeat;
border-radius: 50%;
}

.avatarImageClassic {
border: 2px solid #fff;
}

.avatarImageOutlineCambio {
border: 2px solid var(--color-cambio-gray-100);
}

.sm {
width: 24px;
height: 24px;
Expand All @@ -30,3 +37,23 @@
width: 128px;
height: 129px;
}

.smCambio {
width: 32px;
height: 32px;
}

.mdCambio {
width: 48px;
height: 48px;
}

.lgCambio {
width: 64px;
height: 64px;
}

.xlCambio {
width: 64px;
height: 64px;
}
42 changes: 38 additions & 4 deletions packages/syntax-core/src/Avatar/Avatar.tsx
Expand Up @@ -3,6 +3,7 @@ import classNames from "classnames";
import styles from "./Avatar.module.css";
import Box from "../Box/Box";
import { useAvatarGroup } from "../AvatarGroup/AvatarGroup";
import { useTheme } from "../ThemeProvider/ThemeProvider";

const sizeToIconStyles = {
sm: { bottom: 6, marginInlineEnd: 2, height: 4, width: 4 },
Expand All @@ -11,30 +12,51 @@ const sizeToIconStyles = {
xl: { bottom: 12, marginInlineEnd: 12, height: 16, width: 16 },
} as const;

const sizeToMargin = {
const sizeToMarginClassic = {
sm: -16,
md: -28,
lg: -48,
xl: -88,
} as const;

const sizeToMarginCambio = {
sm: -12,
md: -20,
lg: -28,
xl: -28,
} as const;

function AvatarInternal({
accessibilityLabel,
icon,
outline,
size = "md",
src,
}: {
accessibilityLabel: string;
icon?: React.ReactElement;
outline?: boolean;
size?: "sm" | "md" | "lg" | "xl";
src: string;
}): ReactElement {
const { themeName } = useTheme();

return (
<div className={classNames(styles.avatar, styles[size])}>
<div
className={classNames(
styles.avatar,
themeName === "classic" ? styles[size] : styles[`${size}Cambio`],
)}
>
<img
alt={accessibilityLabel}
src={src}
className={classNames(styles.avatarImage, styles[size])}
className={classNames(
styles.avatarImage,
themeName === "classic" && styles.avatarImageClassic,
themeName === "cambio" && outline && styles.avatarImageOutlineCambio,
themeName === "classic" ? styles[size] : styles[`${size}Cambio`],
)}
/>
{icon && (
<Box display="flex" position="relative" justifyContent="end">
Expand Down Expand Up @@ -81,11 +103,18 @@ const Avatar = ({
/**
* Size of the avatar.
*
* Classic:
* * `sm`: 24px
* * `md`: 40px
* * `lg`: 72px
* * `xl`: 128px
*
* Cambio:
* * `sm`: 32px
* * `md`: 48px
* * `lg`: 64px
* * `xl`: 64px (deprecated, maps to `lg` in Cambio)
*
* @defaultValue `md`
*/
size?: "sm" | "md" | "lg" | "xl";
Expand All @@ -95,14 +124,18 @@ const Avatar = ({
src: string;
}): JSX.Element => {
const avatarGroupContext = useAvatarGroup();
const { themeName } = useTheme();

if (avatarGroupContext !== null) {
return (
<Box
position="relative"
dangerouslySetInlineStyle={{
__style: {
marginInlineEnd: sizeToMargin[avatarGroupContext.size],
marginInlineEnd:
themeName === "cambio"
? sizeToMarginCambio[avatarGroupContext.size]
: sizeToMarginClassic[avatarGroupContext.size],
},
}}
>
Expand All @@ -116,6 +149,7 @@ const Avatar = ({
<AvatarInternal
accessibilityLabel={accessibilityLabel}
icon={icon}
outline={themeName === "cambio"}
size={avatarGroupContext.size}
src={src}
/>
Expand Down
20 changes: 18 additions & 2 deletions packages/syntax-core/src/AvatarGroup/AvatarGroup.tsx
Expand Up @@ -5,8 +5,14 @@ import {
type ReactElement,
} from "react";
import Box from "../Box/Box";
import { useTheme } from "../ThemeProvider/ThemeProvider";

type Size = "sm" | "md" | "lg" | "xl";
type Size =
| "sm"
| "md"
| "lg"
/* `xl` is deprecated and mapped to `lg` in Cambio */
| "xl";
type Orientation = "standard" | "reverse";

type AvatarGroupContextType = {
Expand Down Expand Up @@ -43,11 +49,18 @@ export default function AvatarGroup({
/**
* Size of the avatars in the AvatarGroup.
*
* Classic:
* * `sm`: 24px
* * `md`: 40px
* * `lg`: 72px
* * `xl`: 128px
*
* Cambio:
* * `sm`: 32px
* * `md`: 48px
* * `lg`: 64px
* * `xl`: 64px (deprecated, maps to `lg` in Cambio)
*
* @defaultValue `md`
*/
size?: Size;
Expand All @@ -65,8 +78,11 @@ export default function AvatarGroup({
*/
children: ReactNode;
}): ReactElement {
const { themeName } = useTheme();
const parsedSize = themeName === "cambio" && size === "xl" ? "lg" : size;

return (
<AvatarGroupContext.Provider value={{ size, orientation }}>
<AvatarGroupContext.Provider value={{ size: parsedSize, orientation }}>
<Box
display="flex"
justifyContent={orientation === "standard" ? "start" : "end"}
Expand Down
52 changes: 30 additions & 22 deletions packages/syntax-core/src/Badge/Badge.tsx
@@ -1,6 +1,7 @@
import Typography from "../Typography/Typography";
import Box from "../Box/Box";
import styles from "./Badge.module.css";
import { useTheme } from "../ThemeProvider/ThemeProvider";

const BadgeColor = [
"gray200",
Expand Down Expand Up @@ -47,27 +48,34 @@ const Badge = ({
* @defaultValue "primary700"
*/
color?: (typeof BadgeColor)[number];
}): JSX.Element => (
<Box
display="inlineBlock"
paddingX={2}
paddingY={1}
rounding="full"
backgroundColor={color}
>
<Typography color={textColorForBackgroundColor(color)} size={100}>
<Box display="flex" gap={1} alignItems="center" justifyContent="start">
{Icon && <Icon className={styles.icon} />}
<Typography
color={textColorForBackgroundColor(color)}
size={100}
weight="bold"
>
{text}
</Typography>
</Box>
</Typography>
</Box>
);
}): JSX.Element => {
const { themeName } = useTheme();

return (
<Box
display={themeName === "classic" ? "inlineBlock" : "inlineFlex"}
paddingX={themeName === "classic" ? 2 : 3}
paddingY={1}
rounding={themeName === "classic" ? "full" : "sm"}
backgroundColor={color}
alignItems="center"
justifyContent="center"
height={themeName === "cambio" ? 32 : undefined}
>
<Typography color={textColorForBackgroundColor(color)}>
<Box display="flex" gap={1} alignItems="center" justifyContent="start">
{Icon && <Icon className={styles.icon} />}
<Typography
color={textColorForBackgroundColor(color)}
size={100}
weight={themeName === "classic" ? "bold" : "medium"}
>
{text}
</Typography>
</Box>
</Typography>
</Box>
);
};

export default Badge;
12 changes: 12 additions & 0 deletions packages/syntax-core/src/Box/Box.module.css
Expand Up @@ -119,6 +119,10 @@
display: inline-block;
}

.inlineFlex {
display: inline-flex;
}

.none {
display: none;
}
Expand Down Expand Up @@ -149,6 +153,10 @@
display: inline-block;
}

.inlineFlexSmall {
display: inline-flex;
}

.noneSmall {
display: none;
}
Expand Down Expand Up @@ -180,6 +188,10 @@
display: inline-block;
}

.inlineFlexLarge {
display: inline-flex;
}

.noneLarge {
display: none;
}
Expand Down

0 comments on commit 28a5bcb

Please sign in to comment.