Skip to content

Commit ac84c44

Browse files
JeremyDollejgautraisvbriand
authored
V4 - theme refactoring, documentation and code improvment (#382)
* feat(theme): refactoring for better theme with unique config file * fix(deps): new deps * feat(theme): add new theme configuration * feat(theme): remove complex Generic type * chore(rn): improve all the code type check, the documentation and the git config * Update 02-Configuration.md Co-authored-by: Jeremy <[email protected]> * Update 01-Navigate.md Co-authored-by: Jeremy <[email protected]> * feat(zod): add zod to validate request and move axios to ky * feat(component): component theme * chore(rn): upgrade code to simply * chore(rn): upgrade code to simply it * chore(lint): fix lint * feat(plugin): improve startup command with yarn and npm choose * Update documentation/blog/2023-09-18-React-Native-Boilerplate-4.0.0.md Co-authored-by: Valentin Briand <[email protected]> * Update documentation/blog/2023-09-18-React-Native-Boilerplate-4.0.0.md Co-authored-by: Valentin Briand <[email protected]> * Update documentation/docs/04-Guides/04-Theming/01-Using.md Co-authored-by: Valentin Briand <[email protected]> * chore(clean): simplify project * chore(doc): improve documentation related to new features * chore(arch): simplify arch * feat(rn): improve arch for v4 * feat(doc): improve style and content --------- Co-authored-by: jeremydolle <[email protected]> Co-authored-by: Jeremy <[email protected]> Co-authored-by: Valentin Briand <[email protected]>
1 parent 49be252 commit ac84c44

File tree

200 files changed

+12817
-5945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+12817
-5945
lines changed

.github/workflows/cd-documentation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [ main ]
66
paths:
77
- documentation/**/*
8+
- template/theme/**/*
9+
- template/package.json
810

911
jobs:
1012
deploy_doc:
@@ -13,7 +15,7 @@ jobs:
1315
- uses: actions/checkout@v1
1416
- uses: actions/setup-node@v1
1517
with:
16-
node-version: '16.x'
18+
node-version: '19.x'
1719
- name: Add key to allow access to repository
1820
env:
1921
SSH_AUTH_SOCK: /tmp/ssh_agent.sock

.github/workflows/ci-documentation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [ main ]
66
paths:
77
- documentation/**/*
8+
- template/theme/**/*
9+
- template/package.json
810

911
jobs:
1012
check_build:
@@ -13,7 +15,7 @@ jobs:
1315
- uses: actions/checkout@v1
1416
- uses: actions/setup-node@v1
1517
with:
16-
node-version: '16.x'
18+
node-version: '19.x'
1719
- name: Test Build
1820
run: |
1921
cd documentation

.github/workflows/w-deploy-npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
ref: ${{ inputs.checkout_ref }}
2525
- uses: actions/setup-node@v1
2626
with:
27-
node-version: 14
27+
node-version: '19.x'
2828
- run: |
2929
git config --global user.name "RNB Bot"
3030
git config --global user.email "[email protected]"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ yarn-lock.json
1818
package-lock.json
1919

2020
node_modules
21+
template/js

.husky/prepare-commit-msg

Lines changed: 0 additions & 5 deletions
This file was deleted.

.npmignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ template/ios/Pods
1313
template/ios/build
1414
template/android/app/.cxx
1515
template/android/app/build
16+
template/android/build
1617
template/android/.gradle
1718
template/android/.idea
1819
documentation
19-
.idea
2020
.github
21-
.husky

commitlint.config.js

Lines changed: 0 additions & 103 deletions
This file was deleted.

documentation/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,3 @@ $ yarn build
2323
```
2424

2525
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26-
27-
### Deployment
28-
29-
Using SSH:
30-
31-
```
32-
$ USE_SSH=true yarn deploy
33-
```
34-
35-
Not using SSH:
36-
37-
```
38-
$ GIT_USER=<Your GitHub username> yarn deploy
39-
```
40-
41-
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

documentation/blog/2020-04-19-React-Native-Boilerplate-3.0.0.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Each of the used libraries are well-known, tried and tested.
6969
For the state management we use [**Redux**](https://redux.js.org/) (redux + redux toolkit + redux persist).
7070
Some people like it, some people don't.
7171
We are really comfortable with this library, it's not so difficult to learn, and the implementation is well-known,
72-
recognized as a good choice and easy [to debug](/docs/UsingFlipper)!
72+
recognized as a good choice and easy to debug!
7373
Thanks to this boilerplate and [redux-toolkit](https://redux-toolkit.js.org/), the state management is ready out of the box.
7474
A complete example is even included. This way, you can easier understand how it works.
7575
To deal with the navigation, [**React Navigation**](https://reactnavigation.org/) is THE reference for screen navigation.
@@ -145,10 +145,6 @@ export default ExampleContainer
145145

146146
That's this simple! 🚀
147147

148-
:::info
149-
For more details about redux-toolkit-wrapper jump [**here**](/docs/ReduxStore)
150-
:::
151-
152148
## What's in the box? 📦
153149

154150
Still hesitating ? Let's make a recap and see what this beautiful boilerplate can provide you:
@@ -161,9 +157,9 @@ Still hesitating ? Let's make a recap and see what this beautiful boilerplate ca
161157
- **Redux** (with redux-toolkit and redux-toolkit-wrapper 😉) : handling
162158
redux store has never been as easy as this!! ⚡
163159
- DarkMode or colorful app? Give your users the power to choose!
164-
**Multi-theming** and **darkMode** support 🌗 (see [here](/docs/ThemesAndDarkMode))
165-
- French kisses aren't translatable, but you can translate your app! **i18n friendly** 🌐 (see [here](/docs/AddALangTranslation))
166-
- You don't like bug hunt? Use **Flipper debugging** 🐛 (see [here](/docs/UsingFlipper))
160+
**Multi-theming** and **darkMode** support 🌗
161+
- French kisses aren't translatable, but you can translate your app! **i18n friendly** 🌐
162+
- You don't like bug hunt? Use **Flipper debugging** 🐛
167163
- Maintained by **passionate developers** ⚛️
168164

169165
Just Test It 🧪 !!
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: React Native Boilerplate 4.0.0
3+
authors: jed
4+
description: What's new?
5+
hide_table_of_contents: false
6+
tags: [v4, boilerplate react, react-native, kickstart]
7+
---
8+
After using the boilerplate on several projects,
9+
we decided to revisit some important aspects while still adhering to the core principles of the boilerplate:
10+
separation of concerns, ease of setup, and maintainability.
11+
We made several enhancements, which we'll detail here.
12+
13+
<!--truncate-->
14+
15+
16+
## Improved Theming
17+
Theming is a crucial aspect of any application.
18+
Previously, we had designed a layered theming system where all variables could be customized for each theme,
19+
including base colors and spacing.
20+
Upon reflection, we found that this system, while effective, wasn't the most straightforward to use,
21+
especially with the layered naming convention.
22+
23+
Additionally, being able to modify spacing between themes didn't make sense.
24+
Furthermore, the variable names we used weren't always intuitive.
25+
For instance, terms like 'medium' or 'large' didn't allow for easy interpolation between them.
26+
It was even harder to find an intermediate value between 'medium' and 'regular,' for example.
27+
28+
As a result, we decided to simplify and improve the theming process, making it more efficient and comprehensive.
29+
30+
### Configuration
31+
Everything now revolves around a configuration file named `_config.ts`.
32+
This file serves as a central configuration point where you can define the base theme values and declare theme variants.
33+
We've moved away from the complex layering system in favor of a more reflective system with main themes and variants.
34+
35+
### Theme Provider
36+
To boost performance, we introduced a `ThemeProvider` component. This component provides the theme to the application,
37+
preventing the need to regenerate the theme with every `useTheme` call.
38+
39+
### Type Inference
40+
We've also improved the type inference of the theme. Now each generated style is typed according to the theme configuration even if there are variants.
41+
For example, let's imagine a configuration like this:
42+
43+
```ts title=/src/theme/_config.ts
44+
export const config = {
45+
//...
46+
fonts: {
47+
//...
48+
colors: {
49+
primary: 'blue',
50+
},
51+
},
52+
//...
53+
variants: {
54+
dark: {
55+
fonts: {
56+
colors: {
57+
primary: 'darkblue',
58+
},
59+
},
60+
},
61+
premium: {
62+
fonts: {
63+
colors: {
64+
primary: 'gold',
65+
},
66+
},
67+
}
68+
}
69+
}
70+
```
71+
72+
The generated type will be inferred at the perfect level:
73+
![powerful typescript](./assets/theme-infer.png)
74+
75+
76+
## Goodbye Redux 🤧
77+
Redux is a fantastic library, but it's not always the best solution for every project.
78+
When we started the boilerplate, our goal was to provide a comprehensive solution for state management. In our initial version, we integrated Redux, Redux Persist, and Redux Saga, to name a few. These libraries were essential for managing the application's state, handling asynchronous requests, and persisting data.
79+
80+
However, over time, alternative solutions emerged,
81+
particularly in the realm of data fetching.
82+
It was with Redux Toolkit Query that we began version 3.
83+
Nonetheless, we decided to part ways with it for version 4.
84+
85+
Our aim has always been to offer a lightweight yet comprehensive solution
86+
without being too opinionated. Thus, we chose to remove Redux from the boilerplate
87+
in favor of lighter and more straightforward alternatives.
88+
It's important to note that global state management remains crucial in an application,
89+
and several options are available:
90+
91+
- Redux
92+
- Mobx
93+
- Zustand
94+
- Jotai
95+
- React Context
96+
- And more...
97+
98+
Now, in this version, for data fetching, we now use React Query,
99+
an excellent library that's straightforward to use.
100+
As for data storage, we rely on React Native MMKV, a native library known for its high performance and secure,
101+
synchronous data storage capabilities.
102+
103+
## Enhanced Documentation 💙
104+
We also took the opportunity to enhance the documentation.
105+
It's now clearer and more comprehensive.
106+
We've made an effort to make the documentation more accessible and easier to understand.
107+
At times, we've added 'playgrounds' in the section related to theme generation,
108+
allowing you to directly test the values you want and see the results for yourself

0 commit comments

Comments
 (0)