-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ability to customize the fonts with the theme (#11243)
**Motivation** React Navigation 5 introduced a theming API. However, the theme only supported customizing colors. With this change, the theme can be used to customize font family as well - making it simpler to use a specific font across all of React Navigation's UI elements. **Test plan** Specify a custom font in the theme and check that React Navigation's UI elements use the new font. The following screenshots show the usage of the "Lato" font. <img width="804" alt="SCR-20230224-qy4" src="https://user-images.githubusercontent.com/1174278/221260433-258083a8-7fba-4d3c-a2ae-da134b0e29f2.png"> <img width="803" alt="SCR-20230224-qyl" src="https://user-images.githubusercontent.com/1174278/221260454-7e57f7b4-415e-47e5-8a53-a85cd51a5821.png"> <img width="806" alt="SCR-20230224-qz6" src="https://user-images.githubusercontent.com/1174278/221260478-d698a060-c835-4527-9fdc-3717ea58907f.png"> <img width="388" alt="SCR-20230224-qzt" src="https://user-images.githubusercontent.com/1174278/221260490-a7e63117-5615-491a-ab0f-1c5f148153fc.png">
- Loading branch information
Showing
11 changed files
with
156 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Platform } from 'react-native'; | ||
|
||
import type { Theme } from '../types'; | ||
|
||
const WEB_FONT_STACK = | ||
'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; | ||
|
||
export const fonts = Platform.select({ | ||
web: { | ||
regular: { | ||
fontFamily: WEB_FONT_STACK, | ||
fontWeight: '400', | ||
}, | ||
medium: { | ||
fontFamily: WEB_FONT_STACK, | ||
fontWeight: '500', | ||
}, | ||
bold: { | ||
fontFamily: WEB_FONT_STACK, | ||
fontWeight: '600', | ||
}, | ||
heavy: { | ||
fontFamily: WEB_FONT_STACK, | ||
fontWeight: '700', | ||
}, | ||
}, | ||
ios: { | ||
regular: { | ||
fontFamily: 'System', | ||
fontWeight: '400', | ||
}, | ||
medium: { | ||
fontFamily: 'System', | ||
fontWeight: '500', | ||
}, | ||
bold: { | ||
fontFamily: 'System', | ||
fontWeight: '600', | ||
}, | ||
heavy: { | ||
fontFamily: 'System', | ||
fontWeight: '700', | ||
}, | ||
}, | ||
default: { | ||
regular: { | ||
fontFamily: 'sans-serif', | ||
fontWeight: 'normal', | ||
}, | ||
medium: { | ||
fontFamily: 'sans-serif-medium', | ||
fontWeight: 'normal', | ||
}, | ||
bold: { | ||
fontFamily: 'sans-serif', | ||
fontWeight: '600', | ||
}, | ||
heavy: { | ||
fontFamily: 'sans-serif', | ||
fontWeight: '700', | ||
}, | ||
}, | ||
} as const satisfies Record<string, Theme['fonts']>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters