@cryptofi/core-ui 0.1.0
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/LICENSE +21 -0
- package/README.md +88 -0
- package/package.json +106 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 CryptoFi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# CryptoFi Core UI
|
|
2
|
+
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
Launch Storybook to view components locally:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn storybook
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Adding a Component
|
|
12
|
+
|
|
13
|
+
1. Create a new directory in the **components** directory using the following structure. Note that a component can consist of only a React component file (tsx) or a theme files (ts) depending on how it is structured.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
components/
|
|
17
|
+
├─ Button/
|
|
18
|
+
| ├─ Button.tsx
|
|
19
|
+
| ├─ buttonTheme.ts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. Setup the basic component structure. This simplified example demonstrates wrapping a Chakra component:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Button } from '@chakra-ui/react';
|
|
26
|
+
|
|
27
|
+
const CFButton = ({ children }: { children: React.reactNode }) => {
|
|
28
|
+
return <Button>{children}</Button>;
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
3. Add the component file to **components/index.ts**, using the `CF` prefix as a namespace to differentiate between similarly named Chakra components:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
export { default as CFButton } from './Button/Button'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
4. Add the component theme to the corresponding section of the **src/theme.ts** file under the `components` key.
|
|
39
|
+
|
|
40
|
+
### Styling a Component
|
|
41
|
+
|
|
42
|
+
The reusable components exported from this library generally use separate theme files to simplify implementation of variants, sizes, etc., but simple components can also be styled directly in the component file using Chakra [style props](https://chakra-ui.com/docs/styled-system/style-props).
|
|
43
|
+
|
|
44
|
+
Guidelines:
|
|
45
|
+
|
|
46
|
+
- Prefer responsive units like `rem` over pixel values
|
|
47
|
+
- Use Chakra's unitless [spacing](https://chakra-ui.com/docs/styled-system/theme#spacing) values for spacing and positioning when possible
|
|
48
|
+
- Refer to documentation for the corresponding Chakra UI component when styling base components
|
|
49
|
+
|
|
50
|
+
### Icons
|
|
51
|
+
|
|
52
|
+
Run the command below to (re)generate React components from SVG files located in the **svg-icons** directory.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
yarn icons:gen
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When adding a new icon, place the SVG file in the **svg-icons** directory, then regenerate icons and check-in the resulting changes.
|
|
59
|
+
|
|
60
|
+
Following is an example of using an icon component in application code. Note that icons are named with the prefix `Icon` during generation and can be styled using Chakra style props.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { IconBank } from '@cryptofi/core-ui';
|
|
64
|
+
|
|
65
|
+
const SomeComponent = () => {
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<IconBank height="10" width="10" __css={{ path: { fill: 'orange' } }} />
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Build and Publish
|
|
75
|
+
|
|
76
|
+
To build components and update local consumers with the latest changes, run the following:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
yarn publish:local
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Tooling
|
|
83
|
+
|
|
84
|
+
This project uses [Rollup](https://rollupjs.org/) to build an optimized JavaScript bundle, and consumers are expected to provide necessary peer dependencies for Chakra UI and React as outlined in this project's package.json.
|
|
85
|
+
|
|
86
|
+
Vite is used in conjunction with Storybook for local development.
|
|
87
|
+
|
|
88
|
+
Based on the following Vite / React template: https://github.com/The24thDS/vite-reactts18-chakra-jest-husky
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cryptofi/core-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "CryptoFi"
|
|
6
|
+
},
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.0.0"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "yarn storybook",
|
|
14
|
+
"build": "rm -rf ./dist && rollup -c",
|
|
15
|
+
"lint": "eslint src --ext .tsx --ext .ts",
|
|
16
|
+
"lint:fix": "yarn lint --fix",
|
|
17
|
+
"format": "prettier --config ./.prettierrc -w 'src/**/*.{tsx,ts}' && git update-index --again",
|
|
18
|
+
"pretest": "yarn lint:fix",
|
|
19
|
+
"test": "jest --colors --passWithNoTests",
|
|
20
|
+
"posttest": "npx http-server coverage/lcov-report",
|
|
21
|
+
"test:watch": "yarn test --collectCoverage=false --watch",
|
|
22
|
+
"storybook": "storybook dev -p 6006",
|
|
23
|
+
"build:storybook": "storybook build",
|
|
24
|
+
"publish:local": "yarn build && yarn dlx yalc publish --push",
|
|
25
|
+
"icons:gen": "yarn icons:clean && yarn icons:prefix && yarn dlx @svgr/cli -- ./svg-icons",
|
|
26
|
+
"icons:clean": "rm -rf src/icons && mkdir src/icons",
|
|
27
|
+
"icons:prefix": "node scripts/prefix-icons.cjs"
|
|
28
|
+
},
|
|
29
|
+
"module": "dist/index.js",
|
|
30
|
+
"types": "dist/types/index.d.ts",
|
|
31
|
+
"src": "src",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@chakra-ui/react": "^2.4.9",
|
|
37
|
+
"@emotion/react": "^11.11.1",
|
|
38
|
+
"@emotion/styled": "^11.11.0",
|
|
39
|
+
"framer-motion": "^10.16.4",
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"react-dom": "^18.2.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@babel/core": "^7.17.5",
|
|
45
|
+
"@chakra-ui/react": "^2.4.9",
|
|
46
|
+
"@chakra-ui/storybook-addon": "^5.0.1",
|
|
47
|
+
"@emotion/react": "^11.11.1",
|
|
48
|
+
"@emotion/styled": "^11.11.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
50
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
51
|
+
"@storybook/addon-essentials": "^7.5.2",
|
|
52
|
+
"@storybook/addon-interactions": "^7.5.2",
|
|
53
|
+
"@storybook/addon-links": "^7.5.2",
|
|
54
|
+
"@storybook/addon-onboarding": "^1.0.8",
|
|
55
|
+
"@storybook/blocks": "^7.5.2",
|
|
56
|
+
"@storybook/react": "^7.5.2",
|
|
57
|
+
"@storybook/react-vite": "^7.5.2",
|
|
58
|
+
"@storybook/testing-library": "^0.2.2",
|
|
59
|
+
"@svgr/cli": "^8.1.0",
|
|
60
|
+
"@svgr/core": "^8.1.0",
|
|
61
|
+
"@svgr/plugin-jsx": "^8.1.0",
|
|
62
|
+
"@svgr/plugin-prettier": "^8.1.0",
|
|
63
|
+
"@svgr/plugin-svgo": "^8.1.0",
|
|
64
|
+
"@testing-library/jest-dom": "^5.16.2",
|
|
65
|
+
"@testing-library/react": "^13.4.0",
|
|
66
|
+
"@types/jest": "^29.2.6",
|
|
67
|
+
"@types/lodash.isempty": "^4",
|
|
68
|
+
"@types/react": "^18.0.27",
|
|
69
|
+
"@types/react-dom": "^18.0.10",
|
|
70
|
+
"@types/rollup-plugin-peer-deps-external": "^2",
|
|
71
|
+
"@types/stringify-object": "^4.0.4",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
73
|
+
"@typescript-eslint/parser": "^5.12.1",
|
|
74
|
+
"colord": "^2.9.3",
|
|
75
|
+
"eslint": "^8.9.0",
|
|
76
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
77
|
+
"eslint-config-prettier": "^8.4.0",
|
|
78
|
+
"eslint-plugin-import": "^2.25.4",
|
|
79
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
80
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
81
|
+
"eslint-plugin-react": "^7.28.0",
|
|
82
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
83
|
+
"eslint-plugin-simple-import-sort": "^9.0.0",
|
|
84
|
+
"eslint-plugin-storybook": "^0.6.15",
|
|
85
|
+
"framer-motion": "^10.16.4",
|
|
86
|
+
"identity-obj-proxy": "^3.0.0",
|
|
87
|
+
"jest": "^29.4.0",
|
|
88
|
+
"lodash.isempty": "^4.4.0",
|
|
89
|
+
"pnpapi": "^0.0.0",
|
|
90
|
+
"prettier": "^2.5.1",
|
|
91
|
+
"react": "^18.2.0",
|
|
92
|
+
"react-dom": "^18.2.0",
|
|
93
|
+
"rollup": "^4.3.1",
|
|
94
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
95
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
96
|
+
"rollup-plugin-filesize": "^10.0.0",
|
|
97
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
98
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
99
|
+
"storybook": "^7.5.2",
|
|
100
|
+
"stringify-object": "^5.0.0",
|
|
101
|
+
"ts-jest": "^29.0.5",
|
|
102
|
+
"typescript": "^4.5.5",
|
|
103
|
+
"vite": "^4.5.0"
|
|
104
|
+
},
|
|
105
|
+
"packageManager": "yarn@4.0.1"
|
|
106
|
+
}
|