|
1 | | -<img src="logo.svg" alt="FE-Theme Logo" width="100%" style="width: 100%;"> |
| 1 | +<img src="https://github.com/opensrc0/fe-theme/blob/develop/logo.svg" alt="FE-Theme Logo" width="100%" style="width: 100%;"> |
2 | 2 | <h2 align="center">A React UI library using styled-component to build consistent, responsive, theme able UI 💪 </h2> |
3 | 3 | <br /> |
4 | 4 | <p align="center"> |
@@ -50,61 +50,128 @@ FE-Theme is a styled-component based comprehensive library of accessible, reusab |
50 | 50 | - **Dark Mode UI:** FE-Theme support dark mode compatibility. |
51 | 51 |
|
52 | 52 | ## Installation |
| 53 | +Install `fe-theme` package using any package manager |
| 54 | + |
| 55 | +```sh |
| 56 | +# with Yarn |
| 57 | +$ yarn add fe-theme |
| 58 | + |
| 59 | +# with npm |
| 60 | +$ npm i fe-theme --save |
53 | 61 |
|
54 | | - npm install fe-theme --save |
55 | | - |
56 | | -## Usage |
| 62 | +# with pnpm |
| 63 | +$ pnpm add fe-theme |
57 | 64 |
|
58 | | -#### 1. Creating a fe-theme folder in the root directory of you application. It contains configuration files of fe-theme component like Button, Input etc. |
| 65 | +# with Bun |
| 66 | +$ bun add fe-theme |
| 67 | +``` |
59 | 68 |
|
60 | | - npm run theme-prepare --prefix ./node_modules/fe-theme |
| 69 | +## Usage |
61 | 70 |
|
62 | | -#### 2. Passing universal configuration like color properties, font family properties, to the fe-theme library using ThemeProvider (For internal usage only but required) |
| 71 | +#### 1. Use fe-theme in your application using themeProvider |
63 | 72 |
|
64 | 73 | ```js |
65 | | -import React from 'react'; |
66 | | -import ReactDOM from 'react-dom'; |
67 | | -import { ThemeProvider } from 'styled-components'; |
68 | | -import theme from '{root-location-of-your-project}/fe-theme/universal/theme'; // root-location-of-your-project is dynamic variable |
| 74 | +import { ThemeProvider } from 'styled-components'; // import ThemeProvider component |
| 75 | +import init from 'fe-theme/init'; // import Init function |
69 | 76 | import App from './App'; |
70 | 77 |
|
71 | | -ReactDOM.hydrate( |
72 | | - <ThemeProvider theme={theme}> |
| 78 | +ReactDOM.createRoot(document.getElementById('root')).render( |
| 79 | + // Wrap your application with ThemeProvider |
| 80 | + <ThemeProvider theme={init()}> |
73 | 81 | <App /> |
74 | | - </ThemeProvider>, |
75 | | - document.getElementById('root'), |
| 82 | + </ThemeProvider> |
76 | 83 | ); |
77 | 84 | ``` |
78 | 85 |
|
79 | | -#### 3. Setup is completed, Now import UI component in your application like button |
| 86 | +#### 2. You are good to go and import fe-theme component in your application |
80 | 87 | ```js |
81 | 88 | import Button from 'fe-theme/Button'; |
82 | 89 |
|
83 | 90 | <Button /> |
84 | 91 | ``` |
85 | 92 |
|
86 | | -Hurrah...!!! Button is created, but button theme does not match with the your application. No worries. You can change default properties of button component |
87 | | - |
| 93 | +Wow, the configuration is quite simple, but wait... button design is different in my application. No worry, follow step 3, 4. |
| 94 | + |
| 95 | +#### 3. Create your own theme |
| 96 | + |
| 97 | + **a)** Create an empty folder called ```fe-theme-config``` in your application at any location. |
| 98 | + |
| 99 | + **c)** Create configButton.js file inside fe-theme-config folder (To configure Button Component) |
| 100 | + |
| 101 | +```js |
| 102 | +const Button = { |
| 103 | + "borderRadius": "50px", |
| 104 | + "borderColor": "12px", |
| 105 | + "primary": { |
| 106 | + "color": "white", |
| 107 | + "borderColor": "white" |
| 108 | + }, |
| 109 | + "secondary": { |
| 110 | + "color": "white", |
| 111 | + "borderColor": "white" |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +export default Button; |
| 116 | +``` |
| 117 | + **Note** Config file name start with ```config``` keyword along with ```component Name``` like ```configButton.js```/```configInput.js``` |
| 118 | + |
| 119 | + **c)** Create theme.js file and include configButton.js |
| 120 | +```js |
| 121 | +import Button from '../configButton'; |
| 122 | + |
| 123 | +export default { |
| 124 | + Button, |
| 125 | +}; |
| 126 | + |
| 127 | +``` |
| 128 | +Yeah, We have created config files Mannually but You can also generate config files automatically using command line [Check Commands](./.github/COMMAND.md) |
| 129 | + |
| 130 | +#### 4. Pass the newly created theme file in init function |
| 131 | + |
| 132 | +```js |
| 133 | +import { ThemeProvider } from 'styled-components'; |
| 134 | +import init from 'fe-theme/init'; |
| 135 | +import theme from '{PATH}/fe-theme-config/theme'; // Include your theme to fe-theme |
| 136 | +import App from './App'; |
| 137 | + |
| 138 | +ReactDOM.createRoot(document.getElementById('root')).render( |
| 139 | + // Inside the Init function pass theme |
| 140 | + <ThemeProvider theme={init(theme)}> |
| 141 | + <App /> |
| 142 | + </ThemeProvider> |
| 143 | +); |
| 144 | +``` |
| 145 | + |
| 146 | +**Note:** ```PATH``` is a variable i.e. location of config files in your application |
| 147 | + |
| 148 | +**Hurrah...!!!** Now you can change button(any compponent) property according to your application |
88 | 149 |
|
89 | 150 | ``` |
90 | 151 | Your Application Folder(Root Directory) |
91 | | - └──fe-theme |
| 152 | + └──fe-theme-config |
92 | 153 | ├──configButton |
93 | 154 | ├──configInput |
94 | | - └──configChip |
95 | | - |
| 155 | + └──configChip |
96 | 156 | ``` |
97 | | -Play around the property of button according to your project. |
| 157 | +Play around the property of component according to your project. |
98 | 158 |
|
99 | 159 | ## Online Editor Templates |
100 | | -WIP |
| 160 | +#### 1. CodeSandbox |
| 161 | +- JavaScript Starter: https://codesandbox.io/p/devbox/fe-theme-js-6q2vcg |
| 162 | +<!-- - TypeScript Starter: WIP --> |
| 163 | +<!-- - NextJS TypeScript Starter: WIP --> |
101 | 164 |
|
102 | | -## Contributing |
| 165 | +#### 2. Stackblitz |
| 166 | +- JavaScript Starter: https://stackblitz.com/edit/fe-theme-js-b6mri2 |
| 167 | +<!-- - TypeScript Starter: WIP --> |
| 168 | +<!-- - NextJS TypeScript Starter: WIP --> |
103 | 169 |
|
104 | | -Feel like contributing? Most welcome! |
105 | | -Follow this quick [setup and guide lines](./.github/CONTRIBUTING.md) to get fe-theme working on your local machine and contribute. |
106 | 170 |
|
| 171 | +## Contributing |
107 | 172 |
|
| 173 | +Feel like contributing? Most welcome! |
| 174 | +[Setup locally](./.github/SETUP.md) to get fe-theme working on your local machine and [guide lines](./.github/CONTRIBUTING.md) to contribute in fe-theme. |
108 | 175 |
|
109 | 176 | ## Contributors |
110 | 177 |
|
|
0 commit comments