-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into ts-dev-setup-tests
* develop: Fix usage of URL from a Healthcare Authority (#507) Event history UX update (#467) Move Google import block, disable for release builds (#505) Add French translation (#490) Notify "Location tracking was disabled" on Android (#503) Russian Translation by Ksenia Lukacher (#479) Feature/cn-language (#493) Italian i18n updates from @andreanuzzo, @diarmidmackenzie (#498) Android StatusBar transparency fix (#497) Remove hardcoded link to Haitian health authority (#499) Spanish Translation from Miquel Vila Porte (#491) Configure Android to use singleTask launchMode (#501)
- Loading branch information
Showing
54 changed files
with
4,305 additions
and
868 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ node_modules/ | |
ios/ | ||
android/ | ||
patches/ | ||
__tests__/ | ||
package-lock.json | ||
yarn.lock | ||
package.json |
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,92 @@ | ||
import * as React from 'react'; | ||
import styled from '@emotion/native'; | ||
|
||
export const Type = { | ||
Headline1: 'headline1', | ||
Headline2: 'headline2', | ||
Headline3: 'headline3', | ||
Body1: 'body1', | ||
Body2: 'body2', | ||
Body3: 'body3', | ||
}; | ||
|
||
/** | ||
* Render a theme and visual style aware text element. | ||
* | ||
* It uses the theme's `text(Primary|Secondary)OnBackground` color and a set of | ||
* predefined font size and line height values. | ||
* | ||
* Inspired by: https://material-components.github.io/material-components-web-catalog/#/component/typography | ||
* | ||
* Usage: | ||
* | ||
* ```jsx | ||
* <Theme use="charcoal"> | ||
* <Typography use="headline2">Heading</Typography> | ||
* <Typography use="body1" secondary>Paragraph text ...</Typography> | ||
* <Typography use="body2" monospace>link</Typography> | ||
* </Theme> | ||
* ``` | ||
* | ||
* Use within a `<ThemeProvider>` | ||
* | ||
* @param {{ | ||
* use?: string, | ||
* secondary?: boolean, | ||
* monospace?: boolean, | ||
* }} param0 | ||
*/ | ||
export const Typography = ({ | ||
use = Type.Body1, | ||
secondary, | ||
monospace, | ||
children, | ||
...otherProps | ||
}) => { | ||
return ( | ||
<ThemedText | ||
use={use} | ||
secondary={secondary} | ||
monospace={monospace} | ||
{...otherProps}> | ||
{children} | ||
</ThemedText> | ||
); | ||
}; | ||
|
||
const FONT_SIZE_MAP = { | ||
[Type.Headline1]: '52px', | ||
[Type.Headline2]: '26px', | ||
[Type.Headline3]: '16px', | ||
[Type.Body1]: '18px', | ||
[Type.Body2]: '16px', | ||
[Type.Body3]: '15px', | ||
}; | ||
|
||
const getFontSize = ({ use = Type.Body1 }) => FONT_SIZE_MAP[use]; | ||
|
||
const LINE_HEIGHT_MAP = { | ||
[Type.Headline1]: '48px', | ||
[Type.Headline2]: '34px', | ||
[Type.Headline3]: '40px', | ||
[Type.Body1]: '24px', | ||
[Type.Body2]: '22px', | ||
[Type.Body3]: '24px', | ||
}; | ||
|
||
const getLineHeight = ({ use = Type.Body1 }) => LINE_HEIGHT_MAP[use]; | ||
|
||
const getTextColor = ({ theme, secondary = false }) => | ||
secondary ? theme.textSecondaryOnBackground : theme.textPrimaryOnBackground; | ||
|
||
const getFontWeight = ({ use = Type.Body1 }) => | ||
use.startsWith('headline') ? 'bold' : 'normal'; | ||
|
||
const ThemedText = styled.Text` | ||
color: ${getTextColor}; | ||
font-family: ${({ monospace }) => | ||
monospace ? 'IBM Plex Mono' : 'IBM Plex Sans'}; | ||
font-size: ${getFontSize}; | ||
font-weight: ${getFontWeight}; | ||
line-height: ${getLineHeight}; | ||
`; |
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,40 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
|
||
import { Typography } from '../Typography'; | ||
import { Theme } from '../../constants/themes'; | ||
|
||
it('headline1 is large and bold', () => { | ||
const { asJSON } = render( | ||
<Theme> | ||
<Typography use='headline1'>headline1</Typography> | ||
</Theme>, | ||
); | ||
|
||
expect(asJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('body1 is regular', () => { | ||
const { asJSON } = render( | ||
<Theme> | ||
<Typography use='body1'>body1</Typography> | ||
</Theme>, | ||
); | ||
|
||
expect(asJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('changes color based on theme', () => { | ||
const { asJSON } = render( | ||
<> | ||
<Theme use='charcoal'> | ||
<Typography use='body1'>white</Typography> | ||
</Theme> | ||
<Theme use='default'> | ||
<Typography use='body1'>violet</Typography> | ||
</Theme> | ||
</>, | ||
); | ||
|
||
expect(asJSON()).toMatchSnapshot(); | ||
}); |
Oops, something went wrong.