refactored colors and text styles

This commit is contained in:
austinried 2021-06-19 21:48:55 +09:00
parent d82be24992
commit 71563985c0
7 changed files with 44 additions and 48 deletions

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { Image, ImageSourcePropType } from 'react-native'; import { Image, ImageSourcePropType } from 'react-native';
import { primary } from '../styles/colors'; import colors from '../styles/colors';
export type FocusableIconProps = { export type FocusableIconProps = {
focused: boolean, focused: boolean,
@ -20,7 +20,7 @@ const FocusableIcon: React.FC<FocusableIconProps> = (props) => {
style={{ style={{
height: props.height, height: props.height,
width: props.width, width: props.width,
tintColor: props.focused ? primary.focused : primary.blurred, tintColor: props.focused ? colors.text.primary : colors.text.secondary,
}} }}
source={props.focused ? props.focusedSource : props.source} source={props.focused ? props.focusedSource : props.source}
/> />

View File

@ -2,6 +2,7 @@ import React from 'react';
import { Text, View, Image, Pressable } from 'react-native'; import { Text, View, Image, Pressable } from 'react-native';
import { BottomTabBarProps } from '@react-navigation/bottom-tabs'; import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
import textStyles from '../../styles/text'; import textStyles from '../../styles/text';
import colors from '../../styles/colors';
const icons: {[key: string]: any} = { const icons: {[key: string]: any} = {
home: { home: {
@ -26,7 +27,7 @@ const BottomTabBar: React.FC<BottomTabBarProps> = ({ state, descriptors, navigat
return ( return (
<View style={{ <View style={{
height: 54, height: 54,
backgroundColor: '#383838', backgroundColor: colors.gradient.high,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-around', justifyContent: 'space-around',
@ -70,13 +71,12 @@ const BottomTabBar: React.FC<BottomTabBarProps> = ({ state, descriptors, navigat
style={{ style={{
height: 24, height: 24,
width: 24, width: 24,
tintColor: isFocused ? 'white' : '#a0a0a0', tintColor: isFocused ? colors.text.primary : colors.text.secondary,
}} }}
/> />
<Text style={{ <Text style={{
...textStyles.small, ...textStyles.small,
color: isFocused ? 'white' : '#a0a0a0', color: isFocused ? colors.text.primary : colors.text.secondary,
fontFamily: isFocused ? 'Ubuntu-Medium' : 'Ubuntu-Light',
}}> }}>
{label} {label}
</Text> </Text>

View File

@ -1,17 +1,16 @@
import React from 'react'; import React from 'react';
import { Text, View } from 'react-native'; import { Text, View } from 'react-native';
import { MaterialTopTabBarProps } from '@react-navigation/material-top-tabs'; import { MaterialTopTabBarProps } from '@react-navigation/material-top-tabs';
import { primary } from '../../styles/colors'; import colors from '../../styles/colors';
import text from '../../styles/text'; import textStyles from '../../styles/text';
const TopTabBar: React.FC<MaterialTopTabBarProps> = ({ state, descriptors }) => { const TopTabBar: React.FC<MaterialTopTabBarProps> = ({ state, descriptors }) => {
return ( return (
<View style={{ <View style={{
height: 48, backgroundColor: colors.gradient.high,
backgroundColor: '#383838',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-around', justifyContent: 'space-evenly',
}}> }}>
{state.routes.map((route, index) => { {state.routes.map((route, index) => {
const { options } = descriptors[route.key]; const { options } = descriptors[route.key];
@ -23,24 +22,21 @@ const TopTabBar: React.FC<MaterialTopTabBarProps> = ({ state, descriptors }) =>
: route.name; : route.name;
const isFocused = state.index === index; const isFocused = state.index === index;
const fontFamily = isFocused ? 'Ubuntu-Regular' : 'Ubuntu-Light'; const color = isFocused ? colors.text.primary : colors.text.secondary;
const color = isFocused ? primary.focused : primary.blurred; const borderBottomColor = isFocused ? colors.accent : colors.gradient.high;
const borderBottomColor = isFocused ? primary.focused : '#383838';
return ( return (
<View style={{ <View key={route.key} style={{
borderBottomColor, borderBottomColor,
borderBottomWidth: 2, borderBottomWidth: 1.5,
borderBottomLeftRadius: 2, paddingVertical: 8,
borderBottomEndRadius: 2,
paddingBottom: 5,
width: 100, width: 100,
height: 38,
justifyContent: 'center', justifyContent: 'center',
flexDirection: 'row', alignItems: 'center',
}}> }}>
<Text style={{ <Text style={{
...text.header, ...textStyles.header, color,
fontFamily, color
}}>{label}</Text> }}>{label}</Text>
</View> </View>
); );

View File

@ -1,12 +1,11 @@
import React from 'react'; import React from 'react';
import LinearGradient from 'react-native-linear-gradient'; import LinearGradient from 'react-native-linear-gradient';
import colors from '../../styles/colors';
const TopTabContainer: React.FC<{}> = ({ children }) => ( const TopTabContainer: React.FC<{}> = ({ children }) => (
<LinearGradient <LinearGradient
colors={['#383838', '#000000']} colors={[colors.gradient.high, colors.gradient.mid, colors.gradient.low]}
// colors={['#395266', '#06172d']} locations={[0.03,0.3,0.7]}
// start={{x: 0.0, y: 0.25}} end={{x: 0.5, y: 1.0}}
locations={[0.05,0.75]}
style={{ style={{
flex: 1, flex: 1,
}} }}

View File

@ -3,14 +3,13 @@ import { Text, View, Image, FlatList } from 'react-native';
import { Artist } from '../../models/music'; import { Artist } from '../../models/music';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { artistsState } from '../../state/artists'; import { artistsState } from '../../state/artists';
import text from '../../styles/text'; import textStyles from '../../styles/text';
import TopTabContainer from '../common/TopTabContainer'; import TopTabContainer from '../common/TopTabContainer';
const ArtistItem: React.FC<{ item: Artist } > = ({ item }) => ( const ArtistItem: React.FC<{ item: Artist } > = ({ item }) => (
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
// height: 56,
marginVertical: 6, marginVertical: 6,
marginLeft: 6, marginLeft: 6,
}}> }}>
@ -19,11 +18,10 @@ const ArtistItem: React.FC<{ item: Artist } > = ({ item }) => (
style={{ style={{
width: 56, width: 56,
height: 56, height: 56,
// tintColor: 'white',
}} }}
/> />
<Text style={{ <Text style={{
...text.regular, ...textStyles.paragraph,
marginLeft: 12, marginLeft: 12,
}}>{item.name}</Text> }}>{item.name}</Text>
</View> </View>

View File

@ -1,6 +1,12 @@
import { StyleSheet } from "react-native"; export default {
text: {
export const primary = { primary: '#ffffff',
focused: '#fff', secondary: '#999999',
blurred: '#bababa', },
gradient: {
high: '#2d2d2d',
mid: '#191919',
low: '#000000',
},
accent: '#c260e5',
} }

View File

@ -1,27 +1,24 @@
import { StyleSheet, TextStyle } from "react-native"; import { TextStyle } from "react-native";
import colors from './colors';
const regular: TextStyle = { const paragraph: TextStyle = {
fontFamily: 'Ubuntu-Light', fontFamily: 'Ubuntu-Light',
fontSize: 18, fontSize: 16,
color: '#fff', color: colors.text.primary,
}; };
const header: TextStyle = { const header: TextStyle = {
...regular, ...paragraph,
fontSize: 22, fontSize: 18,
}; };
const small: TextStyle = { const small: TextStyle = {
...regular, ...paragraph,
fontSize: 11, fontSize: 11,
}; };
export type TextStyles = {
[key: string]: TextStyle,
}
export default { export default {
regular, paragraph,
header, header,
small, small,
}; };