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

Changed config setup #107

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 22 additions & 10 deletions .github/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,53 @@ Clone the repository and run the following commands from the root directory

## Local setup

1. Go to the fe-theme repo location in your terminal and do
#### 1. Go to the fe-theme repo location in your terminal and do
```
npm install
```
```
npm start

```
3. Go to your project location in terminal and link cloned repo of fe-theme with your project
#### 2. Open terminal and Go to any ```working react application``` in your system, where you want to ```implement FE-Theme```

```js
npm link {PATH}/fe-theme/ {PATH}/fe-theme/node_modules/styled-components/ {PATH}/fe-theme/node_modules/react {PATH}/fe-theme/node_modules/react-dom
npm link {PATH}/fe-theme/ {PATH}/fe-theme/node_modules/styled-components/ {PATH}/fe-theme/node_modules/react {PATH}/fe-theme/node_modules/react-dom
```
**Note:** PATH is the location of cloned fe-theme folder

#### 3. Last step to get config folder(fe-theme) contains config files of each component in your project repo

4. Last step to get config folder(fe-theme) contains config files of each component in your project repo
Create config file for all the component of fe-theme
```js
COMPONENT_CONFIG_PATH=./{location of fe-theme configuration folder in your application} ENVI=local CURRENT_APP_DIR=$(pwd) npm run theme-prepare --prefix ./node_modules/fe-theme
```
ENVI=local CURRENT_APP_DIR=$(pwd) COMPONENT_CONFIG_PATH=./{location of fe-theme component configuration folder in your application} npm run theme-prepare --prefix ./node_modules/fe-theme

Create config file for a single component of fe-theme
```js
COMPONENET_NAME=button COMPONENT_CONFIG_PATH=./{location of fe-theme configuration folder in your application} ENVI=local CURRENT_APP_DIR=$(pwd) npm run theme-prepare --prefix ./node_modules/fe-theme
```
**Note:** ```COMPONENT_CONFIG_PATH``` is a variable and setup it properly.
**Note:**
```COMPONENT_CONFIG_PATH``` is a variable and setup it properly.
```COMPONENET_NAME``` is the component Name

5.
#### 4. Pass theme config to ThemeProvider
```js
import React from 'react';
import ReactDOM from 'react-dom';
import { ThemeProvider } from 'styled-components';
import theme from '{PATH}/fe-theme/universal/theme';
import Init from 'fe-theme/Init';
import theme from '{PATH}/fe-theme/universal/theme'; // Include your theme to fe-theme
import App from './App';

ReactDOM.createRoot(document.getElementById('root')).render(
<ThemeProvider theme={theme}>
<ThemeProvider theme={Init(theme)}>
<App />
</ThemeProvider>
);
```

6. Hurrah...! Now fe-theme repo is available inside the node_modules of your project, and waching change in fe-theme.
#### 5. Hurrah...! Now fe-theme repo is available inside the node_modules of your project, and waching change in fe-theme.


<!-- # open http://localhost:6006 -->
Expand Down
8 changes: 8 additions & 0 deletions Init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import merge from 'lodash.merge';
import defaultTheme from './__appset/universal/theme';

export default function Init(userTheme) {
const mergeTheme = merge(defaultTheme, userTheme);

return mergeTheme;
}
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,45 +68,68 @@ $ bun add fe-theme

## Usage

#### 1. Creating a fe-theme folder in your application. It contains config files of components.
#### 1. Passing configuration settings to the fe-theme library using ThemeProvider

```js
COMPONENT_CONFIG_PATH=./{PATH} npm run theme-prepare --prefix ./node_modules/fe-theme
import React from 'react';
import ReactDOM from 'react-dom';
import { ThemeProvider } from 'styled-components';
import Init from 'fe-theme/Init';
import App from './App';

ReactDOM.createRoot(document.getElementById('root')).render(
<ThemeProvider theme={Init()}>
<App />
</ThemeProvider>
);
```

