Skip to content

Commit 2def8f9

Browse files
Move font and text style to theme
1 parent 94def5a commit 2def8f9

51 files changed

Lines changed: 568 additions & 378 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"name": "@observation.org/react-native-components",
33
"version": "1.73.0",
44
"main": "src/index.ts",
5+
"exports": {
6+
".": "./src/index.ts",
7+
"./theme": "./src/theme/index.ts",
8+
"./styles": "./src/styles/index.ts"
9+
},
510
"repository": "git@github.com:observation/react-native-components.git",
611
"author": "Observation.org",
712
"license": "MIT",

src/@types/theme.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/components/Accordion.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { View } from 'react-native'
66
import { Collapse, CollapseBody, CollapseHeader } from 'accordion-collapse-react-native'
77

88
import Log from '../lib/Log'
9-
import { unsafeLayoutAnimation } from '../lib/Utils'
109

1110
type Item = {
1211
title: string
@@ -26,7 +25,6 @@ const Accordion = <T extends Item>({ list, header, footer, body, onOpen, ListEmp
2625

2726
const onToggle = (index: number, isExpanded: boolean) => {
2827
Log.debug('Accordion:onToggle', index, isExpanded)
29-
unsafeLayoutAnimation('Accordion:onToggle')
3028
if (isExpanded) {
3129
setActiveIndex(index)
3230
onOpen(index)

src/components/BackButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import { NavigationProp, ParamListBase } from '@react-navigation/native'
44

55
import IconButton from '../components/IconButton'
6-
import { useTheme } from '../theme/ThemeProvider'
6+
import { useTheme } from '../theme'
77

88
type Props = {
99
navigation: NavigationProp<ParamListBase>

src/components/BottomSheet.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'
44
import { useTheme as useNavigationTheme } from '@react-navigation/native'
55

66
import LargeButton, { LargeButtonProps } from './LargeButton'
7-
import { Theme } from '../@types/theme'
87
import { shadow } from '../styles'
9-
import textStyle from '../styles/text'
10-
import { useStyles, useTheme } from '../theme/ThemeProvider'
8+
import { Theme, useStyles, useTheme } from '../theme/'
119

1210
type Props = {
1311
title?: string
@@ -31,13 +29,13 @@ const BottomSheet = ({ title, text, buttons = [], style, testID, children }: Pro
3129
<View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
3230
{title && (
3331
<View style={{ flex: 1 }}>
34-
<Text style={textStyle.lead}>{title}</Text>
32+
<Text style={theme.text.lead}>{title}</Text>
3533
</View>
3634
)}
3735
</View>
3836
{text && (
3937
<View style={{ marginTop: theme.margin.half }}>
40-
<Text style={textStyle.body}>{text}</Text>
38+
<Text style={theme.text.body}>{text}</Text>
4139
</View>
4240
)}
4341
{children}

src/components/BrandIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
44

55
import BrandIcons, { BrandIconName } from '../lib/BrandIcons'
6-
import { useTheme } from '../theme/ThemeProvider'
6+
import { useTheme } from '../theme'
77

88
type Props = {
99
name: BrandIconName

src/components/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle } from 'react-
33

44
import { Icon } from './Icon'
55
import Log from '../lib/Log'
6-
import { useTheme } from '../theme/ThemeProvider'
6+
import { useTheme } from '../theme'
77

88
type Props = {
99
enabled: boolean

src/components/Chip.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import {
1010
ViewStyle,
1111
} from 'react-native'
1212

13-
import { Theme } from '../@types/theme'
14-
import { fontSize } from '../styles'
15-
import appTextStyle from '../styles/text'
16-
import { useStyles, useTheme } from '../theme/ThemeProvider'
13+
import { Theme, useStyles, useTheme } from '../theme'
1714

1815
type Props = {
1916
text?: string
@@ -48,10 +45,10 @@ const createStyles = (theme: Theme) =>
4845
justifyContent: 'center',
4946
},
5047
chipText: {
51-
...appTextStyle.body,
48+
...theme.text.body,
5249
color: theme.color.white,
5350
lineHeight: theme.margin.common,
54-
fontSize: fontSize.medium,
51+
fontSize: theme.fontSize.medium,
5552
},
5653
chipContainer: {
5754
backgroundColor: theme.color.accentLime400,

src/components/ContentImage.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { Dimensions, Image, StyleSheet, Text, TouchableOpacity, View } from 'rea
44
import ScalableImage from 'react-native-scalable-image'
55

66
import Lightbox from './Lightbox'
7-
import { Theme } from '../@types/theme'
8-
import { font, rounded, shadow } from '../styles'
9-
import { useTheme } from '../theme/ThemeProvider'
7+
import { rounded, shadow } from '../styles'
8+
import { Theme, useTheme } from '../theme'
109

1110
type Props = {
1211
src: string
@@ -89,12 +88,12 @@ const createStyles = (theme: Theme) =>
8988
justifyContent: 'center',
9089
},
9190
title: {
92-
...font.smallBold,
91+
...theme.font.smallBold,
9392
color: theme.color.black,
9493
marginBottom: theme.margin.quarter,
9594
},
9695
description: {
97-
...font.small,
96+
...theme.font.small,
9897
color: theme.color.grey500,
9998
},
10099
})

src/components/Date.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { StyleProp, ViewStyle } from 'react-native'
33

44
import { Icon } from './Icon'
55
import IconText from './IconText'
6-
import textStyle from '../styles/text'
76
import { useTheme } from '../theme/ThemeProvider'
87

98
type Props = {
@@ -19,7 +18,7 @@ const Date = ({ date, containerStyle }: Props) => {
1918
text={date}
2019
style={{
2120
containerStyle,
22-
textStyle: textStyle.light,
21+
textStyle: theme.text.light,
2322
}}
2423
singleLineText
2524
/>

0 commit comments

Comments
 (0)