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

+3-1
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

+3-1
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

+1-1
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

+1
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

-5
This file was deleted.

.npmignore

+1-2
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

-103
This file was deleted.

documentation/README.md

-16
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

+4-8
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 🧪 !!
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
142 KB
Loading
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
slug: /getting-started
3+
sidebar_label: Getting Started
4+
title: Introduction
5+
id: getting-started
6+
keywords: ['react-native', 'boilerplate', 'template', 'starter', 'getting started']
7+
---
8+
import VersionReader from '../src/components/VersionReader'
9+
import Tom from '../src/components/Tom'
10+
11+
Welcome to the React Native Boilerplate documentation!
12+
<Tom />
13+
14+
This React Native template project is here to jumpstart your mobile app development journey.
15+
What makes it stand out? Its simplicity, lightweight nature, and scalability.
16+
17+
We've crafted it on a sturdy foundation to ensure easy maintenance, without forcing you into a web of unnecessary dependencies.
18+
19+
Our main goal in designing this boilerplate was to keep things simple and focus on the core principles of React Native,
20+
all while maintaining a clear separation of concerns.
21+
22+
:::tip Don't forget !!
23+
If you find value in this boilerplate, consider giving us a star. It would brighten our day like a ray of sunshine! 🌈☀️
24+
:::
25+
26+
## Features
27+
28+
| Features | Description |
29+
| ---------------------------------------------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30+
| [`Javascript or TypeScript`](/docs/installation#using-the-boilerplate) | Every project, developer, team, and experience is unique. That's why you have the freedom to select either a JavaScript or TypeScript codebase. [The choice is yours!](/docs/installation#using-the-boilerplate) |
31+
| [`Navigation`](/docs/navigate) | With [React Navigation](https://reactnavigation.org/), we offer a swift start to your navigation structure through a robust dependency. Check out the details in our [navigation structure documentation](/docs/navigate#navigation-structure). |
32+
| [`Data fetching`](/docs/data-fetching)| Leveraging [TanStackQuery](https://react-query.tanstack.com/), data fetching has never been this effortless. |
33+
| [`Internationalization`](/docs/internationalization) | Our application is fully prepared for multilingual support, all thanks to [React i18next](https://react.i18next.com/). |
34+
| [`Multi theming`](/docs/theming/how-to-use) | Without any extra dependencies, we offer an easy-to-use and maintainable theme configuration |
35+
| [`Safe synchrone storage`](/docs/storage) | With [React Native MMKV](https://www.npmjs.com/package/@react-navigation/devtools), storing data becomes a breeze, and it can be done securely. |
36+
| [`Environment`](/docs/environment) | The app comes pre-installed with all the necessary tools for handling simple environment variables |
37+
| [`Debug`](/docs/debugging) | The app comes pre-installed with all the necessary tools for debugging, including [Flipper](https://fbflipper.com/) and [Navigation DevTools](https://www.npmjs.com/package/@react-navigation/devtools). |
38+
39+
40+
## Dependencies
41+
42+
As previously mentioned, this boilerplate is intentionally designed to be straightforward and lightweight, steering clear of unnecessary dependencies. It relies on the following key dependencies:
43+
44+
- [React Native](https://reactnative.dev/) (**<VersionReader name="react-native"/>**): Used for building the native app with React.
45+
- [React](https://react.dev/) (**<VersionReader name="react"/>**): Empowers the native app with React.
46+
- [React Native MMKV](https://github.com/mrousavy/react-native-mmkv) (**<VersionReader name="react-native-mmkv"/>**): A highly efficient and compact mobile key-value storage solution.
47+
- [React Navigation](https://reactnavigation.org/) (**<VersionReader name="@react-navigation/native"/>**): Handles routing and navigation within the app, featuring a default splash screen setup.
48+
- [TanStack Query](https://tanstack.com/query/latest) (**<VersionReader name="@tanstack/react-query"/>**): Facilitates data fetching.
49+
- [Axios](https://axios-http.com/fr/docs/intro) (**<VersionReader name="axios"/>**): Used for making HTTP requests.
50+
- [React i18next](https://github.com/i18next/react-i18next) (**<VersionReader name="react-i18next"/>**): Manages internationalization within your app.
51+
52+
:::info Just for you
53+
This boilerplate comes complete with an example that demonstrates everything from UI components to business logic, showcasing fake user data. We've made it easy for you to remove this example if it doesn't align with your project requirements, ensuring it won't hinder your progress.
54+
:::
55+
56+
## Updates
57+
58+
This boilerplate will stay in sync with the latest React Native releases as soon as the libraries and tools used here become compatible.
59+
60+
Now, prepare yourself for an exhilarating journey with this React Native boilerplate! 🚀

0 commit comments

Comments
 (0)