**Note:** ```PATH``` is a variable i.e. path for ```fe-theme configuration folder``` in your application. If you want to place config folder in your root location of your application folder then command will be
#### 2. You are good to go and import fe-theme component in your application
```js
import Button from 'fe-theme/Button';

<Button />
```

Wow, the configuration is quite simple, but wait... button design is different in my application. No worry, fellow step 3, 4.

#### 3. Creating a fe-theme folder in your application. It contains config files of components.

Create config file for all the component of fe-theme
```js
COMPONENT_CONFIG_PATH=./ npm run theme-prepare --prefix ./node_modules/fe-theme
COMPONENT_CONFIG_PATH=./{PATH} CURRENT_APP_DIR=$(pwd) npm run theme-prepare --prefix ./node_modules/fe-theme
```

#### 2. Passing configuration settings to the fe-theme library using ThemeProvider
Create config file for a single component of fe-theme
```js
COMPONENET_NAME={COMPONENT_NAME} COMPONENT_CONFIG_PATH=./{PATH} CURRENT_APP_DIR=$(pwd) npm run theme-prepare --prefix ./node_modules/fe-theme
```

**Note:**
```PATH``` is a variable i.e. where you want to place config files for your application
```COMPONENT_NAME``` is a variable i.e. where ```component``` Input, button, CHIP (Allow any case)

#### 4. Passing configuration settings to the fe-theme library using ThemeProvider

```js
import React from 'react';
import ReactDOM from 'react-dom';
import { ThemeProvider } from 'styled-components';
import theme from '{PATH}/fe-theme/universal/theme';
import Init from 'fe-theme/Init';
import theme from '{PATH}/fe-theme/universal/theme'; // Include your theme to fe-theme
import App from './App';

ReactDOM.createRoot(document.getElementById('root')).render(
<ThemeProvider theme={theme}>
// Inside the Init function pass theme
<ThemeProvider theme={Init(theme)}>
<App />
</ThemeProvider>
);
```

**Note:** ```PATH``` is a variable (Same as 1st point).
**Note:** ```PATH``` is a variable i.e. location of config files for your application

#### 3. Setup is completed, Now import UI component in your application like button
```js
import Button from 'fe-theme/Button';

<Button />
```

**Hurrah...!!!** Button is created, but button theme does not match with the your application. No worries. You can change default properties of button component

**Hurrah...!!!** Now you can change button(any compponent) property according to your application

```
Your Application Folder(Root Directory)
Expand Down
1 change: 0 additions & 1 deletion __application/component/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
Expand Down
58 changes: 0 additions & 58 deletions __application/component/Init/Init.js

This file was deleted.

3 changes: 0 additions & 3 deletions __application/component/Init/index.js

This file was deleted.

5 changes: 2 additions & 3 deletions __application/component/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import React from 'react';
import styled, { css } from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
import theme from '../theme';

const styles = {
borderRadius(props) {
if (props.shape === 'bluntEdged') {
return theme.cornerEdge;
return props.theme.cornerEdge;
}
if (props.shape === 'sharpEdged') {
return '2px';
}
if (props.shape === 'capsular') {
return theme.px(10);
return props.theme.px(10);
}
return '';
},
Expand Down
15 changes: 0 additions & 15 deletions __application/component/theme/font/fontColorConst.js

This file was deleted.

7 changes: 0 additions & 7 deletions __application/component/theme/font/fontFamilyConst.js

This file was deleted.

18 changes: 0 additions & 18 deletions __application/component/theme/font/fontSizeConst.js

This file was deleted.

8 changes: 0 additions & 8 deletions __application/component/theme/font/fontWeightConst.js

This file was deleted.

3 changes: 0 additions & 3 deletions __application/component/theme/index.js

This file was deleted.

67 changes: 0 additions & 67 deletions __application/component/theme/theme.js

This file was deleted.

Loading