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

Design system: Modular CSS support, Color palette, Ant theme update #5453

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The types of changes are:

### Developer Experience
- Added Carbon Icons to FidesUI [#5416](https://github.com/ethyca/fides/pull/5416)
- Apply new color palette as scss module [#5453](https://github.com/ethyca/fides/pull/5453)

## [2.48.2](https://github.com/ethyca/fidesplus/compare/2.48.1...2.48.2)

Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
1 change: 1 addition & 0 deletions clients/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"openapi-typescript-codegen": "^0.23.0",
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"sass": "^1.80.6",
"tailwindcss": "^3.4.10",
"typescript": "4.9.5",
"whatwg-fetch": "^3.6.2"
Expand Down
10 changes: 1 addition & 9 deletions clients/admin-ui/src/features/common/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,9 @@ const SearchBar = ({
onChange={handleSearchChange}
placeholder={placeholder || "Search..."}
prefix={withIcon ? <SearchLineIcon boxSize={4} /> : undefined}
className="border-neutral-2"
{...props}
/>
{onClear ? (
<Button
onClick={onClear}
className="border-neutral-2 bg-[#f5f5f5] hover:!border-neutral-2 hover:!bg-neutral-2"
>
Clear
</Button>
) : null}
{onClear ? <Button onClick={onClear}>Clear</Button> : null}
</Space.Compact>
);
};
Expand Down
1 change: 1 addition & 0 deletions clients/admin-ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "@fontsource/inter/500.css";
import "@fontsource/inter/600.css";
import "@fontsource/inter/700.css";
import "../theme/tailwind.css";
import "../theme/global.scss";

import { FidesUIProvider, Flex } from "fidesui";
import type { AppProps } from "next/app";
Expand Down
76 changes: 46 additions & 30 deletions clients/admin-ui/src/theme/ant.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,65 @@
import { AntThemeConfig } from "fidesui";
import palette from "fidesui/src/palette/palette.module.scss";

/**
* Order of priority for styling
* 1. Ant Design default theme
* 2. FidesUI palette colors
* 3. Ant Design custom theme (this file, which also includes some custom override colors not found in the palette)
* 4. global CSS variables (as a last resort when styling Ant components, should rely on the palette vars)
* 5. tailwindcss (for layout and spacing only)
* 6. SCSS modules (for custom-component-specific styles)
*/

export const antTheme: AntThemeConfig = {
cssVar: true,
token: {
colorPrimary: "#2b2e35",
colorInfo: "#2b2e35",
colorSuccess: "#5a9a68",
colorWarning: "#e59d47",
colorError: "#d9534f",
colorLink: "#2272ce",
colorBgBase: "#ffffff",
colorPrimary: palette.FIDESUI_MINOS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean using the palette for overides.

colorInfo: palette.FIDESUI_MINOS,
colorSuccess: palette.FIDESUI_SUCCESS,
colorWarning: palette.FIDESUI_WARNING,
colorError: palette.FIDESUI_ERROR,
colorLink: palette.LINK,
colorBgBase: palette.FIDESUI_FULL_WHITE,
borderRadius: 4,
wireframe: true,
colorTextBase: "#2b2e35",
colorErrorBg: "#ffdcd6",
colorErrorBorder: "#f2aca5",
colorWarningBg: "#ffecc9",
colorWarningBorder: "#ffdba1",
colorSuccessBorder: "#5a9a68",
colorPrimaryBg: "#e3e0d9",
colorBorder: "#e6e6e8",
colorTextBase: palette.FIDESUI_MINOS,
colorErrorBg: "#ffdcd6", // custom override
colorErrorBorder: "#f2aca5", // custom override
colorWarningBg: "#ffecc9", // custom override
colorWarningBorder: "#ffdba1", // custom override
colorSuccessBorder: palette.FIDESUI_SUCCESS,
colorPrimaryBg: palette.FIDESUI_SANDSTONE,
colorBorder: palette.FIDESUI_NEUTRAL_100,
zIndexPopupBase: 1500, // supersede Chakra's modal z-index
gilluminate marked this conversation as resolved.
Show resolved Hide resolved
},
components: {
Alert: {
colorInfoBg: palette.FIDESUI_FULL_WHITE,
colorInfo: palette.FIDESUI_NEUTRAL_500,
},
Button: {
primaryShadow: "",
defaultShadow: "",
dangerShadow: "",
defaultBg: "#ffffff",
primaryShadow: undefined,
defaultShadow: undefined,
dangerShadow: undefined,
defaultBg: palette.FIDESUI_FULL_WHITE,
},
Input: {
colorBgContainer: palette.FIDESUI_FULL_WHITE,
},
Layout: {
bodyBg: "rgb(250,250,250)",
bodyBg: palette.FIDESUI_NEUTRAL_50,
},
Alert: {
colorInfoBg: "rgb(255,255,255)",
colorInfo: "rgb(147,150,154)",
Select: {
optionActiveBg: palette.FIDESUI_SANDSTONE,
},
Tooltip: {
colorBgSpotlight: "rgb(43,46,53)",
colorText: "rgb(250,250,250)",
colorTextLightSolid: "rgb(250,250,250)",
colorBgSpotlight: palette.FIDESUI_MINOS,
colorText: palette.FIDESUI_NEUTRAL_50,
colorTextLightSolid: palette.FIDESUI_NEUTRAL_50,
},
Transfer: {
controlItemBgActiveHover: "rgb(206,202,194)",
},
Input: {
colorBgContainer: "#ffffff",
controlItemBgActiveHover: palette.FIDESUI_SANDSTONE,
},
},
};
24 changes: 24 additions & 0 deletions clients/admin-ui/src/theme/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "fidesui/src/palette/palette.module.scss";

/**
* Adds the color variables from the palette to the root element
*/
:root {
@each $color, $value in $colors {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful to have every color as a css variable.

#{getPrefixedColor("--fidesui-", unquote($color))}: $value;
}
}

/**
* Styles for Ant components where tokens are not available
*/
.ant-input-compact-item.ant-input-css-var {
--ant-color-border: var(--fidesui-neutral-200);
--ant-input-hover-border-color: var(--fidesui-neutral-200);
}
.ant-btn-compact-item.ant-btn-variant-outlined {
--ant-button-default-border-color: var(--fidesui-neutral-200);
--ant-button-default-hover-border-color: var(--fidesui-neutral-200);
--ant-button-default-hover-bg: var(--fidesui-neutral-200);
--ant-button-default-bg: var(--fidesui-neutral-50);
}
2 changes: 0 additions & 2 deletions clients/admin-ui/src/theme/tailwind.css
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
@tailwind base;
@tailwind components;
gilluminate marked this conversation as resolved.
Show resolved Hide resolved
@tailwind utilities;
3 changes: 2 additions & 1 deletion clients/fidesui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"peerDevDependencies": {
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1"
"@types/react-dom": "^18.3.1",
"sass": "^1.80.6"
},
"devDependencies": {
"@types/react": "^18.3.2",
Expand Down
85 changes: 85 additions & 0 deletions clients/fidesui/src/palette/palette.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
$colors: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all the different libraries, utilities, etc having a single source for colors is going to be much simpler. This is great, and the added TS export of colors is just chef kiss.

"full-black": #000000,
"full-white": #ffffff,

// Neutral //
"neutral-50": #fafafa,
"neutral-75": #f5f5f5,
"neutral-100": #e6e6e8,
"neutral-200": #d1d2d4,
"neutral-300": #bcbec1,
"neutral-400": #a8aaad,
"neutral-500": #93969a,
"neutral-600": #7e8185,
"neutral-700": #696c71,
"neutral-800": #53575c,
"neutral-900": #2b2e35,

// Brand //
"corinth": #fafafa,
"bg-corinth": #fafafa,
"limestone": #f1efee,
"minos": #2b2e35,
"bg-minos": #4f525b,
"terracotta": #b9704b,
"bg-terracotta": #f1b193,
"olive": #999b83,
"bg-olive": #d4d5c8,
"marble": #cdd2d3,
"bg-marble": #e1e5e6,
"sandstone": #cecac2,
"bg-sandstone": #e3e0d9,
"nectar": #f0ebc1,
"bg-nectar": #f5f2d7,

// Functional //
"error": #d9534f,
"bg-error": #f7c2c2,
"warning": #e59d47,
"bg-warning": #fbddb5,
"bg-caution": #f6e3a4,
"success": #5a9a68,
"bg-success": #c3e6b2,
"info": #4a90e2,
"bg-info": #a5d6f3,
"alert": #7b4ea9,
"bg-alert": #d9b0d7,

// Type //
"error-text": #d32f2f,
"success-text": #388e3c,
"link": #2272ce,
);

@function getPrefixedColor($prefix, $name) {
@return $prefix + $name;
}

@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);

@if $index {
@return str-slice($string, 1, $index - 1) + $replace +
str-replace(
str-slice($string, $index + str-length($search)),
$search,
$replace
);
}

@return $string;
}

/**
* exports a typescript object with the colors
* @example
* ```tsx
* import { palette } from 'fidesui/src/palette/palette.module.scss';
* console.log(palette.FIDESUI_MINOS);
* ```
*/
:export {
@each $color, $value in $colors {
#{to-upper-case(getPrefixedColor("FIDESUI_", str-replace(unquote($color), '-', '_')))}: $value;
}
}
4 changes: 4 additions & 0 deletions clients/fidesui/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.scss" {
const palette: { readonly [key: string]: string };
export default palette;
}
Loading
Loading