Skip to content

bogoslavskiy/react-native-steezy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

988d545 · May 22, 2023

History

9 Commits
Nov 1, 2022
May 22, 2023
Oct 30, 2022
Oct 30, 2022
Nov 1, 2022
May 22, 2023
Oct 30, 2022
Oct 30, 2022

Repository files navigation

React Native Steezy

Create Steezy

export const media = createMediaStyleVars({
  isTablet: {
    minWidth: 706,
  },
  isLandscape: {
    orientation: 'landscape'
  }
});

export const variables = createDynamicStyleVars(() => {
  const safeArea = useSafeAreaInsets();
  const theme = useTheme();

  return {
    colors: theme.colors,
    safeArea,
  };
});

export const Steezy = createSteezy({
  variables,
  media,
});

Wrap Native Components

import { 
  View as NativeView 
  Text as NativeText
} from 'react-native';

export const View = Steezy.withStyle(NativeView);
export const Text = Steezy.withStyle(NativeText);

Create styles

const Component = () => (
  <View style={styles.container}>
    <Text style={styles.text}>Text</Text>
  </View>
);

const styles = Steezy.create(({ colors, safeArea, isTablet, isLandscape }) => ({
  container: {
    flex: 1,
    backgroundColor: colors.border,
    alignItems: 'center',
    justifyContent: 'center',
    marginTop: safeArea.top,
    marginBottom: safeArea.bottom,

    [isTablet]: {
      backgroundColor: colors.primary,
    },
    [isLandscape]: {
      backgroundColor: 'red',
    }
  },
  text: {
    color: 'green',
    
    [isLandscape]: {
      color: '#FFF',
    }
  }
}));

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published