Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): Update design tokens and defaultTheme #748

Merged
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d668f61
refactor(styles): change font to Inter + Add storybook Badges + Updat…
masoudmanson Feb 13, 2024
ecab23c
refactor(storybook): fix storybook ui styles
masoudmanson Feb 13, 2024
f510e62
refactor(fonts): change all fonts to Inter
masoudmanson Feb 13, 2024
c8af49a
refactor(storybook): add Badges and fix storybook styles
masoudmanson Feb 13, 2024
cefa4a1
chore(merge): merge latest changes from main into the current PR
masoudmanson Feb 15, 2024
d112fc6
fix(tests): update snapshots
masoudmanson Feb 15, 2024
eb02c2b
feat(styles): update style-dictionary tokens to figma refactor values
masoudmanson Feb 16, 2024
bb86978
fix(googlefonts): fix Inter font weights link
masoudmanson Feb 16, 2024
00df2a2
feat(designtokens): separate design tokens in smaller files and fix t…
masoudmanson Feb 16, 2024
6c63b52
feat(defaulttheme): import all figma design tokens into defaultTheme
masoudmanson Feb 17, 2024
9f8010b
fix(bordercolors): fix border colors design tokens
masoudmanson Feb 17, 2024
6eb6418
feat(styles): update all components to accomodate new figma refactor …
masoudmanson Feb 23, 2024
5d0fd60
fix(a11y): fix a11y tests errors
masoudmanson Feb 24, 2024
57dc7b5
feat(storybook): add Colors and Corners foundation stories
masoudmanson Feb 25, 2024
b7b7858
feat(bases): add corner, borders, shadows, spacing
masoudmanson Feb 25, 2024
e73f3d7
fix(a11y): fix a11y errors
masoudmanson Feb 25, 2024
d70cbcd
fix(callout): add 2px margin top for the callout alert-message
masoudmanson Feb 26, 2024
c66ae4d
refactor(spaces): change all theme.spacings to theme.spaces
masoudmanson Feb 26, 2024
620dd58
fix(types): fix Spaces type names
masoudmanson Feb 26, 2024
913568b
fix(spaces): fix types
masoudmanson Feb 26, 2024
929f90c
refactor(variables): refactor sass/css variables
masoudmanson Feb 26, 2024
f840f18
fix(storybook): upgrade to version 7.6.17
masoudmanson Feb 26, 2024
422653b
refactor(refactor): remove redundant code
masoudmanson Feb 26, 2024
dffd204
refactor(inputradio): full refactor of InputRadio, InputCheckbox and …
masoudmanson Feb 27, 2024
40bc661
fix(a11y): fix a11y errors
masoudmanson Feb 27, 2024
bc29594
feat(link): add size prop to link component
masoudmanson Feb 27, 2024
73afe98
fix(a11y): fix a11y errors
masoudmanson Feb 27, 2024
0faa9cb
feat(icons): refactor all SDS icons to new 16 x 16 and 24 x 24 sizes
masoudmanson Feb 29, 2024
d717c0e
fix(icons): add xml schema to svg icons + Add ExcludedControls to all…
masoudmanson Feb 29, 2024
5937dd6
fix(icons): fix case-sensitive icon names
masoudmanson Feb 29, 2024
42ba1c2
feat(link): add fontWeight prop to the link component
masoudmanson Feb 29, 2024
9bdbbe0
fix(inputcheckbox): fix checkbox icon
masoudmanson Feb 29, 2024
95dee6d
fix(inputcheckbox): fix icon fill
masoudmanson Feb 29, 2024
9145f0f
fix(checkbox): fix fill
masoudmanson Feb 29, 2024
6e10869
fix(table): fix table demo
masoudmanson Feb 29, 2024
f58e42c
fix(refactor): fix code review bugs
masoudmanson Mar 5, 2024
ac0b868
chore(snapshots): update test snapshots
masoudmanson Mar 5, 2024
49f4f1d
refactor(stories): organize storybook files and breakdown large stori…
masoudmanson Mar 6, 2024
7517bab
fix(components): fix design review bugs in all components
masoudmanson Mar 12, 2024
3f31501
fix(a11y): fix a11y errors
masoudmanson Mar 12, 2024
411f73e
fix(linter): fix lint errors
masoudmanson Mar 12, 2024
627a32e
refactor(cellbasic): exclude new props form non-default stories
masoudmanson Mar 12, 2024
9e831b8
refactor(colors): show semantic names in color component
masoudmanson Mar 12, 2024
cffb970
fix(borders): change borders semantic names
masoudmanson Mar 12, 2024
b8e0283
fix(autocomplete): fix Autocomplete section titles + tagFilter delete…
masoudmanson Mar 12, 2024
df6e98a
refactor(tag): add sdsSize to tag and fix Dialog close button styles
masoudmanson Mar 13, 2024
f06e554
fix(tag): fix icon sizes in the storybook default demo
masoudmanson Mar 14, 2024
d84d730
feat(icon): add IconCubeSmall
masoudmanson Apr 1, 2024
acaedf2
fix(cube icon): fix icon fill
masoudmanson Apr 3, 2024
fcac667
fix(filtertag): fix onDelete
masoudmanson Apr 3, 2024
088dad4
fix(filtertag): fix a11y errors
masoudmanson Apr 3, 2024
052d2ca
fix(tagfilter): update test snapshots
masoudmanson Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
endOfLine: "lf",
tabWidth: 2,
trailingComma: "es5",
printWidth: 80,
};
21 changes: 21 additions & 0 deletions .storybook/components/SidebarItem/SidebarItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import { StyledSidebarItem } from "./style";
import StatusTag from "../StatusTag/StatusTag";

