Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added body font #124

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/funke/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ const config = {
'expo-font',
{
fonts: [
'../../node_modules/@expo-google-fonts/open-sans/OpenSans_400Regular.ttf',
'../../node_modules/@expo-google-fonts/open-sans/OpenSans_500Medium.ttf',
'../../node_modules/@expo-google-fonts/open-sans/OpenSans_600SemiBold.ttf',
'../../node_modules/@expo-google-fonts/open-sans/OpenSans_700Bold.ttf',
'../../node_modules/@expo-google-fonts/raleway/Raleway_400Regular.ttf',
'../../node_modules/@expo-google-fonts/raleway/Raleway_500Medium.ttf',
'../../node_modules/@expo-google-fonts/raleway/Raleway_600SemiBold.ttf',
Expand Down
1 change: 1 addition & 0 deletions apps/funke/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"prebuild": "APP_VARIANT=development expo prebuild --no-install"
},
"dependencies": {
"@expo-google-fonts/open-sans": "^0.2.3",
"@expo-google-fonts/raleway": "^0.2.3",
"@gorhom/bottom-sheet": "^4.6.3",
"@hyperledger/anoncreds-react-native": "^0.2.2",
Expand Down
5 changes: 3 additions & 2 deletions apps/funke/tamagui.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// instead this is just setting types for this folder
import { radius, size, space, zIndex } from '@tamagui/themes'

import { configInput, fontRaleway, hexColors } from '@package/ui/src/config/tamagui.config'
import { configInput, fontOpenSans, fontRaleway, hexColors } from '@package/ui/src/config/tamagui.config'
import { createTamagui, createTokens } from 'tamagui'

export const tokensInput = {
Expand Down Expand Up @@ -43,7 +43,8 @@ const config = createTamagui({
...configInput,
tokens,
fonts: {
default: fontRaleway,
default: fontOpenSans,
heading: fontRaleway,
},
themes: {
dark: {
Expand Down
3 changes: 2 additions & 1 deletion apps/storybook/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:slnt,[email protected],100..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Raleway:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Raleway:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&display=swap" rel="stylesheet">
6 changes: 5 additions & 1 deletion apps/storybook/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"../../node_modules/@expo-google-fonts/raleway/Raleway_400Regular.ttf",
"../../node_modules/@expo-google-fonts/raleway/Raleway_500Medium.ttf",
"../../node_modules/@expo-google-fonts/raleway/Raleway_600SemiBold.ttf",
"../../node_modules/@expo-google-fonts/raleway/Raleway_700Bold.ttf"
"../../node_modules/@expo-google-fonts/raleway/Raleway_700Bold.ttf",
"../../node_modules/@expo-google-fonts/open-sans/OpenSans_400Regular.ttf",
"../../node_modules/@expo-google-fonts/open-sans/OpenSans_500Medium.ttf",
"../../node_modules/@expo-google-fonts/open-sans/OpenSans_600SemiBold.ttf",
"../../node_modules/@expo-google-fonts/open-sans/OpenSans_700Bold.ttf"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/base/Headings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Heading as THeading, styled } from 'tamagui'
export const Heading = styled(THeading, {
name: 'Heading',
tag: 'span',
fontFamily: '$default',
fontFamily: '$heading',
fontWeight: '$medium',
userSelect: 'auto',
accessibilityRole: 'header',
Expand Down
46 changes: 42 additions & 4 deletions packages/ui/src/config/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@ import { createInterFont } from '@tamagui/font-inter'
import { Platform } from 'react-native'
import { createFont } from 'tamagui'

export const fontOpenSans = createFont({
family: 'OpenSans',
weight: {
regular: '400',
1: '400',

medium: '500',
3: '500',

semiBold: '600',
5: '600',

bold: '700',
7: '700',
},
size: {
1: 12, // Annotation
2: 14, // Sub text
3: 16, // Body text
true: 16,
4: 18, // Heading 3
5: 20, // Heading 2
6: 24, // Heading 1
7: 38, // Page Title
},
letterSpacing: {
4: 0,
},
face: {
// Android uses filename, iOS uses PostScript name (configured in app.config.js with expo-font plugin)
'400': { normal: Platform.select({ ios: 'OpenSans-Regular', android: 'OpenSans_400Regular' }) },
'500': { normal: Platform.select({ ios: 'OpenSans-Medium', android: 'OpenSans_500Medium' }) },
'600': { normal: Platform.select({ ios: 'OpenSans-SemiBold', android: 'OpenSans_600SemiBold' }) },
'700': { normal: Platform.select({ ios: 'OpenSans-Bold', android: 'OpenSans_700Bold' }) },
},
})

export const fontRaleway = createFont({
family: 'Raleway',
weight: {
Expand Down Expand Up @@ -31,11 +68,12 @@ export const fontRaleway = createFont({
4: 0,
},
face: {
// Raleway is a lighter font in terms of weight, so we move all the weights one step up.
// Android uses filename, iOS uses PostScript name (configured in app.config.js with expo-font plugin)
'400': { normal: Platform.select({ ios: 'Raleway-Regular', android: 'Raleway_400Regular' }) },
'500': { normal: Platform.select({ ios: 'Raleway-Medium', android: 'Raleway_500Medium' }) },
'600': { normal: Platform.select({ ios: 'Raleway-SemiBold', android: 'Raleway_600SemiBold' }) },
'700': { normal: Platform.select({ ios: 'Raleway-Bold', android: 'Raleway_700Bold' }) },
'300': { normal: Platform.select({ ios: 'Raleway-Regular', android: 'Raleway_400Regular' }) },
'400': { normal: Platform.select({ ios: 'Raleway-Medium', android: 'Raleway_500Medium' }) },
'500': { normal: Platform.select({ ios: 'Raleway-SemiBold', android: 'Raleway_600SemiBold' }) },
'600': { normal: Platform.select({ ios: 'Raleway-Bold', android: 'Raleway_700Bold' }) },
},
})

Expand Down
6 changes: 4 additions & 2 deletions packages/ui/src/config/tamagui.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { type CreateTamaguiProps, createTamagui, createTokens } from 'tamagui'

import { animations } from '../animations'

import { fontInter, fontRaleway } from './font'
export { fontInter, fontRaleway }
import { fontInter, fontOpenSans, fontRaleway } from './font'
export { fontInter, fontOpenSans, fontRaleway }

export const absoluteFill = {
position: 'absolute',
Expand Down Expand Up @@ -79,7 +79,9 @@ export const configInput = {
themeClassNameOnRoot: true,
shorthands,
fonts: {
// By default we use the same font for headings and body
default: fontInter,
heading: fontInter,
},
tokens,
themes: {
Expand Down
10 changes: 9 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.