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

Admin UI - Tokens #4302

Open
wants to merge 67 commits into
base: feat/new-admin-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
33b23d6
wip: create Avatar component
adrians5j Sep 3, 2024
348b74f
Merge remote-tracking branch 'refs/remotes/origin/feat/new-admin-ui' …
adrians5j Sep 5, 2024
936f83e
wip: create Avatar component
adrians5j Sep 5, 2024
0abec5f
fix: remove needless `cn` usage
adrians5j Sep 5, 2024
1a550cb
wip: create Avatar component
adrians5j Sep 5, 2024
a3ff702
wip: create Avatar component
adrians5j Sep 5, 2024
d89b81e
wip: create Avatar component
adrians5j Sep 5, 2024
83537b8
Merge branch 'feat/new-admin-ui' into feat/avatar
adrians5j Sep 5, 2024
04e7e94
wip: create Avatar component
adrians5j Sep 9, 2024
3a6898a
wip: create Avatar component
adrians5j Sep 9, 2024
83ad097
wip: create Avatar component
adrians5j Sep 9, 2024
5dd474b
Merge remote-tracking branch 'refs/remotes/origin/feat/new-admin-ui' …
adrians5j Sep 10, 2024
a95a914
fix: update dependencies
adrians5j Sep 10, 2024
5f002a4
wip: create Avatar component
adrians5j Sep 10, 2024
d8f6de5
chore: run prettier
adrians5j Oct 1, 2024
9a432c8
wip: remove avatar-related changes
adrians5j Oct 2, 2024
aaffef7
wip: remove avatar-related changes
adrians5j Oct 2, 2024
63873db
wip: remove avatar-related changes
adrians5j Oct 2, 2024
2c993d6
wip: remove avatar-related changes
adrians5j Oct 2, 2024
ed4638d
wip: remove avatar-related changes
adrians5j Oct 2, 2024
17e8f8d
wip: remove avatar-related changes
adrians5j Oct 2, 2024
e675a7a
wip: remove avatar-related changes
adrians5j Oct 2, 2024
9fb83be
wip
adrians5j Oct 22, 2024
24ce7d1
wip - colors placeholders
adrians5j Oct 22, 2024
a63753f
wip
adrians5j Oct 24, 2024
cd42084
wip
adrians5j Oct 24, 2024
82b5481
wip
adrians5j Oct 24, 2024
c9352e8
wip
adrians5j Oct 24, 2024
2b284e5
wip
adrians5j Oct 24, 2024
5b802ae
wip
adrians5j Oct 24, 2024
2fe7a33
wip
adrians5j Oct 24, 2024
c89186f
wip
adrians5j Oct 24, 2024
b7a3462
wip
adrians5j Oct 24, 2024
0523b82
wip
adrians5j Oct 28, 2024
61bce7b
wip
adrians5j Oct 28, 2024
0320857
wip
adrians5j Oct 28, 2024
451188a
wip
adrians5j Oct 28, 2024
0bc0441
wip
adrians5j Oct 28, 2024
366308e
wip
adrians5j Oct 28, 2024
2cc9434
wip
adrians5j Oct 28, 2024
6fa6ed4
wip
adrians5j Oct 28, 2024
5261222
wip
adrians5j Oct 28, 2024
c5e6486
wip
adrians5j Oct 28, 2024
08d10d0
wip
adrians5j Oct 28, 2024
f5795d9
wip
adrians5j Oct 28, 2024
ba2ff84
wip
adrians5j Oct 28, 2024
4051407
Merge branch 'feat/new-admin-ui' into feat/tokens
adrians5j Oct 28, 2024
b53d791
wip
adrians5j Oct 28, 2024
8b04ace
wip
adrians5j Oct 28, 2024
86a1579
wip
adrians5j Oct 28, 2024
50a6ffb
wip
adrians5j Oct 29, 2024
15dd5f0
Merge remote-tracking branch 'origin/feat/tokens' into feat/tokens
adrians5j Oct 29, 2024
e400c74
wip
adrians5j Oct 29, 2024
3afc7b3
wip
adrians5j Oct 29, 2024
369671e
wip
adrians5j Oct 29, 2024
bcd1d5a
wip
adrians5j Oct 29, 2024
dd15b89
wip
adrians5j Oct 29, 2024
3d6973f
wip
adrians5j Oct 29, 2024
99d6dab
wip
adrians5j Oct 29, 2024
e3d6535
wip
adrians5j Oct 29, 2024
044c9e7
wip
adrians5j Oct 31, 2024
1e88e44
wip
adrians5j Oct 31, 2024
2576141
wip
adrians5j Oct 31, 2024
ea3b6ed
wip
adrians5j Oct 31, 2024
2e844f4
wip
adrians5j Oct 31, 2024
5626e88
wip
adrians5j Oct 31, 2024
b34dca6
wip
adrians5j Oct 31, 2024
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ schema.graphql
lerna.json
.stormTests
*storybook.log
.normalizedFigmaExport.json

