@lgsm/modules 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/assets/index.css +1 -0
- package/dist/assets/index2.css +1 -0
- package/dist/assets/index3.css +1 -0
- package/dist/clsx-OuTLNxxd.js +16 -0
- package/dist/components/MyButton/index.d.ts +7 -0
- package/dist/components/MyButton/index.js +27 -0
- package/dist/components/MyCounter/index.d.ts +8 -0
- package/dist/components/MyCounter/index.js +54 -0
- package/dist/components/MyTitle/index.d.ts +6 -0
- package/dist/components/MyTitle/index.js +22 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +8 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# react-vite-component-template
|
|
2
|
+
|
|
3
|
+
Template for building a **React component library**, with **Vite**, **TypeScript** and **Storybook**.
|
|
4
|
+
|
|
5
|
+
Check my post about this repository [here](https://victorlillo.dev/blog/react-typescript-vite-component-library).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- โ๏ธ **React** component library with **TypeScript**.
|
|
10
|
+
|
|
11
|
+
- ๐๏ธ **Vite** as development environment.
|
|
12
|
+
|
|
13
|
+
- ๐ณ **Tree shaking**, for not distributing dead-code.
|
|
14
|
+
|
|
15
|
+
- ๐ **Storybook** for live viewing the components.
|
|
16
|
+
|
|
17
|
+
- ๐จ **PostCSS** for processing our CSS.
|
|
18
|
+
|
|
19
|
+
- ๐๏ธ **CSS Modules** in development, compiled CSS for production builds.
|
|
20
|
+
|
|
21
|
+
- ๐งช Testing with **Vitest** and **React Testing Library**.
|
|
22
|
+
|
|
23
|
+
- โ
Code quality tools with **ESLint**, **Prettier** and **Stylelint**.
|
|
24
|
+
|
|
25
|
+
## ๐ค Scripts
|
|
26
|
+
|
|
27
|
+
| Script | Function |
|
|
28
|
+
| :---------------: | ---------------------------------------------------------------------------------- |
|
|
29
|
+
| `build` | Build the `dist`, with types declarations, after checking types with TypeScript. |
|
|
30
|
+
| `lint` | Lint the project with **Eslint**. |
|
|
31
|
+
| `lint:fix` | Lint and fix the project with **Eslint**. |
|
|
32
|
+
| `format` | Check the project format with **Prettier**. |
|
|
33
|
+
| `format:fix` | Format the project code with **Prettier**. |
|
|
34
|
+
| `stylelint` | Lint the styles code with **Stylelint**. |
|
|
35
|
+
| `stylelint:fix` | Lint and fix the styles code with **Stylelint**. |
|
|
36
|
+
| `storybook` | Start a Storybook development server. |
|
|
37
|
+
| `build-storybook` | Build the Storybook `dist`. |
|
|
38
|
+
| `test` | Run the tests with **Vitest** using `jsdom` and starts a **Vitest UI** dev server. |
|
|
39
|
+
| `coverage` | Generate a coverage report, with **v8**. |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._title_izbg1_1{--color: black;color:var(--color)}._title--primary_izbg1_13{--color: crimson}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_rjlrw_1{text-align:center;font-family:system-ui}._text_rjlrw_11{font-size:1.5rem;margin-bottom:10px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._button_31ovf_1{--bg-color: none;background-color:var(--bg-color);border-radius:6px}._button--primary_31ovf_15{--bg-color: crimson;-webkit-backdrop-filter:sepia(90%);backdrop-filter:sepia(90%)}._button--small_31ovf_27{font-size:1rem;padding:.4rem .6rem}._button--medium_31ovf_37{font-size:1.2rem;padding:.6rem .8rem}._button--large_31ovf_47{font-size:1.4rem;padding:.8rem 1rem}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function a(r) {
|
|
2
|
+
var f, n, t = "";
|
|
3
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
4
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
5
|
+
var o = r.length;
|
|
6
|
+
for (f = 0; f < o; f++) r[f] && (n = a(r[f])) && (t && (t += " "), t += n);
|
|
7
|
+
} else for (n in r) r[n] && (t && (t += " "), t += n);
|
|
8
|
+
return t;
|
|
9
|
+
}
|
|
10
|
+
function i() {
|
|
11
|
+
for (var r, f, n = 0, t = "", o = arguments.length; n < o; n++) (r = arguments[n]) && (f = a(r)) && (t && (t += " "), t += f);
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
i as c
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface ComponentProps extends React.ComponentProps<'button'> {
|
|
2
|
+
primary?: boolean;
|
|
3
|
+
size?: 'small' | 'medium' | 'large';
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function MyButton({ primary, size, label, ...props }: ComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { c as _ } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import '../../assets/index3.css';const s = "_button_31ovf_1", t = {
|
|
4
|
+
button: s,
|
|
5
|
+
"button--primary": "_button--primary_31ovf_15",
|
|
6
|
+
"button--small": "_button--small_31ovf_27",
|
|
7
|
+
"button--medium": "_button--medium_31ovf_37",
|
|
8
|
+
"button--large": "_button--large_31ovf_47"
|
|
9
|
+
};
|
|
10
|
+
function a({ primary: n = !1, size: o = "medium", label: u, ...b }) {
|
|
11
|
+
const m = _(t.button, {
|
|
12
|
+
[t["button--primary"]]: n,
|
|
13
|
+
[t[`button--${o}`]]: o
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ r(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
type: "button",
|
|
19
|
+
className: m,
|
|
20
|
+
...b,
|
|
21
|
+
children: u
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
a as MyButton
|
|
27
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface CounterProps extends React.ComponentProps<'button'> {
|
|
2
|
+
initialValue?: number;
|
|
3
|
+
step?: number;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function MyCounter({ initialValue, step, min, max, }: CounterProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f } from "react";
|
|
3
|
+
import { MyButton as r } from "../MyButton/index.js";
|
|
4
|
+
import '../../assets/index2.css';const y = "_container_rjlrw_1", C = "_text_rjlrw_11", m = {
|
|
5
|
+
container: y,
|
|
6
|
+
text: C
|
|
7
|
+
};
|
|
8
|
+
function h({
|
|
9
|
+
initialValue: c = 0,
|
|
10
|
+
step: s = 1,
|
|
11
|
+
min: i = -1 / 0,
|
|
12
|
+
max: l = 1 / 0
|
|
13
|
+
}) {
|
|
14
|
+
const [t, e] = f(c), u = () => {
|
|
15
|
+
e((n) => Math.min(n + s, l));
|
|
16
|
+
}, d = () => {
|
|
17
|
+
e((n) => Math.max(n - s, i));
|
|
18
|
+
}, x = () => {
|
|
19
|
+
e(c);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ a("section", { className: m.container, children: [
|
|
22
|
+
/* @__PURE__ */ a("p", { className: m.text, children: [
|
|
23
|
+
"Count: ",
|
|
24
|
+
t
|
|
25
|
+
] }),
|
|
26
|
+
/* @__PURE__ */ o(
|
|
27
|
+
r,
|
|
28
|
+
{
|
|
29
|
+
label: "Increment",
|
|
30
|
+
onClick: u,
|
|
31
|
+
disabled: t >= l
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
/* @__PURE__ */ o(
|
|
35
|
+
r,
|
|
36
|
+
{
|
|
37
|
+
label: "Decrement",
|
|
38
|
+
onClick: d,
|
|
39
|
+
disabled: t <= i
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ o(
|
|
43
|
+
r,
|
|
44
|
+
{
|
|
45
|
+
label: "Reset",
|
|
46
|
+
onClick: x,
|
|
47
|
+
primary: !0
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
h as MyCounter
|
|
54
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { c as o } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import '../../assets/index.css';const c = "_title_izbg1_1", t = {
|
|
4
|
+
title: c,
|
|
5
|
+
"title--primary": "_title--primary_izbg1_13"
|
|
6
|
+
};
|
|
7
|
+
function n({ primary: i = !1, title: e, ...l }) {
|
|
8
|
+
const r = o(t.title, {
|
|
9
|
+
[t["title--primary"]]: i
|
|
10
|
+
});
|
|
11
|
+
return /* @__PURE__ */ s(
|
|
12
|
+
"h1",
|
|
13
|
+
{
|
|
14
|
+
className: r,
|
|
15
|
+
...l,
|
|
16
|
+
children: e
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
n as MyTitle
|
|
22
|
+
};
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lgsm/modules",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc && vite build",
|
|
7
|
+
"lint": "eslint . --ext ts,tsx",
|
|
8
|
+
"lint:fix": "eslint . --ext ts,tsx --fix",
|
|
9
|
+
"format": "prettier --check .",
|
|
10
|
+
"format:fix": "prettier --write .",
|
|
11
|
+
"stylelint": "stylelint **/*.css",
|
|
12
|
+
"stylelint:fix": "stylelint **/*.css --fix",
|
|
13
|
+
"storybook": "storybook dev -p 6006",
|
|
14
|
+
"build-storybook": "storybook build",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"test:ui": "vitest --ui",
|
|
17
|
+
"coverage": "vitest run --coverage",
|
|
18
|
+
"prepublishOnly": "vitest run && npm run build"
|
|
19
|
+
},
|
|
20
|
+
"module": "./dist/main.js",
|
|
21
|
+
"exports": "./dist/main.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"types": "./dist/main.d.ts",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "^19.0.0",
|
|
28
|
+
"react-dom": "^19.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@chromatic-com/storybook": "3.2.5",
|
|
32
|
+
"@eslint/js": "9.21.0",
|
|
33
|
+
"@storybook/addon-essentials": "8.6.3",
|
|
34
|
+
"@storybook/addon-interactions": "8.6.3",
|
|
35
|
+
"@storybook/addon-links": "8.6.3",
|
|
36
|
+
"@storybook/addon-onboarding": "8.6.3",
|
|
37
|
+
"@storybook/blocks": "8.6.3",
|
|
38
|
+
"@storybook/react": "8.6.3",
|
|
39
|
+
"@storybook/react-vite": "8.6.3",
|
|
40
|
+
"@storybook/test": "8.6.3",
|
|
41
|
+
"@testing-library/react": "16.2.0",
|
|
42
|
+
"@types/node": "22.13.8",
|
|
43
|
+
"@types/react": "19.0.10",
|
|
44
|
+
"@types/react-dom": "19.0.4",
|
|
45
|
+
"@vitejs/plugin-react": "4.3.4",
|
|
46
|
+
"@vitest/coverage-v8": "3.0.7",
|
|
47
|
+
"@vitest/ui": "3.0.7",
|
|
48
|
+
"autoprefixer": "10.4.20",
|
|
49
|
+
"clsx": "2.1.1",
|
|
50
|
+
"eslint": "9.21.0",
|
|
51
|
+
"eslint-config-prettier": "10.0.2",
|
|
52
|
+
"eslint-plugin-react-hooks": "5.2.0",
|
|
53
|
+
"eslint-plugin-react-refresh": "0.4.19",
|
|
54
|
+
"eslint-plugin-storybook": "0.11.3",
|
|
55
|
+
"glob": "11.0.1",
|
|
56
|
+
"globals": "16.0.0",
|
|
57
|
+
"jsdom": "26.0.0",
|
|
58
|
+
"prettier": "3.5.2",
|
|
59
|
+
"storybook": "8.6.3",
|
|
60
|
+
"stylelint": "16.15.0",
|
|
61
|
+
"stylelint-config-standard": "37.0.0",
|
|
62
|
+
"typescript": "5.7.3",
|
|
63
|
+
"typescript-eslint": "8.25.0",
|
|
64
|
+
"vite": "6.2.0",
|
|
65
|
+
"vite-plugin-dts": "4.5.1",
|
|
66
|
+
"vite-plugin-lib-inject-css": "2.2.1",
|
|
67
|
+
"vitest": "3.0.7"
|
|
68
|
+
}
|
|
69
|
+
}
|