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

Add react-native-styled-system #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
36 changes: 20 additions & 16 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useFonts } from "expo-font";
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import { useFonts } from 'expo-font';
import { useState } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';

import Dripsy from "./components/Dripsy";
import EmotionNative from "./components/EmotionNative";
import Gluestack from "./components/Gluestack";
import NativeWind from "./components/NativeWind";
import Native from "./components/ReactNative";
import Restyle from "./components/Restyle";
import StyledComponents from "./components/StyledComponents";
import Tamagui from "./components/Tamagui";
import TimedRender from "./components/TimedRender";
import Twrnc from "./components/Twrnc";
import { Zephyr } from "./components/Zephyr";
import FastStyles from "./components/FastStyles";
import Unistyles from "./components/Unistyles";
import Dripsy from './components/Dripsy';
import EmotionNative from './components/EmotionNative';
import Gluestack from './components/Gluestack';
import NativeWind from './components/NativeWind';
import Native from './components/ReactNative';
import Restyle from './components/Restyle';
import StyledComponents from './components/StyledComponents';
import Tamagui from './components/Tamagui';
import TimedRender from './components/TimedRender';
import Twrnc from './components/Twrnc';
import { Zephyr } from './components/Zephyr';
import FastStyles from './components/FastStyles';
import Unistyles from './components/Unistyles';
import { ReactNativeStyledSystem } from './components/ReactNativeStyledSystem';

export default function App() {
const [styleType, setStyleType] = useState(undefined);
Expand Down Expand Up @@ -49,6 +50,8 @@ export default function App() {
return <FastStyles />;
case "Unistyles":
return <Unistyles />;
case "ReactNativeStyledSystem":
return <ReactNativeStyledSystem />;
default:
return null;
}
Expand Down Expand Up @@ -90,6 +93,7 @@ export default function App() {
<Button title="Tamagui" onPress={onStyleTypePress("Tamagui")} />
<Button title="Gluestack" onPress={onStyleTypePress("Gluestack")} />
<Button title="Dripsy" onPress={onStyleTypePress("Dripsy")} />
<Button title="ReactNativeStyledSystem" onPress={onStyleTypePress("ReactNativeStyledSystem")} />
{styleType ? (
<TimedRender key={styleType}>
<Text style={styles.text}>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Original reproducer was created by @tj-mc: https://github.com/tj-mc/styled-compo

This is an Expo SDK 49 App reproducer to demonstrate the performance difference between popular style libraries and react-native built-in styling.

Tests include React Native [StyleSheet](https://reactnative.dev/docs/stylesheet), [Styled Components](https://github.com/styled-components/styled-components), [Tamagui](https://github.com/tamagui/tamagui), [NativeWind](https://github.com/marklawlor/nativewind), [Emotion](https://github.com/emotion-js/emotion), [Zephyr](https://github.com/FormidableLabs/react-native-zephyr), [Dripsy](https://github.com/nandorojo/dripsy), Gluestack [[1]](https://github.com/gluestack/gluestack-ui) [[2]](https://github.com/gluestack/gluestack-style), [fast-styles](https://github.com/fedemartinm/fast-styles), [Tailwind React Native Classnames(twrnc)](https://github.com/jaredh159/tailwind-react-native-classnames), Shopify's [restyle](https://github.com/Shopify/restyle) and [react-native-unistyles](https://github.com/jpudysz/react-native-unistyles)
Tests include React Native [StyleSheet](https://reactnative.dev/docs/stylesheet), [Styled Components](https://github.com/styled-components/styled-components), [Tamagui](https://github.com/tamagui/tamagui), [NativeWind](https://github.com/marklawlor/nativewind), [Emotion](https://github.com/emotion-js/emotion), [Zephyr](https://github.com/FormidableLabs/react-native-zephyr), [Dripsy](https://github.com/nandorojo/dripsy), Gluestack [[1]](https://github.com/gluestack/gluestack-ui) [[2]](https://github.com/gluestack/gluestack-style), [fast-styles](https://github.com/fedemartinm/fast-styles), [Tailwind React Native Classnames(twrnc)](https://github.com/jaredh159/tailwind-react-native-classnames), Shopify's [restyle](https://github.com/Shopify/restyle), [react-native-unistyles](https://github.com/jpudysz/react-native-unistyles) and [react-native-styled-system](https://github.com/mj-studio-library/react-native-styled-system)

Feel free to fork or PR this repo with improvements or to include other styling libraries.

Expand Down
35 changes: 35 additions & 0 deletions components/ReactNativeStyledSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { View } from 'react-native';
import { COUNT } from '../utils';
import { StyledSystemProvider, useSx } from '@react-native-styled-system/core';

const AppTheme = {
colors: {
red: '#F00',
},
space: {1: 5},
sizes: {},
radii: {},
typography: {},
};

export const ReactNativeStyledSystem = () => {
return (
<StyledSystemProvider theme={AppTheme}>
<View style={{ display: 'flex', flexDirection: 'row' }}>
{new Array(COUNT).fill(0).map((_, i) => (
<StyledView
key={i}
borderWidth={2}
p={1}
borderColor={'red'}
/>
))}
</View>
</StyledSystemProvider>
);
};

const StyledView = (props) => {
const { getStyle, filteredProps } = useSx(props);
return <View style={getStyle()} {...filteredProps} />;
};
Loading