# TODO remove after moving traffic splitting config to WPC
gateway.*.json
Expand Down
87 changes: 4 additions & 83 deletions apps/admin/src/App.scss
Original file line number Diff line number Diff line change
@@ -1,88 +1,9 @@
// OLD
// OLD - Will probably be removed.
@import "~@webiny/app-serverless-cms/styles.scss";

// NEW
// Base styles.
@import "~@webiny/admin-ui/styles.scss";

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap");

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 47.4% 11.2%;

--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--popover: 0 0% 100%;
--popover-foreground: 222.2 47.4% 11.2%;

--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;

--card: 0 0% 100%;
--card-foreground: 222.2 47.4% 11.2%;

--primary: 14.5 95.6% 55.9%;
--primary-foreground: 210 40% 98%;

--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;

--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive: 0 100% 50%;
--destructive-foreground: 210 40% 98%;

--ring: 215 20.2% 65.1%;

--radius: 8px;

--font-sans: "Inter", "Source Sans Pro", "Open Sans", sans-serif;
}

.dark {
--background: 224 71% 4%;
--foreground: 213 31% 91%;

--muted: 223 47% 11%;
--muted-foreground: 215.4 16.3% 56.9%;

--accent: 216 34% 17%;
--accent-foreground: 210 40% 98%;

--popover: 224 71% 4%;
--popover-foreground: 215 20.2% 65.1%;

--border: 216 34% 17%;
--input: 216 34% 17%;

--card: 224 71% 4%;
--card-foreground: 213 31% 91%;

--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 1.2%;

--secondary: 222.2 47.4% 11.2%;
--secondary-foreground: 210 40% 98%;

--destructive: 0 63% 31%;
--destructive-foreground: 210 40% 98%;

--ring: 216 34% 17%;

--radius: 8px;
}
}

@layer base {
* {
@apply border-border;
}

body {
@apply bg-background text-foreground;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to define the CSS variable in this file and admin-ui/src/styles.scss?

Also, is this the correct place to define the font family import? I would keep this together with the CSS variable definition.

Both of these might come from the POC phase. Shall we discuss it now? I'm happy to talk about it.

Copy link
Member Author

@adrians5j adrians5j Oct 30, 2024

Choose a reason for hiding this comment

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

Sounds reasonable.

Why do we need a copy of everything in App.scss when we already have it in admin-ui package? And why don't we abstract the font import from users and have it in single styles.scss?

It's basically because of real Webiny projects and being in sync with the code we'll be shipping.

In real projects, users will need to have the ability to customize the theme, and because of that, this is how their App.scss file will look like. Basically:

  1. all of the CSS vars are listed in the file
  2. the default font import statement is here as well, just so they can remove it and import their own font (no point in loading our default font if they will be using their own). That's why we don't have this in our styles.scss.

Note

I see I forgot to update packages/cwp-template-aws/template/common/apps/admin/src/App.scss, I'll do it during the day.

So, basically, all of this was just to have our App.scss and users' App.scss in sync.

But.... all that being said... maybe we could rethink this a bit. Maybe we could actually not-have a bunch of CSS vars and font import by default in users' projects, but maybe we ship an SCSS file that's imported in App.scss. And then, if users want to customize things, they remove the default theme import, and paste all of the CSS vars and a font import statement (we'd have this documented) and then they proceed to tweak things.

So something like:

// apps/admin/src/App.scss
@import "~@webiny/admin-ui/styles.scss";

// To customize the theme, remove the following line and paste the code from https://docs.webiny.com/xyz
@import "~@webiny/admin-ui/theme.scss";

BTW, now that we've discussed this, I think this way of doing things might also resolve an issue where we have a bunch of TW vars duplicated, which is visible in console:
image

This just crossed my mind while I was writing this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of having a separate file for theming 🎉

Regarding the duplicated Tailwind CSS variables: I’m not sure; I would expect that some override would be the default behavior of Tailwind. Also, while checking Tailwind themes, I noticed the same situation.

I would keep this as low priority if you agree,

Copy link
Member Author

@adrians5j adrians5j Oct 31, 2024

Choose a reason for hiding this comment

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

This is done as well. I also noted the low priority thingie here.

font-feature-settings: "rlig" 1, "calt" 1;
}
}
// The default theme. Learn more: https://webiny.link/admin-themes.
@import "~@webiny/admin-ui/theme.scss";
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
"webiny": "./node_modules/.bin/webiny",
"wby": "./node_modules/.bin/wby",
"webiny-admin-storybook": "cd packages/admin-ui && yarn storybook",
"webiny-admin-build-storybook": "cd packages/admin-ui && cross-env OUT=../../netlify-static yarn build-storybook"
"webiny-admin-build-storybook": "cd packages/admin-ui && cross-env OUT=../../netlify-static yarn build-storybook",
"webiny-admin-import-from-figma": "node packages/admin-ui/scripts/importFromFigma.js"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Preview } from "@storybook/react";

import "../src/styles.scss";
import "../src/theme.scss";