export type StatusType = "beta" | "deprecated" | "wip";

interface SidebarItemProps {
children: React.ReactNode;
status: StatusType;
}

const SidebarItem = ({ children, status }: SidebarItemProps) => {
return (
<StyledSidebarItem>
<div>{children}</div>
<StatusTag type={status}>{status}</StatusTag>
</StyledSidebarItem>
);
};

export default SidebarItem;
8 changes: 8 additions & 0 deletions .storybook/components/SidebarItem/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { styled } from "@mui/material";

export const StyledSidebarItem = styled("div")`
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
`;
22 changes: 22 additions & 0 deletions .storybook/components/StatusTag/StatusTag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { FC } from "react";
import { StyledLabel } from "./style";
import { StatusType } from "../SidebarItem/SidebarItem";

interface StatusTagProps {
children: React.ReactNode;
type: StatusType;
}

const TypeToLabel: Record<StatusType, string> = {
beta: "Beta",
deprecated: "Deprecated",
wip: "Work in Progress",
};

const StatusTag: FC<StatusTagProps> = ({ type }) => {
const label = TypeToLabel[type];

return <StyledLabel type={type}>{label}</StyledLabel>;
};

export default StatusTag;
36 changes: 36 additions & 0 deletions .storybook/components/StatusTag/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { styled } from "@mui/material";
import { StatusType } from "../SidebarItem/SidebarItem";

interface StyledLabelProps {
type: StatusType;
}

const TypeToColor: Record<StatusType, string> = {
beta: "#703CBE",
deprecated: "#C61128",
wip: "#D8921F",
};

const TypeToBorderColor: Record<StatusType, string> = {
beta: "#7A41CE",
deprecated: "#DC132C",
wip: "#F5A623",
};

export const StyledLabel = styled("label")`
${(props: StyledLabelProps) => {
const { type } = props;
const color = TypeToColor[type];
const borderColor = TypeToBorderColor[type];

return `
margin: 0 16px 0 8px;
padding: 1px 4px;
font-size: 10px;
font-weight: 600;
color: ${color};
border: solid 1px ${borderColor};
border-radius: 2px;
`;
}}
`;
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/react"),
getAbsolutePath("storybook-addon-pseudo-states"),
getAbsolutePath("@geometricpanda/storybook-addon-badges"),
],
framework: {
name: getAbsolutePath("@storybook/react-webpack5"),
Expand Down
40 changes: 21 additions & 19 deletions .storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<meta property="og:description" content="SDS design system by CZI" />
<meta property="og:title" content="Vibe Design System" />
<meta property="og:description" content="Science Design System by CZI" />
<meta property="og:title" content="Science Design System" />
<link
rel="icon"
type="image/png"
href="https://user-images.githubusercontent.com/927990/204130290-897628ee-e89a-4911-89df-0956c9edf940.png"
sizes="48x48"
/>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400;1,600;1,700&display=swap"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
rel="stylesheet"
crossorigin="anonymous"
/>
<title>SDS Design System</title>
<style>
body {
font-family: "Open Sans", sans-serif !important;
font-family: "Inter", sans-serif !important;
font-size: 14px;
}

#storybook-explorer-menu svg {
color: #555;
margin-top: 4px;
}

#storybook-explorer-menu button:focus,
Expand Down Expand Up @@ -62,17 +65,14 @@
background-color: transparent !important;
}

#storybook-explorer-menu button.sidebar-item {
font-size: 14px;
padding: 5px 3px 5px 2px;
}

#storybook-explorer-menu button.sidebar-item,
#storybook-explorer-menu a.sidebar-item {
font-size: 14px;
padding: 5px 3px 5px 34px;
padding-top: 5px;
padding-bottom: 5px;
}

