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: moving Flexgrid and ThemeProvider to ui-system #353

Merged
merged 12 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 7 additions & 2 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ 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
- uses: mshick/add-pr-comment@v2
if: always()
with:
refresh-message-position: true
message-path: packages/ui-system/tmp/pr-stats.md

inspect:
if: ${{ always() }}
Expand Down
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"
}
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": "vite build -c vite.components.config.js",
"build:system": "vite build -c vite.system.config.js",
"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
2 changes: 1 addition & 1 deletion packages/bundlesize/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"include": ["ui-components/src", "ui-system/src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
6 changes: 5 additions & 1 deletion packages/bundlesize/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["./vite.config.ts", "./vitest.setup.ts"]
"include": [
"./vite.components.config.ts",
"./vite.system.config.ts",
"./vitest.setup.ts"
]
}
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>
19 changes: 19 additions & 0 deletions packages/bundlesize/ui-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/ui-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/ui-system/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/** @type {import('vite').UserConfig} */

import { resolve } from "node:path";

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

Expand Down Expand Up @@ -25,7 +29,11 @@ export default defineConfig({
},
},
build: {
outDir: "dist/system",
rollupOptions: {
input: {
index: resolve(__dirname, "ui-system", "index.html"),
},
output: {
assetFileNames: "assets/style[extname]",
entryFileNames: "assets/[name].js",
Expand Down
57 changes: 57 additions & 0 deletions packages/bundlesize/vite.system.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** @type {import('vite').UserConfig} */

import { resolve } from "node:path";

import fs from "fs-extra";
import { defineConfig } 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
},
},
build: {
outDir: "dist/components",
emptyOutDir: false,
rollupOptions: {
input: {
index: resolve(__dirname, "ui-components", "index.html"),
},
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: [],
});
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 {
aversini marked this conversation as resolved.
Show resolved Hide resolved
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
Loading
Loading