const preview: Preview = {
parameters: {
Expand Down
24 changes: 24 additions & 0 deletions packages/admin-ui/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Overview
This document covers different aspects of the development process for the `@webiny/admin-ui` package.

## Tailwind CSS
Webiny's Admin app uses Tailwind CSS for styling.

### Tailwind Configuration
Tailwind CSS is configured as usual, via the [`tailwind.config.js`](./tailwind.config.js) file. Among other things, this file defines the default Webiny theme, which is based on Webiny's design system. More on this in the next section.

### Default Theme
One of the main things we define via the [`tailwind.config.js`](./tailwind.config.js) file is the default theme, which is based on Webiny's design system, and which can be found in this [Figma file](https://www.figma.com/file/f0QUDWX37Kt5X53eltTRiT/Webiny-Design-System?type=design&node-id=127-26352&mode=design&t=nhoOU7NamjWvImoW-0).

But, do note that all the default theme-values are not actually defined in the `tailwind.config.js` file, but rather in the `tailwind.config.theme.js` file, which is a file that is generated from a Figma export (more on this in the next section).

### Figma To Code
Since manually transferring values from the mentioned Figma file into code has shown to be a very cumbersome process, we've created a script that basically takes a Figma export and generates all the necessary Tailwind CSS configuration. Note that when we say "Figma export", we basically mean an export of Alias tokens, created by this [Export/Import Variables](https://www.figma.com/community/plugin/1256972111705530093/export-import-variables) plugin.

Once the export is downloaded, we place it in `packages/admin-ui/scripts/importFromFigma/exports/Alias tokens.json`, and then we run the following command from project root:

```bash
yarn webiny-admin-import-from-figma
```

This will generate a new `tailwind.config.theme.js` file, which will contain all the necessary Tailwind CSS configuration. On top of that, it will also generate a `src/styles.scss` file, which contains actual values for CSS variables that are referenced in the `tailwind.config.theme.js` file.
25 changes: 10 additions & 15 deletions packages/admin-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# @webiny/admin-ui
[![](https://img.shields.io/npm/dw/@webiny/admin-ui.svg)](https://www.npmjs.com/package/@webiny/admin-ui)
[![](https://img.shields.io/npm/v/@webiny/admin-ui.svg)](https://www.npmjs.com/package/@webiny/admin-ui)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

## Install
```
npm install --save @webiny/admin-ui
```

Or if you prefer yarn:
```
yarn add @webiny/admin-ui
```
# `@webiny/admin-ui`

This package contains React components and styles for Webiny's Admin app.

> [!NOTE]
> This package is included in every Webiny project by default, and it's not meant to be used as a standalone package.




2 changes: 2 additions & 0 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
"@types/react": "18.2.79",
"@webiny/cli": "0.0.0",
"@webiny/project-utils": "0.0.0",
"chalk": "^4.1.0",
"css-loader": "^6.10.0",
"file-loader": "6.2.0",
"postcss-loader": "^6.2.1",
"prettier": "^2.8.3",
"rimraf": "^5.0.5",
"sass": "1.44.0",
"storybook": "7.6.20",
Expand Down
53 changes: 53 additions & 0 deletions packages/admin-ui/scripts/importFromFigma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const fs = require("fs");
const { green } = require("chalk");
const path = require("path");
const aliasTokensExport = require("./importFromFigma/exports/Alias tokens.json");
const { normalizeFigmaExport } = require("./importFromFigma/normalizeFigmaExport");
const { createTailwindConfigTheme } = require("./importFromFigma/createTailwindConfigTheme");
const { createThemeScss } = require("./importFromFigma/createThemeScss");
const { formatCode } = require("./importFromFigma/formatCode");

const saveFileAndFormat = async (filePath, content) => {
fs.writeFileSync(filePath, content);
await formatCode(filePath);
};

(async () => {
const normalizedFigmaExport = normalizeFigmaExport(aliasTokensExport);
const tailwindConfigTheme = createTailwindConfigTheme(normalizedFigmaExport);
const stylesScss = createThemeScss(normalizedFigmaExport);

const paths = {
cwd: process.cwd(),
normalizedFigmaExport: path.join(__dirname, "../.normalizedFigmaExport.json"),
createTailwindConfigTheme: path.join(__dirname, "../tailwind.config.theme.js"),
stylesScss: path.join(__dirname, "../src/theme.scss")
};

console.log("Storing...");
console.log(
`‣ normalized Figma export (${green(
path.relative(paths.cwd, paths.normalizedFigmaExport)
)}).`
);
console.log(
`‣ Tailwind config theme (${green(
path.relative(paths.cwd, paths.createTailwindConfigTheme)
)}).`
);
console.log(`‣ styles.scss (${green(path.relative(paths.cwd, paths.stylesScss))}).`);

await saveFileAndFormat(
paths.normalizedFigmaExport,
JSON.stringify(normalizedFigmaExport, null, 2)
);

await saveFileAndFormat(
paths.createTailwindConfigTheme,
`module.exports = ${JSON.stringify(tailwindConfigTheme, null, 2)};`
);

await saveFileAndFormat(paths.stylesScss, stylesScss);

console.log("Done.");
})();
Loading
Loading