Skip to content

Commit

Permalink
Richtext//RichtextCollapsible: add fontSize fixes #425 fonts: update …
Browse files Browse the repository at this point in the history
…font size to be same on all devices
  • Loading branch information
philli-m committed Mar 23, 2023
1 parent 9adc2f4 commit 809dbff
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
13 changes: 13 additions & 0 deletions src/components/Richtext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RenderHTML, {

import { baseUrl } from '../BaseApi'
import { COLORS } from '../theme/colors'
import { FONTS, SIZES } from '../theme/fonts'

import { LinkTextSourceSans } from './LinkTextSourceSans'
import { RichtextCollapsibleItem } from './RichtextCollapsibleItem'
Expand Down Expand Up @@ -106,6 +107,18 @@ export const Richtext = ({ text }) => {
},
a: {
color: COLORS.text
},
p: {
fontFamily: FONTS.familySans,
fontSize: SIZES.base,
},
li: {
fontFamily: FONTS.familySans,
fontSize: SIZES.base,
},
div: {
fontFamily: FONTS.familySans,
fontSize: SIZES.base,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/RichtextCollapsibleItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const RichtextCollapsibleItem = ({ title, body }) => {

return (
<TouchableOpacity
accessibilityRole="button"
accessibilityRole="button"
onPress={() => setCollapsed(!collapsed)}
>
<View style={styles.collapsibleButton}>
Expand All @@ -27,7 +27,7 @@ export const RichtextCollapsibleItem = ({ title, body }) => {
</View>
{!collapsed && (
<View style={styles.collapsibleBody}>
<Text>{body}</Text>
<Text style={styles.collapsibleBodyText}>{body}</Text>
</View>
)}
</TouchableOpacity>
Expand Down
6 changes: 5 additions & 1 deletion src/components/RichtextCollapsibleItem.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const styles = StyleSheet.create({
paddingTop: SPACINGS.multiplyBy(0.5),
paddingBottom: SPACINGS.multiplyBy(1.25),
marginBottom: SPACINGS.multiplyBy(0.5),
borderBottomWidth: 1
borderBottomWidth: 1,
},
collapsibleBodyText: {
fontFamily: FONTS.familySans,
fontSize: SIZES.base,
}
})
29 changes: 15 additions & 14 deletions src/theme/fonts.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
const baseFontSize = 18
const baseLineHeight = 22
import { PixelRatio } from 'react-native'

const pixelRatio = PixelRatio.getFontScale()

export const FONTS = {
familySans: 'SourceSansPro_400Regular',
familySemiBold: 'SourceSansPro_600SemiBold',
}

export const SIZES = {
xs: baseFontSize * 0.8125, //
sm: baseFontSize * 0.9375, //
base: baseFontSize,
md: baseFontSize * 1.0625, //
lg: baseFontSize * 1.25, //
xl: baseFontSize * 1.375, //
xxl: baseFontSize * 1.75, //
xs: pixelRatio * 13,
sm: pixelRatio * 16,
base: pixelRatio * 18,
md: pixelRatio * 20,
lg: pixelRatio * 22,
xl: pixelRatio * 28,
xxl: pixelRatio * 34,
}

export const LINEHEIGHTS = {
sm: baseLineHeight * 0.95,
base: baseLineHeight,
md: baseLineHeight * 1.1,
lg: baseLineHeight * 1.3,
xl: baseLineHeight * 1.9,
sm: pixelRatio * 21,
base: pixelRatio * 22,
md: pixelRatio * 24,
lg: pixelRatio * 28,
xl: pixelRatio * 30,
}

export const LETTERSPACING = {
Expand Down

0 comments on commit 809dbff

Please sign in to comment.