Skip to content

Commit 9573d7f

Browse files
authored
feat: Reduce bundle size by 66% (#67)
* feat: change icon generation logic * feat: change icon generation logic * feat: add name prop to IconBase for dynamic class and testID generation * feat: add SingleImportsScreen component and integrate into TabLayout * fix: exclude yarn.lock from .gitignore to ensure it is tracked * chore: update Node.js version in CI workflow and include 'core/' in ESLint paths * feat: clean up unused PaintFunction type * fix: update SVG generation to join lines with newline character
1 parent bcc9e2f commit 9573d7f

File tree

18 files changed

+6154
-6818
lines changed

18 files changed

+6154
-6818
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v4
1010
- uses: actions/setup-node@v4
1111
with:
12-
node-version: 18
12+
node-version: 22
1313

1414
- name: Get yarn cache directory path
1515
id: yarn-cache-dir-path

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ node_modules/
4242
npm-debug.log
4343
yarn-debug.log
4444
yarn-error.log
45+
!yarn.lock
4546

4647
# BUCK
4748
buck-out/
@@ -56,4 +57,5 @@ android/keystores/debug.keystore
5657
/lib/
5758

5859
# ignore generated icon files
59-
/src/
60+
src/*
61+
!src/lib/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "core"]
2+
path = core
3+
url = [email protected]:phosphor-icons/core.git

core

Submodule core added at 24fd919

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default [
2121
'src/thin/',
2222
'src/index.tsx',
2323
'example/',
24+
'core/',
2425
],
2526
},
2627
eslintPluginPrettierRecommended,

example/app/(tabs)/_layout.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export default function TabLayout() {
3434
),
3535
}}
3636
/>
37+
<Tabs.Screen
38+
name="single-imports"
39+
options={{
40+
title: 'Single',
41+
tabBarIcon: ({ color, focused }) => (
42+
<TestTube weight={focused ? 'fill' : 'light'} color={color} />
43+
),
44+
}}
45+
/>
3746
</Tabs>
3847
);
3948
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@/components/single-imports';
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
/* eslint-disable react-native/no-inline-styles */
2-
/* eslint-disable @typescript-eslint/no-explicit-any */
32

4-
import React, { useCallback, useState, useMemo } from 'react';
3+
import { useCallback, useState } from 'react';
4+
55
import {
66
StyleSheet,
77
View,
88
Text,
99
StatusBar,
1010
Image,
11+
FlatList,
1112
TouchableOpacity,
1213
} from 'react-native';
13-
import { Palette, PencilLine, Swap } from '@/components/icons';
14+
import { SafeAreaView } from 'react-native-safe-area-context';
1415
import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png';
15-
16+
import Swap from '@/components/icons/icons/Swap';
17+
import Acorn from '@/components/icons/icons/Acorn';
18+
import Palette from '@/components/icons/icons/Palette';
1619
const weights = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone'];
20+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
21+
const singleIcons = [Acorn, Palette, Swap]
22+
export default function SingleImportsScreen() {
23+
const [toggleActive, setToggleActive] = useState(false);
1724

18-
export default function HomeScreen() {
19-
const [weightIdx, setWeightIdx] = useState(2);
20-
21-
const weight: IconWeight = useMemo(
22-
() => weights[weightIdx] as any,
23-
[weightIdx]
24-
);
25-
26-
const handleChangeWeight = useCallback(() => {
27-
setWeightIdx((weightIdx + 1) % weights.length);
28-
}, [weightIdx]);
29-
30-
const handleChangeIconColor = useCallback(() => {
31-
setIconColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`);
32-
}, []);
33-
25+
const handleToggle = useCallback(() => {
26+
setToggleActive(!toggleActive);
27+
}, [toggleActive]);
3428
return (
3529
<View style={styles.rootView}>
3630
<StatusBar barStyle="light-content" />
37-
38-
<View style={styles.headerContainer}>
31+
<SafeAreaView style={styles.headerContainer}>
3932
<View style={styles.header}>
4033
<Image source={PhosphorLogo} style={styles.logoImage} />
4134
<View
@@ -54,26 +47,32 @@ export default function HomeScreen() {
5447
textTransform: 'capitalize',
5548
}}
5649
>
57-
{weight}
50+
Single imports
5851
</Text>
5952
</View>
60-
<TouchableOpacity
61-
style={styles.weightSelect}
62-
onPress={handleChangeIconColor}
63-
>
64-
<Palette color="#FFF" weight={weight} />
65-
</TouchableOpacity>
66-
<TouchableOpacity
67-
style={styles.weightSelect}
68-
onPress={handleChangeWeight}
69-
>
70-
<PencilLine color="#FFF" weight={weight} />
71-
</TouchableOpacity>
72-
<TouchableOpacity style={styles.weightSelect}>
73-
<Swap color="#FFF" weight={weight} />
53+
<TouchableOpacity style={styles.weightSelect} onPress={handleToggle}>
54+
<Swap color="#FFF" weight={'regular'} />
7455
</TouchableOpacity>
7556
</View>
76-
</View>
57+
</SafeAreaView>
58+
<FlatList
59+
style={styles.scrollView}
60+
contentContainerStyle={styles.main}
61+
data={singleIcons}
62+
keyExtractor={(item) => item}
63+
numColumns={3}
64+
renderItem={({ item: Icon }) => (
65+
<View style={styles.iconItem}>
66+
<Icon
67+
size={48}
68+
weight={weights[Math.floor(Math.random() * 6)]}
69+
color={`#${Math.floor(Math.random() * 16777215).toString(16)}`}
70+
duotoneColor={`#${Math.floor(Math.random() * 16777215).toString(16)}`}
71+
duotoneOpacity={Math.random()}
72+
/>
73+
</View>
74+
)}
75+
/>
7776
</View>
7877
);
7978
}

example/package.json

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,30 @@
1010
"lint": "eslint . --fix"
1111
},
1212
"dependencies": {
13-
"@react-navigation/native": "^6.0.2",
14-
"expo": "~51.0.39",
15-
"expo-constants": "~16.0.2",
16-
"expo-linking": "~6.3.1",
17-
"expo-router": "~3.5.24",
18-
"expo-splash-screen": "~0.27.7",
19-
"expo-status-bar": "~1.12.1",
20-
"expo-system-ui": "~3.0.7",
21-
"react": "18.2.0",
22-
"react-dom": "18.2.0",
23-
"react-native": "0.74.5",
24-
"react-native-gesture-handler": "~2.16.1",
25-
"react-native-reanimated": "~3.10.1",
26-
"react-native-safe-area-context": "4.10.5",
27-
"react-native-screens": "3.31.1",
28-
"react-native-svg": "15.2.0",
13+
"@react-navigation/bottom-tabs": "^7.2.0",
14+
"@react-navigation/native": "^7.0.14",
15+
"@react-navigation/native-stack": "^7.2.0",
16+
"expo": "^52.0.27",
17+
"expo-constants": "~17.0.4",
18+
"expo-linking": "~7.0.4",
19+
"expo-router": "~4.0.17",
20+
"expo-splash-screen": "~0.29.21",
21+
"expo-status-bar": "~2.0.1",
22+
"expo-system-ui": "~4.0.7",
23+
"react": "18.3.1",
24+
"react-dom": "18.3.1",
25+
"react-native": "0.76.6",
26+
"react-native-gesture-handler": "~2.20.2",
27+
"react-native-reanimated": "~3.16.1",
28+
"react-native-safe-area-context": "4.12.0",
29+
"react-native-screens": "~4.4.0",
30+
"react-native-svg": "15.8.0",
2931
"react-native-web": "~0.19.13"
3032
},
3133
"devDependencies": {
3234
"@babel/core": "^7.24.0",
3335
"@eslint/js": "^9.9.0",
34-
"@types/react": "~18.2.79",
36+
"@types/react": "~18.3.12",
3537
"eslint": "9.x",
3638
"eslint-plugin-react": "^7.35.0",
3739
"globals": "^15.9.0",

example/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
".expo/types/**/*.ts",
1515
"expo-env.d.ts"
1616
]
17-
}
17+
}

0 commit comments

Comments
 (0)