Skip to content

Commit

Permalink
Merge pull request #353 from aversini/feat-moving-flexbox-and-themepr…
Browse files Browse the repository at this point in the history
…ovider-to-ui-system

feat: moving Flexgrid and ThemeProvider to ui-system
  • Loading branch information
aversini authored Feb 26, 2024
2 parents ae71ac8 + df9d416 commit 56f7ec5
Show file tree
Hide file tree
Showing 63 changed files with 827 additions and 489 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ jobs:
corepack enable
pnpm install
npx lerna run build --ignore @versini/documentation
npx lerna run stats:pr --scope=@versini/ui-components
npx lerna run stats:report --scope=@versini/ui-components
npx lerna run stats:pr
npx lerna run stats:report
- uses: mshick/add-pr-comment@v2
if: always()
with:
refresh-message-position: true
message-path: packages/ui-components/tmp/pr-stats.md
message-path: |
packages/ui-components/tmp/pr-stats.md
packages/ui-system/tmp/pr-stats.md
inspect:
if: ${{ always() }}
Expand Down Expand Up @@ -87,6 +89,6 @@ jobs:
corepack enable
pnpm install
npx lerna run build --ignore @versini/documentation
npx lerna run stats:release --scope=@versini/ui-components
npx lerna run stats:release
- name: Commit Release Stats
uses: stefanzweifel/git-auto-commit-action@v5
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"packages/eslint-plugin-client": "1.0.1",
"packages/ui-components": "5.0.0",
"packages/ui-hooks": "2.2.0"
"packages/ui-hooks": "2.2.0",
"packages/ui-system": "0.0.0"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions packages/bundlesize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
"private": true,
"scripts": {
"clean": "rimraf dist",
"build:js": "vite build",
"build": "npm-run-all --serial clean build:js",
"build:components": "cross-env-shell VITE_UI_TARGET=components vite build",
"build:system": "cross-env-shell VITE_UI_TARGET=system vite build",
"build": "npm-run-all --serial clean build:components build:system",
"test": "echo \"WARNING: no test specified\" && exit 0",
"test:coverage": "echo \"WARNING: no test specified\" && exit 0"
},
"dependencies": {
"@versini/ui-components": "workspace:../ui-components",
"@versini/ui-hooks": "workspace:../ui-hooks",
"@versini/ui-system": "workspace:../ui-system",
"react": "18.2.0",
"react-dom": "18.2.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="src/main.tsx"></script>
</body>

</html>
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions packages/bundlesize/src/system/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#64748b">
<link rel="icon" type="image/png" href="/favicon.ico?v=2">

<title>UI System</title>

</head>

<body>
<div id="root"></div>
<script type="module" src="src/main.tsx"></script>
</body>

</html>
18 changes: 18 additions & 0 deletions packages/bundlesize/src/system/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "@versini/ui-system/dist/style.css";

import * as System from "@versini/ui-system";
import React from "react";
import ReactDOM from "react-dom/client";

Object.keys(System).forEach(() => {
/**
* This is simply to loop through all system components
* and trick rollup into bundling them (instead of
* simply tree-shaking anything that is imported but
* not used...)
*/
});

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>hello</React.StrictMode>,
);
1 change: 1 addition & 0 deletions packages/bundlesize/src/system/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
91 changes: 53 additions & 38 deletions packages/bundlesize/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
/** @type {import('vite').UserConfig} */

import { resolve } from "node:path";

import fs from "fs-extra";
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";

const VENDOR_CHUNK = "vendorChunk";
const packageJson = fs.readJSONSync("../ui-components/package.json");
const prodDependencies = Object.keys(packageJson.dependencies).filter(
(dependency) =>
dependency !== "react" &&
dependency !== "react-dom" &&
dependency !== "react/jsx-runtime" &&
dependency !== "react-dom/server" &&
dependency !== "tailwindcss",
);
prodDependencies.push(
"react-dom",
"react-dom/server",
"react",
"react/jsx-runtime",
);

