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

Reduce bundle size by 66% #67

Merged
merged 8 commits into from
Jan 24, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
!yarn.lock

# BUCK
buck-out/
Expand All @@ -56,4 +57,5 @@ android/keystores/debug.keystore
/lib/

# ignore generated icon files
/src/
src/*
!src/lib/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "core"]
path = core
url = [email protected]:phosphor-icons/core.git
1 change: 1 addition & 0 deletions core
Submodule core added at 24fd91
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default [
'src/thin/',
'src/index.tsx',
'example/',
'core/',
],
},
eslintPluginPrettierRecommended,
Expand Down
9 changes: 9 additions & 0 deletions example/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ export default function TabLayout() {
),
}}
/>
<Tabs.Screen
name="single-imports"
options={{
title: 'Single',
tabBarIcon: ({ color, focused }) => (
<TestTube weight={focused ? 'fill' : 'light'} color={color} />
),
}}
/>
</Tabs>
);
}
1 change: 1 addition & 0 deletions example/app/(tabs)/single-imports.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@/components/single-imports';
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable @typescript-eslint/no-explicit-any */

import React, { useCallback, useState, useMemo } from 'react';
import { useCallback, useState } from 'react';

import {
StyleSheet,
View,
Text,
StatusBar,
Image,
FlatList,
TouchableOpacity,
} from 'react-native';
import { Palette, PencilLine, Swap } from '@/components/icons';
import { SafeAreaView } from 'react-native-safe-area-context';
import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png';

import Swap from '@/components/icons/icons/Swap';
import Acorn from '@/components/icons/icons/Acorn';
import Palette from '@/components/icons/icons/Palette';
const weights = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone'];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const singleIcons = [Acorn, Palette, Swap]
export default function SingleImportsScreen() {
const [toggleActive, setToggleActive] = useState(false);

export default function HomeScreen() {
const [weightIdx, setWeightIdx] = useState(2);

const weight: IconWeight = useMemo(
() => weights[weightIdx] as any,
[weightIdx]
);

const handleChangeWeight = useCallback(() => {
setWeightIdx((weightIdx + 1) % weights.length);
}, [weightIdx]);

const handleChangeIconColor = useCallback(() => {
setIconColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`);
}, []);

const handleToggle = useCallback(() => {
setToggleActive(!toggleActive);
}, [toggleActive]);
return (
<View style={styles.rootView}>
<StatusBar barStyle="light-content" />

<View style={styles.headerContainer}>
<SafeAreaView style={styles.headerContainer}>
<View style={styles.header}>
<Image source={PhosphorLogo} style={styles.logoImage} />
<View
Expand All @@ -54,26 +47,32 @@ export default function HomeScreen() {
textTransform: 'capitalize',
}}
>
{weight}
Single imports
</Text>
</View>
<TouchableOpacity
style={styles.weightSelect}
onPress={handleChangeIconColor}
>
<Palette color="#FFF" weight={weight} />
</TouchableOpacity>
<TouchableOpacity
style={styles.weightSelect}
onPress={handleChangeWeight}
>
<PencilLine color="#FFF" weight={weight} />
</TouchableOpacity>
<TouchableOpacity style={styles.weightSelect}>
<Swap color="#FFF" weight={weight} />
<TouchableOpacity style={styles.weightSelect} onPress={handleToggle}>
<Swap color="#FFF" weight={'regular'} />
</TouchableOpacity>
</View>
</View>
</SafeAreaView>
<FlatList
style={styles.scrollView}
contentContainerStyle={styles.main}
data={singleIcons}
keyExtractor={(item) => item}
numColumns={3}
renderItem={({ item: Icon }) => (
<View style={styles.iconItem}>
<Icon
size={48}
weight={weights[Math.floor(Math.random() * 6)]}
color={`#${Math.floor(Math.random() * 16777215).toString(16)}`}
duotoneColor={`#${Math.floor(Math.random() * 16777215).toString(16)}`}
duotoneOpacity={Math.random()}
/>
</View>
)}
/>
</View>
);
}
Expand Down
36 changes: 19 additions & 17 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@
"lint": "eslint . --fix"
},
"dependencies": {
"@react-navigation/native": "^6.0.2",
"expo": "~51.0.39",
"expo-constants": "~16.0.2",
"expo-linking": "~6.3.1",
"expo-router": "~3.5.24",
"expo-splash-screen": "~0.27.7",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.5",
"react-native-gesture-handler": "~2.16.1",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"@react-navigation/bottom-tabs": "^7.2.0",
"@react-navigation/native": "^7.0.14",
"@react-navigation/native-stack": "^7.2.0",
"expo": "^52.0.27",
"expo-constants": "~17.0.4",
"expo-linking": "~7.0.4",
"expo-router": "~4.0.17",
"expo-splash-screen": "~0.29.21",
"expo-status-bar": "~2.0.1",
"expo-system-ui": "~4.0.7",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.76.6",
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "~3.16.1",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-svg": "15.8.0",
"react-native-web": "~0.19.13"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@eslint/js": "^9.9.0",
"@types/react": "~18.2.79",
"@types/react": "~18.3.12",
"eslint": "9.x",
"eslint-plugin-react": "^7.35.0",
"globals": "^15.9.0",
Expand Down
2 changes: 1 addition & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
".expo/types/**/*.ts",
"expo-env.d.ts"
]
}
}
Loading
Loading