#storybook-explorer-menu .sidebar-item > span {
#storybook-explorer-menu .sidebar-item > div > span {
display: inline-block;
position: relative;
border-style: solid;
Expand All @@ -90,11 +90,13 @@
margin-right: 6px;
}

#storybook-explorer-menu .sidebar-item > span {
margin-top: 7px;
#storybook-explorer-menu .sidebar-item[data-selected="true"] {
background-color: #eaeaea;
color: black;
font-weight: 600;
}

#storybook-explorer-menu .sidebar-item[aria-expanded="true"] > span,
#storybook-explorer-menu .sidebar-item[aria-expanded="true"] > div > span,
#storybook-explorer-menu
.sidebar-subheading[aria-expanded="true"]
> button
Expand All @@ -105,7 +107,7 @@
<script>
//workaround to increase the left panel width just enough to show even the longer story names
//based on https://github.com/storybookjs/storybook/issues/9682#issuecomment-983356523
const DEFAULT_MINIMUM_LEFT_PANEL_WIDTH = 260; // original default is 230
const DEFAULT_MINIMUM_LEFT_PANEL_WIDTH = 280; // original default is 230
let storybookConfig = JSON.parse(localStorage.getItem("storybook-layout"));

// we only resize the left panel if it is set to a value lower than DEFAULT_MINIMUM_LEFT_PANEL_WIDTH
Expand All @@ -132,7 +134,7 @@
).firstChild;
bookmarkHollowIcon.setAttribute(
"d",
"M 13.762 6.202 C 13.87 6.452 13.927 6.724 13.927 7.001 C 13.927 7.275 13.87 7.548 13.762 7.799 C 13.656 8.049 13.498 8.272 13.303 8.451 L 8.873 12.502 C 8.711 12.65 8.504 12.731 8.29 12.731 L 0.968 12.731 C 0.731 12.731 0.503 12.631 0.336 12.452 C 0.168 12.273 0.073 12.03 0.073 11.775 L 0.073 2.224 C 0.073 1.971 0.168 1.727 0.336 1.548 C 0.503 1.369 0.731 1.269 0.968 1.269 L 8.29 1.269 C 8.504 1.269 8.711 1.35 8.873 1.499 L 13.303 5.55 C 13.498 5.729 13.656 5.952 13.762 6.202 Z M 11.862 7.553 C 11.929 7.492 11.988 7.412 12.029 7.315 C 12.071 7.219 12.093 7.11 12.093 7.001 C 12.093 6.889 12.071 6.782 12.029 6.684 C 11.988 6.589 11.929 6.508 11.862 6.447 L 7.885 2.809 L 1.594 2.809 L 1.594 11.191 L 7.885 11.191 L 11.862 7.553 Z"
"M 13.762 6.202 C 13.87 6.452 13.927 6.724 13.927 7.001 C 13.927 7.275 13.87 7.548 13.762 7.799 C 13.656 8.049 13.498 8.272 13.303 8.451 L 8.873 12.502 C 8.711 12.65 8.504 12.731 8.29 12.731 L 0.968 12.731 C 0.731 12.731 0.503 12.631 0.336 12.452 C 0.168 12.273 0.073 12.03 0.073 11.775 L 0.073 2.224 C 0.073 1.971 0.168 1.727 0.336 1.548 C 0.503 1.369 0.731 1.269 0.968 1.269 L 8.29 1.269 C 8.504 1.269 8.711 1.35 8.873 1.499 L 13.303 5.55 C 13.498 5.729 13.656 5.952 13.762 6.202 Z M 12.508 7.538 C 12.575 7.477 12.634 7.397 12.675 7.3 C 12.717 7.204 12.739 7.095 12.739 6.986 C 12.739 6.874 12.717 6.767 12.675 6.669 C 12.634 6.574 12.575 6.493 12.508 6.432 L 8.161 2.346 L 1.085 2.34 L 1.106 11.659 L 8.28 11.628 L 12.508 7.538 Z"
);
bookmarkHollowIcon.setAttribute("fill-rule", "evenodd");
});
Expand Down
19 changes: 18 additions & 1 deletion .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
// .storybook/manager.js

import React from "react";
import { addons } from "@storybook/addons";
import sdsTheme from "./sds-theme";
import SidebarItem from "./components/SidebarItem/SidebarItem";

addons.setConfig({
theme: sdsTheme,
sidebar: {
renderLabel: ({ name }) => {
const statusRegex = /\[([^)]+)]/gi;
const [statusMatch, statusType] = statusRegex.exec(name) || [];

if (statusMatch) {
return (
<SidebarItem status={statusType}>
{name.replace(statusMatch, "").trim()}
</SidebarItem>
);
}

return name;
},
},
});
10 changes: 7 additions & 3 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400;1,600;1,700&display=swap"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
rel="stylesheet"
crossorigin="anonymous"
/>
56 changes: 56 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defaultTheme } from "../packages/components/src/core/styles";
import { ThemeProvider } from "@mui/material/styles";
import { BADGE } from "../packages/components/src/common/storybook/storybookBadges";