export default defineConfig({
esbuild: {
supported: {
"top-level-await": true, //browsers can handle top-level-await features
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const packageJson = fs.readJSONSync(
`../ui-${env.VITE_UI_TARGET}/package.json`,
);
const prodDependencies = Object.keys(packageJson.dependencies).filter(
(dependency) =>
dependency !== "react" &&
dependency !== "react-dom" &&
dependency !== "react/jsx-runtime" &&
dependency !== "react-dom/server" &&
dependency !== "tailwindcss",
);
prodDependencies.push(
"react-dom",
"react-dom/server",
"react",
"react/jsx-runtime",
);

return {
esbuild: {
supported: {
"top-level-await": true, //browsers can handle top-level-await features
},
},
},
build: {
rollupOptions: {
output: {
assetFileNames: "assets/style[extname]",
entryFileNames: "assets/[name].js",
/**
* Manually creating chunks for prod dependencies.
*/
manualChunks: {
[VENDOR_CHUNK]: prodDependencies,
build: {
outDir: `dist/${env.VITE_UI_TARGET}`,
emptyOutDir: false,
rollupOptions: {
input: {
index: resolve(__dirname, "src", env.VITE_UI_TARGET, "index.html"),
},
chunkFileNames(chunkInfo) {
if (chunkInfo.name.includes(VENDOR_CHUNK)) {
return "assets/vendor.js";
}
return "[name]-[hash].js";
output: {
assetFileNames: "assets/style[extname]",
entryFileNames: "assets/[name].js",
/**
* Manually creating chunks for prod dependencies.
*/
manualChunks: {
[VENDOR_CHUNK]: prodDependencies,
},
chunkFileNames(chunkInfo) {
if (chunkInfo.name.includes(VENDOR_CHUNK)) {
return "assets/vendor.js";
}
return "[name]-[hash].js";
},
},
},
},
},
plugins: [],
plugins: [],
};
});
9 changes: 2 additions & 7 deletions packages/documentation/.ladle/components.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import "./styles.css";

import {
ButtonIcon,
Flexgrid,
FlexgridItem,
Footer,
IconGitHub,
} from "@versini/ui-components";
import { ButtonIcon, Footer, IconGitHub } from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

import type { GlobalProvider } from "@ladle/react";
import clsx from "clsx";
Expand Down
1 change: 1 addition & 0 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"@tailwindcss/typography": "0.5.10",
"@versini/ui-components": "workspace:../ui-components",
"@versini/ui-system": "workspace:../ui-system",
"clsx": "2.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/documentation/src/Form/TextArea.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Story } from "@ladle/react";
import { Button, TextArea, ThemeProvider } from "@versini/ui-components";
import { Button, TextArea } from "@versini/ui-components";
import { ThemeProvider } from "@versini/ui-system";

const customTheme = {
"--av-copy-light": "#403c3a",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
} from "@versini/ui-components";
import { ButtonIcon, IconNext } from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

export default {
title: "Getting started",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
IconPrevious,
} from "@versini/ui-components";
import { ButtonIcon, IconNext, IconPrevious } from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

export default {
title: "Getting Started",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
IconPrevious,
} from "@versini/ui-components";
import { ButtonIcon, IconNext, IconPrevious } from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

export default {
title: "Getting Started",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import {
Button,
ButtonIcon,
Card,
Flexgrid,
FlexgridItem,
IconNext,
IconPrevious,
} from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

<Meta title="Getting started/Usage" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconPrevious,
} from "@versini/ui-components";
import { ButtonIcon, IconPrevious } from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

export default {
title: "Getting Started",
Expand Down
3 changes: 1 addition & 2 deletions packages/documentation/src/System/Flexgrid.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Story } from "@ladle/react";
import {
Card,
Flexgrid,
FlexgridItem,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
} from "@versini/ui-components";
import { Flexgrid, FlexgridItem } from "@versini/ui-system";

export default {
title: "System/Flexgrid",
Expand Down
13 changes: 8 additions & 5 deletions packages/documentation/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/** @type {import('tailwindcss').Config} */

import { twPlugin } from "@versini/ui-components/dist/utilities";
import { twPlugin as componentsPlugin } from "@versini/ui-components/dist/utilities";
import { twPlugin as systemPlugin } from "@versini/ui-system/dist/utilities";

export default twPlugin.merge({
darkMode: "selector",
content: ["./src/**/*.{js,ts,jsx,tsx}", "./.ladle/**/*.tsx"],
});
export default systemPlugin.merge(
componentsPlugin.merge({
darkMode: "selector",
content: ["./src/**/*.{js,ts,jsx,tsx}", "./.ladle/**/*.tsx"],
}),
);
3 changes: 2 additions & 1 deletion packages/ui-components/bundlesize.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const bundlePath = "../bundlesize/dist";
const bundlePath = "../bundlesize/dist/components";
export default {
report: {
header: "## Bundle Size (components)",
previous: "stats/stats.json",
current: "tmp/stats.json",
},
Expand Down
6 changes: 0 additions & 6 deletions packages/ui-components/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { Button } from "./Button/Button";
import { ButtonIcon } from "./Button/ButtonIcon";
import { ButtonLink } from "./Button/ButtonLink";
import { Card } from "./Card/Card";
import { Flexgrid } from "./Flexgrid/Flexgrid";
import { FlexgridItem } from "./Flexgrid/FlexgridItem";
import { Footer } from "./Footer/Footer";
import { Header } from "./Header/Header";
import { IconBack } from "./Icons/IconBack";
Expand Down Expand Up @@ -50,7 +48,6 @@ import {
import { TextArea } from "./TextArea/TextArea";
import { TextInput } from "./TextInput/TextInput";
import { TextInputMask } from "./TextInput/TextInputMask";
import { ThemeProvider } from "./ThemeProvider/ThemeProvider";
import { Toggle } from "./Toggle/Toggle";

export {
Expand All @@ -60,8 +57,6 @@ export {
ButtonIcon,
ButtonLink,
Card,
Flexgrid,
FlexgridItem,
Footer,
Header,
IconBack,
Expand Down Expand Up @@ -97,7 +92,6 @@ export {
TextArea,
TextInput,
TextInputMask,
ThemeProvider,
Toggle,
useLocalStorage,
useMergeRefs,
Expand Down
6 changes: 3 additions & 3 deletions packages/ui-components/src/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { customCSS } from "../lib/customCSS";
import { twPlugin } from "../lib/tailwindPlugin";
import { tokens } from "../lib/tokens";
import { customCSS } from "../../../lib/customCSS";
import { twPlugin } from "../../../lib/tailwindPlugin";
import { tokens } from "../../../lib/tokens";

export { customCSS, tokens, twPlugin };
Loading

0 comments on commit 56f7ec5

Please sign in to comment.