@janiscommerce/ui-native
Version:
components library for Janis app
20 lines (19 loc) • 667 B
JavaScript
import { StyleSheet } from 'react-native';
import typography from '../../../../../theme/typography';
const getStyleByTypography = (type = 'body', size = 'medium', color) => {
const validType = Object.keys(typography).includes(type)
? type
: 'body';
const typographyCategory = typography[validType];
const validSize = Object.keys(typographyCategory).includes(size)
? size
: 'medium';
const typographyStyle = typographyCategory[validSize];
return StyleSheet.create({
typography: {
...typographyStyle,
...(color && { color }),
},
});
};
export default getStyleByTypography;