export const decorators = [
(Story) => (
Expand All @@ -18,5 +19,60 @@ const preview = {
globalTypes: {
pseudo: {},
},
parameters: {
badgesConfig: {
[BADGE.BETA]: {
styles: {
backgroundColor: "#F4F0F9",
borderColor: "#7A41CE",
borderRadius: 2,
color: "#703CBE",
},
title: "Beta",
},
[BADGE.DEPRECATED]: {
styles: {
backgroundColor: "#FEF2F2",
borderColor: "#DC132C",
borderRadius: 2,
color: "#C61128",
},
title: "Deprecated",
},
[BADGE.NEEDS_REVISION]: {
styles: {
backgroundColor: "#F8F8F8",
borderColor: "#999999",
borderRadius: 2,
color: "#767676",
},
title: "Needs Revision",
},
[BADGE.STABLE]: {
styles: {
backgroundColor: "#ECF5F0",
borderColor: "#3CB371",
borderRadius: 2,
color: "#349A61",
},
title: "Stable",
},
[BADGE.WIP]: {
styles: {
backgroundColor: "#FCF6EC",
borderColor: "#F5A623",
borderRadius: 2,
color: "#D8921F",
},
title: "Work in progress",
},
},
options: {
storySort: {
method: "alphabetical",
order: ["Bases", "Components", "Data Viz", "Deprecated"],
},
},
},
};
export default preview;
2 changes: 1 addition & 1 deletion .storybook/sds-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default create({
appBorderRadius: 0,

// Typography
fontBase: '"Open Sans", sans-serif',
fontBase: '"Inter", sans-serif',
fontCode: "monospace",

// Text colors
Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The Science Design System (SDS) brings consistency and universal standards to CZ

## Design System Documentation

`@czi-sds/components` implements the Science Design System as documented in [Zeroheight](https://sds.czi.design/). As a result, it's very useful to get familiar with the available **theme variables**, such as `colors`, `spacings`, `typography`, etc., so you can leverage the theme properly in your application.
`@czi-sds/components` implements the Science Design System as documented in [Zeroheight](https://sds.czi.design/). As a result, it's very useful to get familiar with the available **theme variables**, such as `colors`, `spaces`, `typography`, etc., so you can leverage the theme properly in your application.

![Science Design System Zeroheight Homepage Snapshot](https://user-images.githubusercontent.com/6309723/155802483-366008aa-7380-4a01-b356-ae0ab02f4f3b.png)

Expand Down Expand Up @@ -93,24 +93,24 @@ export const Title - styled(Typography)`

```ts
import { css, SerializedStyles } from "@emotion/react";
import { styled } from '@mui/material/styles';
import { styled } from "@mui/material/styles";
import { getColors, getCorners } from "@czi-sds/components";

export const Tag = styled("div")`
// This is a callback function that returns more CSS rules, but the only way
// to access the custom theme object
${(props) => {
// getColors() is a selector that picks out colors from the theme object
const colors = getColors(props);
// getSpaces() is a selector that picks out spacings from the theme object
const spacings = getSpaces(props);
${(props) => {
// getColors() is a selector that picks out colors from the theme object
const colors = getColors(props);
// getSpaces() is a selector that picks out spaces from the theme object
const spaces = getSpaces(props);

return `
return `
background-color: ${colors?.gray[500]};
padding-bottom: ${spacings?.m}px;
margin-bottom: ${spacings?.xxl}px;
padding-bottom: ${spaces?.m}px;
margin-bottom: ${spaces?.xxl}px;
`;
}}
}}
`;
```

Expand Down Expand Up @@ -199,9 +199,14 @@ To use the default theme in your React application, complete the following:

```html
// installs the sds font from google fonts
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400;1,600;1,700&display=swap"
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
rel="stylesheet"
/>
```
Expand Down
14 changes: 14 additions & 0 deletions jest.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ module.exports = {
preset: "ts-jest",
setupFilesAfterEnv: ["./jest.setup.ts"],
testEnvironment: "jsdom",
/**
* A list of paths to directories that Jest should use to search for files in.
* The first two paths are the default paths that Jest uses to search for files.
* The third path specifies the namespace-test files that we want to exclude from the test run.
* The fourth path specifies the storybook files that we want to exclude from the test run.
*
* https://jestjs.io/docs/configuration#testmatch-arraystring
*/
testMatch: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)",
"!**/__tests__/**/*.namespace-test.[jt]s?(x)",
"!**/__storybook__/**/*",
],
transform: {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"../../fileTransformer.js",
Expand Down
Loading
Loading