Skip to content

Commit 59c067e

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent c2342db commit 59c067e

File tree

18 files changed

+582
-10730
lines changed

18 files changed

+582
-10730
lines changed

.eslintrc.js

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

.github/workflows/website-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v1
1313
- uses: actions/setup-node@v1
1414
with:
15-
node-version: '14.x'
15+
node-version: '22.x'
1616
- name: Test Build
1717
run: |
1818
if [ -e yarn.lock ]; then
@@ -30,7 +30,7 @@ jobs:
3030
- uses: actions/checkout@v1
3131
- uses: actions/setup-node@v1
3232
with:
33-
node-version: '14.x'
33+
node-version: '22.x'
3434
- name: Add key to allow access to repository
3535
env:
3636
SSH_AUTH_SOCK: /tmp/ssh_agent.sock

babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* Babel configuration for Docusaurus
3+
*
4+
* This configuration includes performance optimizations
5+
* for faster builds and better runtime performance
6+
*/
17
module.exports = {
28
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
9+
// For better performance
10+
assumptions: {
11+
constantReexports: true,
12+
constantSuper: true,
13+
noDocumentAll: true,
14+
noNewArrows: true,
15+
setPublicClassFields: true,
16+
},
317
};

docs/installation.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ sidebar_label: Installation
77
To install react-native-rooster's package:
88

99
```bash npm2yarn
10-
npm install --save react-native-rooster styled-components
10+
npm install --save react-native-rooster
1111
```
1212

13-
14-
**NOTE:** RNRooster relies on styled-components because it makes easier to handle different kinds of style props and also helps making the code cleaner. You should install manually styled-components in your project (using one of the commands above).
15-
1613
## Import and wrap your application within RNRooster's provider
1714

