Skip to content

Commit eca7136

Browse files
committed
Initial commit
0 parents  commit eca7136

22 files changed

+3102
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{js,json,yml}]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 2

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.yarn/** linguist-vendored
2+
/.yarn/releases/* binary
3+
/.yarn/plugins/**/* binary
4+
/.pnp.* binary linguist-generated

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.yarn/*
2+
!.yarn/patches
3+
!.yarn/plugins
4+
!.yarn/releases
5+
!.yarn/sdks
6+
!.yarn/versions
7+
8+
# Swap the comments on the following lines if you wish to use zero-installs
9+
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
10+
# Documentation here: https://yarnpkg.com/features/caching#zero-installs
11+
12+
#!.yarn/cache
13+
.pnp.*
14+
15+
# build
16+
lib/
17+
cjs/
18+
dist/
19+
esm/
20+
.rollup.cache/
21+
22+
# typescript
23+
*.tsbuildinfo

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# react-library

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "react-library",
3+
"packageManager": "[email protected]",
4+
"private": true,
5+
"workspaces": [
6+
"packages/*"
7+
],
8+
"scripts": {
9+
"compile": "tsc --noEmit",
10+
"build": "yarn workspace @react-library/hooks build"
11+
},
12+
"dependencies": {
13+
"react": "^18.2.0"
14+
},
15+
"devDependencies": {
16+
"@rollup/plugin-commonjs": "^25.0.7",
17+
"@rollup/plugin-node-resolve": "^15.2.3",
18+
"@rollup/plugin-typescript": "^11.1.5",
19+
"@types/react": "^18.2.40",
20+
"@types/rollup-plugin-peer-deps-external": "^2",
21+
"rollup": "^4.6.1",
22+
"rollup-plugin-peer-deps-external": "^2.2.4",
23+
"rollup-plugin-postcss": "^4.0.2",
24+
"rollup-plugin-terser": "^7.0.2",
25+
"typescript": "^5.3.2"
26+
}
27+
}

packages/components/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@react-library/components",
3+
"version": "7.2.2",
4+
"main": "dist/cjs/index.js",
5+
"module": "dist/esm/index.js",
6+
"types": "dist/index.d.ts",
7+
"type": "module",
8+
"scripts": {
9+
"compile": "tsc -b",
10+
"build": "rollup -c --bundleConfigAsCjs"
11+
},
12+
"peerDependencies": {
13+
"react": "^18.2.0"
14+
},
15+
"devDependencies": {
16+
"@rollup/plugin-commonjs": "^25.0.7",
17+
"@rollup/plugin-node-resolve": "^15.2.3",
18+
"@rollup/plugin-typescript": "^11.1.5",
19+
"@types/react": "^18.2.40",
20+
"@types/rollup-plugin-peer-deps-external": "^2",
21+
"postcss": "^8.4.31",
22+
"rollup": "^4.6.1",
23+
"rollup-plugin-dts": "^6.1.0",
24+
"rollup-plugin-peer-deps-external": "^2.2.4",
25+
"rollup-plugin-postcss": "^4.0.2",
26+
"rollup-plugin-terser": "^7.0.2",
27+
"tslib": "^2.6.2",
28+
"typescript": "^5.3.2"
29+
},
30+
"dependencies": {
31+
"classnames": "^2.3.2"
32+
}
33+
}

packages/components/rollup.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import resolve from "@rollup/plugin-node-resolve";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import typescript from "@rollup/plugin-typescript";
4+
import { terser } from "rollup-plugin-terser";
5+
import external from "rollup-plugin-peer-deps-external";
6+
import { dts } from "rollup-plugin-dts";
7+
import postcss from "rollup-plugin-postcss";
8+
9+
const packageJson = require("./package.json");
10+
11+
export default [
12+
{
13+
input: "src/index.ts",
14+
output: [
15+
{
16+
file: packageJson.main,
17+
format: "cjs",
18+
sourcemap: true,
19+
name: "react-ts-lib",
20+
},
21+
{
22+
file: packageJson.module,
23+
format: "esm",
24+
sourcemap: true,
25+
},
26+
],
27+
plugins: [
28+
external(),
29+
resolve(),
30+
commonjs(),
31+
typescript({ tsconfig: "./tsconfig.json" }),
32+
postcss(),
33+
terser(),
34+
],
35+
},
36+
{
37+
input: "dist/esm/types/index.d.ts",
38+
output: [{ file: "dist/index.d.ts", format: "esm" }],
39+
external: [/\.css$/],
40+
plugins: [dts()],
41+
},
42+
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.button {
2+
border-radius: 0.25rem;
3+
}
4+
5+
.red {
6+
color: red;
7+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import cx from "classnames";
2+
import React, { ReactNode } from "react";
3+
import { Props } from "./index.types";
4+
5+
export default function Button({
6+
children,
7+
className,
8+
red = false,
9+
pill = false,
10+
green = false,
11+
gradientBg = false,
12+
white = false,
13+
...props
14+
}: Props): ReactNode {
15+
return (
16+
<button
17+
className={cx(
18+
"button",
19+
{
20+
red: red,
21+
// [css.greenBg]: green,
22+
// [css.pill]: pill,
23+
// [css.gradientBg]: gradientBg,
24+
// [css.whiteBg]: white,
25+
},
26+
className
27+
)}
28+
type="button"
29+
// These props need to come last
30+
{...props}
31+
>
32+
{children}
33+
</button>
34+
);
35+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ButtonHTMLAttributes } from "react";
2+
3+
export type ColorProps = {
4+
red?: boolean;
5+
green?: boolean;
6+
pill?: boolean;
7+
white?: boolean;
8+
gradientBg?: boolean;
9+
};
10+
11+
export type Props = ButtonHTMLAttributes<HTMLButtonElement> & ColorProps;

packages/components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "./Button";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
{
3+
"extends": "../../tsconfig.base.json",
4+
"include": ["./src", "./types"],
5+
"exclude": [
6+
"./lib",
7+
"./esm",
8+
"./cjs",
9+
],
10+
"compilerOptions": {
11+
"rootDir": "src",
12+
"baseUrl": ".",
13+
"outDir": "lib",
14+
"declaration": true,
15+
"declarationDir": "lib",
16+
"composite": true
17+
}
18+
}

packages/components/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["./src", "./types"],
4+
"exclude": ["./lib", "./esm", "./cjs"],
5+
"compilerOptions": {
6+
"rootDir": "src",
7+
"baseUrl": ".",
8+
"outDir": "lib",
9+
"declaration": true,
10+
"declarationDir": "types",
11+
"composite": true,
12+
"emitDeclarationOnly": true
13+
}
14+
}

packages/hooks/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@react-library/hooks",
3+
"version": "7.2.2",
4+
"main": "dist/cjs/index.js",
5+
"module": "dist/esm/index.js",
6+
"types": "dist/index.d.ts",
7+
"type": "module",
8+
"scripts": {
9+
"compile": "tsc -b",
10+
"build": "rollup -c --bundleConfigAsCjs"
11+
},
12+
"peerDependencies": {
13+
"react": "^18.2.0"
14+
},
15+
"devDependencies": {
16+
"@rollup/plugin-commonjs": "^25.0.7",
17+
"@rollup/plugin-node-resolve": "^15.2.3",
18+
"@rollup/plugin-typescript": "^11.1.5",
19+
"@types/react": "^18.2.40",
20+
"@types/rollup-plugin-peer-deps-external": "^2",
21+
"rollup": "^4.6.1",
22+
"rollup-plugin-dts": "^6.1.0",
23+
"rollup-plugin-peer-deps-external": "^2.2.4",
24+
"rollup-plugin-postcss": "^4.0.2",
25+
"rollup-plugin-terser": "^7.0.2",
26+
"tslib": "^2.6.2",
27+
"typescript": "^5.3.2"
28+
}
29+
}

packages/hooks/rollup.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import resolve from "@rollup/plugin-node-resolve";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import typescript from "@rollup/plugin-typescript";
4+
import { terser } from "rollup-plugin-terser";
5+
import external from "rollup-plugin-peer-deps-external";
6+
import { dts } from "rollup-plugin-dts";
7+
// import postcss from "rollup-plugin-postcss";
8+
9+
const packageJson = require("./package.json");
10+
11+
export default [
12+
{
13+
input: "src/index.ts",
14+
output: [
15+
{
16+
file: packageJson.main,
17+
format: "cjs",
18+
sourcemap: true,
19+
name: "react-ts-lib",
20+
},
21+
{
22+
file: packageJson.module,
23+
format: "esm",
24+
sourcemap: true,
25+
},
26+
],
27+
plugins: [
28+
external(),
29+
resolve(),
30+
commonjs(),
31+
typescript({ tsconfig: "./tsconfig.json" }),
32+
// postcss(),
33+
terser(),
34+
],
35+
},
36+
{
37+
input: "dist/esm/types/index.d.ts",
38+
output: [{ file: "dist/index.d.ts", format: "esm" }],
39+
external: [/\.css$/],
40+
plugins: [dts()],
41+
},
42+
];

packages/hooks/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as useSetState } from "./useSetState";

packages/hooks/src/useSetState.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React, { useReducer } from "react";
2+
3+
export default function useSetState<S extends Record<string, unknown>>(
4+
initialState: S
5+
): [S, React.Dispatch<Partial<S>>] {
6+
const reducer = (s: S, a: Partial<S>) => {
7+
return { ...s, ...a };
8+
};
9+
return useReducer(reducer, initialState);
10+
}

packages/hooks/tsconfig.build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
{
3+
"extends": "../../tsconfig.base.json",
4+
"include": ["./src", "./types"],
5+
"exclude": [
6+
"./lib",
7+
"./esm",
8+
"./cjs",
9+
],
10+
"compilerOptions": {
11+
"rootDir": "src",
12+
"baseUrl": ".",
13+
"outDir": "lib",
14+
"declaration": true,
15+
"declarationDir": "lib",
16+
"composite": true
17+
}
18+
}

packages/hooks/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["./src", "./types"],
4+
"exclude": ["./lib", "./esm", "./cjs"],
5+
"compilerOptions": {
6+
"rootDir": "src",
7+
"baseUrl": ".",
8+
"outDir": "lib",
9+
"declaration": true,
10+
"declarationDir": "types",
11+
"composite": true,
12+
"emitDeclarationOnly": true
13+
}
14+
}

tsconfig.base.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"exclude": [
3+
"node_modules",
4+
"lib",
5+
"esm",
6+
"cjs",
7+
"jest-config.js",
8+
"configuration/storybook/main.js",
9+
"lib/**/*",
10+
"esm/**/*",
11+
"cjs/**/*"
12+
],
13+
"compilerOptions": {
14+
"target": "ES2015",
15+
"lib": ["DOM", "ESNext"],
16+
"module": "ESNext",
17+
"moduleResolution": "Node",
18+
"jsx": "react",
19+
"resolveJsonModule": true,
20+
"esModuleInterop": true,
21+
"skipLibCheck": true,
22+
"noEmitOnError": true,
23+
"allowJs": true,
24+
"strict": true,
25+
"baseUrl": "."
26+
}
27+
}

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./tsconfig.base.json"
3+
}

0 commit comments

Comments
 (0)