Skip to content

Commit

Permalink
Prod 2790 initialize ant design (#5308)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate authored Sep 20, 2024
1 parent 1b1ab1f commit 9911451
Show file tree
Hide file tree
Showing 21 changed files with 1,841 additions and 135 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"files.associations": {
"*.css": "tailwindcss"
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The types of changes are:

### Developer Experience
- Added performance mark timings to debug logs for fides.js [#5245](https://github.com/ethyca/fides/pull/5245)
- Initialized Ant Design and Tailwindcss in Admin-UI to prepare for Design System migration [#5308](https://github.com/ethyca/fides/pull/5308)

### Fixed
- Fix wording in tooltip for Yotpo Reviews [#5274](https://github.com/ethyca/fides/pull/5274)
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ["next/core-web-vitals"],
extends: ["next/core-web-vitals", "plugin:tailwindcss/recommended"],
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
Expand Down
5 changes: 5 additions & 0 deletions clients/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@ant-design/cssinjs": "^1.21.0",
"@fontsource/inter": "^4.5.15",
"@monaco-editor/react": "^4.6.0",
"@reduxjs/toolkit": "^1.9.3",
Expand All @@ -39,6 +40,7 @@
"cytoscape-klay": "^3.1.4",
"date-fns": "^2.29.3",
"date-fns-tz": "^2.0.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"fides-js": "^0.0.1",
"fidesui": "*",
"file-saver": "^2.0.5",
Expand Down Expand Up @@ -80,6 +82,7 @@
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"autoprefixer": "^10.4.20",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"cypress": "^13.13.0",
Expand All @@ -102,7 +105,9 @@
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^13.2.0",
"openapi-typescript-codegen": "^0.23.0",
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.10",
"typescript": "4.9.5",
"whatwg-fetch": "^3.6.2"
},
Expand Down
6 changes: 6 additions & 0 deletions clients/admin-ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
1 change: 1 addition & 0 deletions clients/admin-ui/src/features/common/TaxonomiesPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const TaxonomiesPicker = ({

{isAdding && (
<Box
// eslint-disable-next-line tailwindcss/no-custom-classname
className="select-wrapper"
position="absolute"
zIndex={10}
Expand Down
13 changes: 13 additions & 0 deletions clients/admin-ui/src/features/common/nav/v2/nav-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ export const NAV_CONFIG: NavConfigGroup[] = [
},
];

if (process.env.NEXT_PUBLIC_APP_ENV === "development") {
NAV_CONFIG.push({
title: "Developer",
routes: [
{
title: "Ant Design POC",
path: routes.ANT_POC_ROUTE,
scopes: [],
},
],
});
}

export type NavGroupChild = {
title: string;
path: string;
Expand Down
2 changes: 2 additions & 0 deletions clients/admin-ui/src/features/common/nav/v2/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ export const MESSAGING_EDIT_ROUTE = "/messaging/[id]";

// OpenID Authentication group
export const OPENID_AUTHENTICATION_ROUTE = "/settings/openid-authentication";

export const ANT_POC_ROUTE = "/ant-poc";
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ export const FidesTableV2 = <T,>({
width="5px"
cursor="col-resize"
userSelect="none"
// eslint-disable-next-line tailwindcss/no-custom-classname
className="resizer"
opacity={0}
backgroundColor={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const EditCategoriesCell = ({ resource }: EditCategoryCellProps) => {

{isAdding && (
<Box
// eslint-disable-next-line tailwindcss/no-custom-classname
className="select-wrapper"
position="absolute"
zIndex={10}
Expand Down
4 changes: 3 additions & 1 deletion clients/admin-ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "@fontsource/inter/400.css";
import "@fontsource/inter/500.css";
import "@fontsource/inter/600.css";
import "@fontsource/inter/700.css";
import "../theme/tailwind.css";

import { FidesUIProvider, Flex } from "fidesui";
import type { AppProps } from "next/app";
Expand All @@ -14,6 +15,7 @@ import { PersistGate } from "redux-persist/integration/react";
import ProtectedRoute from "~/features/auth/ProtectedRoute";
import CommonSubscriptions from "~/features/common/CommonSubscriptions";
import MainSideNav from "~/features/common/nav/v2/MainSideNav";
import { antTheme } from "~/theme/ant";

import store, { persistor } from "../app/store";
import theme from "../theme";
Expand All @@ -35,7 +37,7 @@ const MyApp = ({ Component, pageProps }: AppProps) => (
<SafeHydrate>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<FidesUIProvider theme={theme}>
<FidesUIProvider theme={theme} antTheme={antTheme}>
<DndProvider backend={HTML5Backend}>
{Component === Login || Component === LoginWithOIDC ? (
// Only the login page is accessible while logged out. If there is
Expand Down
45 changes: 45 additions & 0 deletions clients/admin-ui/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { createCache, extractStyle, StyleProvider } from "@ant-design/cssinjs";
import type { DocumentContext } from "next/document";
import Document, { Head, Html, Main, NextScript } from "next/document";
import React from "react";

const MyDocument = () => (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);

// extract and inject antd's first-screen styles into HTML to avoid page flicker.
// see https://ant.design/docs/react/use-with-next#using-pages-router
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
const cache = createCache();
const originalRenderPage = ctx.renderPage;
// eslint-disable-next-line no-param-reassign
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) => (
<StyleProvider cache={cache}>
<App {...props} />
</StyleProvider>
),
});

const initialProps = await Document.getInitialProps(ctx);
const style = extractStyle(cache, true);
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{/* eslint-disable-next-line react/no-danger */}
<style dangerouslySetInnerHTML={{ __html: style }} />
</>
),
};
};

export default MyDocument;
163 changes: 163 additions & 0 deletions clients/admin-ui/src/pages/ant-poc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import {
AntAlert as Alert,
AntButton as Button,
AntCard as Card,
AntCol as Col,
AntLayout as Layout,
AntRow as Row,
AntSelect as Select,
AntSpace as Space,
AntSwitch as Switch,
AntTag as Tag,
AntTooltip as Tooltip,
AntTypography as Typography,
} from "fidesui";
import type { NextPage } from "next";

import FidesLayout from "~/features/common/Layout";

const { Header, Content } = Layout;
const { Title } = Typography;

const options: { label: string; value: string }[] = [];
for (let i = 10; i < 36; i += 1) {
options.push({
label: i.toString(36) + i,
value: i.toString(36) + i,
});
}

const AntPOC: NextPage = () => {
return (
<FidesLayout title="Ant Design Proof of Concept" padded={false}>
<Layout>
<Header>
<Title style={{ color: "#fff", lineHeight: "64px" }}>
Ant Design Proof of Concept
</Title>
</Header>
<Content className="overflow-auto px-10 py-6">
<Row gutter={16}>
<Col span={8}>
<Card title="Button" bordered={false} className="h-full">
<Space direction="vertical">
<Button type="primary">Primary Button</Button>
<Button>Default Button</Button>
<Button type="dashed">Dashed Button</Button>
<Button type="text">Text Button</Button>
<Button type="link">Link Button</Button>
<Button type="primary" loading>
Loading Button
</Button>
<Button type="primary" disabled>
Disabled Button
</Button>
</Space>
</Card>
</Col>
<Col span={8}>
<Card title="Switch" bordered={false} className="h-full">
<Space direction="vertical">
<Switch defaultChecked />
<Switch size="small" defaultChecked />
<Switch loading defaultChecked />
</Space>
</Card>
</Col>
<Col span={8}>
<Card title="Select" bordered={false} className="h-full">
<Space direction="vertical">
<Select
defaultValue="lucy"
className="w-32"
options={[
{ value: "jack", label: "Jack" },
{ value: "lucy", label: "Lucy" },
{ value: "Yiminghe", label: "yiminghe" },
{ value: "disabled", label: "Disabled", disabled: true },
]}
/>
<Select
defaultValue="lucy"
className="w-32"
disabled
options={[{ value: "lucy", label: "Lucy" }]}
/>
<Select
defaultValue="lucy"
className="w-32"
loading
options={[{ value: "lucy", label: "Lucy" }]}
/>
<Select
defaultValue="lucy"
className="w-32"
allowClear
options={[{ value: "lucy", label: "Lucy" }]}
/>
<Select
mode="multiple"
allowClear
className="w-full"
placeholder="Please select"
defaultValue={["a10", "c12"]}
options={options}
/>
<Select
mode="multiple"
disabled
className="w-full"
placeholder="Please select"
defaultValue={["a10", "c12"]}
options={options}
/>
</Space>
</Card>
</Col>
</Row>
<br />
<Row gutter={16}>
<Col span={8}>
<Card title="Tooltip" bordered={false} className="h-full">
<Space direction="vertical">
<Tooltip title="prompt text">
<span>Tooltip will show on mouse enter.</span>
</Tooltip>
</Space>
</Card>
</Col>
<Col span={8}>
<Card title="Alert" bordered={false} className="h-full">
<Space direction="vertical">
<Alert message="Success Tips" type="success" showIcon />
<Alert message="Informational Notes" type="info" showIcon />
<Alert message="Warning" type="warning" showIcon closable />
<Alert message="Error" type="error" showIcon />
</Space>
</Card>
</Col>
<Col span={8}>
<Card title="Tag" bordered={false} className="h-full">
<Space direction="vertical">
<Tag color="magenta">magenta</Tag>
<Tag color="red">red</Tag>
<Tag color="volcano">volcano</Tag>
<Tag color="orange">orange</Tag>
<Tag color="gold">gold</Tag>
<Tag color="lime">lime</Tag>
<Tag color="green">green</Tag>
<Tag color="cyan">cyan</Tag>
<Tag color="blue">blue</Tag>
<Tag color="geekblue">geekblue</Tag>
<Tag color="purple">purple</Tag>
</Space>
</Card>
</Col>
</Row>
</Content>
</Layout>
</FidesLayout>
);
};

export default AntPOC;
1 change: 1 addition & 0 deletions clients/admin-ui/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const Animation = () => {
<motion.svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 64 64"
// eslint-disable-next-line tailwindcss/no-custom-classname
className="item"
width={46}
height={46}
Expand Down
Loading

0 comments on commit 9911451

Please sign in to comment.