1815
You must import and wrap your application using our provider. Check out this [example](https://github.com/mCodex/react-native-rooster/blob/master/example/src/routes/index.tsx#L18-L20).

docusaurus.config.js

Lines changed: 113 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
module.exports = {
1+
// @ts-check
2+
// Note: type annotations allow type checking and IDEs autocompletion
3+
4+
/** @type {import('@docusaurus/types').Config} */
5+
const config = {
26
title: 'react-native-rooster 🐔',
37
tagline: 'An elegant and flexible toast solution for your react-native apps',
48
url: 'https://mcodex.dev',
@@ -7,13 +11,46 @@ module.exports = {
711
favicon: 'img/favicon.ico',
812
organizationName: 'mcodex',
913
projectName: 'react-native-rooster',
14+
15+
// Performance and SEO optimization
16+
trailingSlash: true,
17+
noIndex: false, // Allow search engine indexing
18+
19+
// Improved build settings
20+
staticDirectories: ['static'],
21+
22+
// Webpack configuration for better performance
23+
webpack: {
24+
jsLoader: (isServer) => ({
25+
loader: require.resolve('swc-loader'),
26+
options: {
27+
jsc: {
28+
parser: {
29+
syntax: 'ecmascript',
30+
jsx: true,
31+
},
32+
transform: {
33+
react: {
34+
runtime: 'automatic',
35+
},
36+
},
37+
},
38+
},
39+
}),
40+
},
41+
42+
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
1043
themeConfig: {
11-
prism: {
12-
theme: require('prism-react-renderer/themes/dracula'),
44+
// Replace dark mode by default
45+
colorMode: {
46+
defaultMode: 'light',
47+
respectPrefersColorScheme: true,
1348
},
14-
googleAnalytics: {
15-
trackingID: 'UA-79205996-7',
49+
prism: {
50+
theme: require('prism-react-renderer').themes.dracula,
1651
},
52+
// Google Analytics is now handled through gtag plugin
53+
// googleAnalytics has been removed in v3
1754
navbar: {
1855
title: 'react-native-rooster',
1956
logo: {
@@ -22,10 +59,10 @@ module.exports = {
2259
},
2360
items: [
2461
{
25-
to: 'docs/',
26-
activeBasePath: 'docs',
27-
label: 'Docs',
62+
type: 'docSidebar',
63+
sidebarId: 'tutorialSidebar',
2864
position: 'right',
65+
label: 'Docs',
2966
},
3067
{
3168
href: 'https://github.com/mcodex/react-native-rooster',
@@ -43,13 +80,25 @@ module.exports = {
4380
style: 'dark',
4481
copyright: `Copyright © ${new Date().getFullYear()} Made with ❤️ by mCodex`,
4582
},
83+
// Add image zoom
84+
zoom: {
85+
selector: '.markdown img',
86+
background: {
87+
light: 'rgb(255, 255, 255)',
88+
dark: 'rgb(50, 50, 50)'
89+
},
90+
config: {
91+
// options you can specify via https://github.com/francoischalifour/medium-zoom#usage
92+
},
93+
},
4694
},
4795
presets: [
4896
[
4997
'@docusaurus/preset-classic',
50-
{
98+
/** @type {import('@docusaurus/preset-classic').Options} */
99+
({
51100
docs: {
52-
homePageId: 'overview',
101+
routeBasePath: 'docs',
53102
sidebarPath: require.resolve('./sidebars.js'),
54103
editUrl:
55104
'https://github.com/mcodex/react-native-rooster/edit/website/website/',
@@ -63,7 +112,61 @@ module.exports = {
63112
theme: {
64113
customCss: require.resolve('./src/css/custom.css'),
65114
},
115+
googleAnalytics: {
116+
trackingID: 'UA-79205996-7',
117+
anonymizeIP: true,
118+
},
119+
sitemap: {
120+
changefreq: 'weekly',
121+
priority: 0.5,
122+
},
123+
}),
124+
],
125+
],
126+
127+
// Add plugins for better performance and SEO
128+
plugins: [
129+
[
130+
'@docusaurus/plugin-client-redirects',
131+
{
132+
fromExtensions: ['html'],
133+
createRedirects: function (existingPath) {
134+
// Redirect old paths to new paths if any
135+
return undefined;
136+
},
66137
},
67138
],
139+
() => ({
140+
name: 'docusaurus-optimizations',
141+
injectHtmlTags() {
142+
return {
143+
headTags: [
144+
{
145+
tagName: 'link',
146+
attributes: {
147+
rel: 'manifest',
148+
href: '/react-native-rooster/manifest.webmanifest',
149+
},
150+
},
151+
{
152+
tagName: 'meta',
153+
attributes: {
154+
name: 'theme-color',
155+
content: '#ff9100',
156+
},
157+
},
158+
{
159+
tagName: 'meta',
160+
attributes: {
161+
name: 'apple-mobile-web-app-capable',
162+
content: 'yes',
163+
},
164+
},
165+
],
166+
};
167+
},
168+
}),
68169
],
69170
};
171+
172+
module.exports = config;

eslint.config.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const {
2+
defineConfig,
3+
} = require("eslint/config");
4+
5+
const globals = require("globals");
6+
7+
const {
8+
fixupConfigRules,
9+
fixupPluginRules,
10+
} = require("@eslint/compat");
11+
12+
const react = require("eslint-plugin-react");
13+
const reactHooks = require("eslint-plugin-react-hooks");
14+
const js = require("@eslint/js");
15+
16+
const {
17+
FlatCompat,
18+
} = require("@eslint/eslintrc");
19+
20+
const compat = new FlatCompat({
21+
baseDirectory: __dirname,
22+
recommendedConfig: js.configs.recommended,
23+
allConfig: js.configs.all
24+
});
25+
26+
module.exports = defineConfig([{
27+
languageOptions: {
28+
globals: {
29+
...globals.browser,
30+
...globals.node,
31+
},
32+
33+
ecmaVersion: "latest",
34+
sourceType: "module",
35+
36+
parserOptions: {
37+
ecmaFeatures: {
38+
jsx: true,
39+
},
40+
},
41+
},
42+
43+
extends: fixupConfigRules(compat.extends(
44+
"plugin:react/recommended",
45+
"airbnb",
46+
"plugin:react-hooks/recommended",
47+
"plugin:prettier/recommended",
48+
)),
49+
50+
plugins: {
51+
react: fixupPluginRules(react),
52+
"react-hooks": fixupPluginRules(reactHooks),
53+
},
54+
55+
settings: {
56+
react: {
57+
version: "detect",
58+
},
59+
},
60+
61+
rules: {
62+
"react/prop-types": "off",
63+
64+
"react/jsx-filename-extension": ["error", {
65+
extensions: [".js", ".jsx", ".ts", ".tsx"],
66+
}],
67+
68+
"import/no-unresolved": ["error", {
69+
ignore: ["^@theme", "^@docusaurus", "^@site"],
70+
}],
71+
72+
"react/react-in-jsx-scope": "off",
73+
"react-hooks/rules-of-hooks": "error",
74+
"react-hooks/exhaustive-deps": "warn",
75+
76+
"import/extensions": ["error", "ignorePackages", {
77+
js: "never",
78+
jsx: "never",
79+
ts: "never",
80+
tsx: "never",
81+
}],
82+
},
83+
}]);

package.json

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@
66
"docusaurus": "docusaurus",
77
"start": "docusaurus start",
88
"build": "docusaurus build",
9+
"build:fast": "docusaurus build --bundle-analyzer --out-dir build",
910
"swizzle": "docusaurus swizzle",
1011
"deploy": "docusaurus deploy",
11-
"serve": "docusaurus serve"
12+
"serve": "docusaurus serve",
13+
"clear": "docusaurus clear",
14+
"write-translations": "docusaurus write-translations",
15+
"write-heading-ids": "docusaurus write-heading-ids",
16+
"typecheck": "tsc"
1217
},
1318
"dependencies": {
14-
"@docusaurus/core": "^2.0.0-alpha.61",
15-
"@docusaurus/preset-classic": "^2.0.0-alpha.61",
16-
"npm-to-yarn": "^1.0.1",
17-
"react": "^16.13.1",
18-
"react-dom": "^16.13.1"
19+
"@docusaurus/core": "^3.7.0",
20+
"@docusaurus/plugin-client-redirects": "^3.7.0",
21+
"@docusaurus/plugin-google-analytics": "^3.7.0",
22+
"@docusaurus/plugin-sitemap": "^3.7.0",
23+
"@docusaurus/preset-classic": "^3.7.0",
24+
"npm-to-yarn": "^3.0.1",
25+
"react": "^19.1.0",
26+
"react-dom": "^19.1.0"
1927
},
2028
"browserslist": {
2129
"production": [
@@ -30,14 +38,24 @@
3038
]
3139
},
3240
"devDependencies": {
33-
"eslint": "^7.6.0",
34-
"eslint-config-airbnb": "^18.2.0",
35-
"eslint-config-prettier": "^6.11.0",
36-
"eslint-plugin-import": "^2.22.0",
37-
"eslint-plugin-jsx-a11y": "^6.3.1",
38-
"eslint-plugin-prettier": "^3.1.4",
39-
"eslint-plugin-react": "^7.20.5",
40-
"eslint-plugin-react-hooks": "^4.0.8",
41-
"prettier": "^2.0.5"
42-
}
41+
"@docusaurus/module-type-aliases": "^3.7.0",
42+
"@eslint/eslintrc": "^3.3.1",
43+
"@eslint/js": "^9.26.0",
44+
"@swc/core": "^1.11.24",
45+
"@tsconfig/docusaurus": "^2.0.3",
46+
"eslint": "^9.26.0",
47+
"eslint-config-airbnb": "^19.0.4",
48+
"eslint-config-prettier": "^10.1.5",
49+
"eslint-plugin-import": "^2.31.0",
50+
"eslint-plugin-jsx-a11y": "^6.10.2",
51+
"eslint-plugin-prettier": "^5.4.0",
52+
"eslint-plugin-react": "^7.37.5",
53+
"eslint-plugin-react-hooks": "^5.2.0",
54+
"globals": "^16.1.0",
55+
"prettier": "^3.5.3",
56+
"sharp": "^0.34.1",
57+
"swc-loader": "^0.2.6",
58+
"typescript": "^5.8.3"
59+
},
60+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
4361
}

0 commit comments

Comments
 (0)