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

(PC-33849) refactor(TypoDS): missing typo body update and refacto #7492

Merged
merged 5 commits into from
Jan 9, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ exports[`<SetBirthday /> no touch device should render correctly 1`] = `
}

.c3 {
font-family: Montserrat-Regular;
font-size: 15px;
line-height: 20px;
font-family: Montserrat-Medium;
font-size: 1rempx;
line-height: 1.6rem;
color: #161617;
width: 100%;
padding-right: 16px;
Expand All @@ -118,9 +118,9 @@ exports[`<SetBirthday /> no touch device should render correctly 1`] = `
}

.c6 {
font-family: Montserrat-Regular;
font-size: 15px;
line-height: 20px;
font-family: Montserrat-Medium;
font-size: 1rempx;
line-height: 1.6rem;
color: #161617;
width: 100%;
padding-right: 16px;
Expand All @@ -144,9 +144,9 @@ exports[`<SetBirthday /> no touch device should render correctly 1`] = `
}

.c7 {
font-family: Montserrat-Regular;
font-size: 15px;
line-height: 20px;
font-family: Montserrat-Medium;
font-size: 1rempx;
line-height: 1.6rem;
color: #161617;
width: 100%;
padding-right: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ type TextBodyProps = TextProps & {
}
const Body = styled(TypoDS.Body).attrs<TextBodyProps>((props) => props)<TextBodyProps>(
({ theme, textAlign }) => ({
...theme.typography.body,
textAlign,
color: theme.colors.white,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ const NotLongEnough = ({ show }: { show: boolean }) =>
</StyledBody>
) : null

const ListIconWrapper = styled.View(({ theme }) => ({
marginTop: (theme.typography.body.fontSize * 15) / 100,
const ListIconWrapper = styled.View({
marginRight: getSpacing(0.5),
}))
})

const StyledBody = styled(TypoDS.Body)(({ theme }) => ({
color: theme.colors.greyDark,
Expand Down
5 changes: 4 additions & 1 deletion src/ui/components/BulletListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Li } from 'ui/components/Li'
import { VerticalUl } from 'ui/components/Ul'
import { Dot } from 'ui/svg/icons/Dot'
import { getSpacing, TypoDS } from 'ui/theme'
import { REM_TO_PX } from 'ui/theme/constants'

// Use with Ul or VerticalUl to be accessible in web
export const BulletListItem: React.FC<{
Expand Down Expand Up @@ -70,7 +71,9 @@ const NestedBullet = styled(Dot).attrs(({ theme }) => ({
}))``

const BulletContainer = styled.View(({ theme }) => ({
height: theme.designSystem.typography.body.lineHeight,
height: theme.isDesktopViewport
? parseFloat(theme.designSystem.typography.body.lineHeight) * REM_TO_PX
: parseFloat(theme.designSystem.typography.body.lineHeight),
justifyContent: 'center',
}))

Expand Down
6 changes: 3 additions & 3 deletions src/ui/components/CollapsibleText/useIsTextEllipsis.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useCallback, useState } from 'react'
import { useTheme } from 'styled-components/native'

import { IsTextEllipsisOutput } from './types'
import { REM_TO_PX } from 'ui/theme/constants'

const REM_TO_PX = 16
import { IsTextEllipsisOutput } from './types'

// React Native Web doesn't support onTextLayout
// https://github.com/necolas/react-native-web/issues/1685
export const useIsTextEllipsis = (numberOfLines: number): IsTextEllipsisOutput => {
const [isTextEllipsis, setIsTextEllipsis] = useState(false)
const theme = useTheme()

const lineHeight = Number(theme.designSystem.typography.body.lineHeight.slice(0, -3)) * REM_TO_PX
const lineHeight = parseFloat(theme.designSystem.typography.body.lineHeight) * REM_TO_PX

const onLayout: Required<IsTextEllipsisOutput>['onLayout'] = useCallback(
(event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { ThemeProvider } from 'styled-components/native'
import { computedTheme } from 'tests/computedTheme'
import { act, renderHook } from 'tests/utils/web'
import { useIsTextEllipsis } from 'ui/components/CollapsibleText/useIsTextEllipsis'
import { REM_TO_PX } from 'ui/theme/constants'

const LINE_HEIGHT = Number(computedTheme.typography.body.lineHeight.slice(0, -2))
const LINE_HEIGHT = parseFloat(computedTheme.designSystem.typography.body.lineHeight) * REM_TO_PX

describe('useIsTextEllipsis', () => {
it('should return the text ends with ellipsis when the text takes more lines than the max', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/inputs/DropDown/DropDown.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const StyledSelect = styled.select<SelectProps>`
: `${theme.borderRadius.button}px`
const { fontFamily, fontSize, color, lineHeight } = isEmpty
? theme.typography.placeholder
: theme.typography.body
: theme.designSystem.typography.body
return `
font-family: ${fontFamily};
font-size: ${fontSize}px;
Expand Down
2 changes: 2 additions & 0 deletions src/ui/theme/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ export const ILLUSTRATION_ICON_SIZE = getSpacing(35) // 140
export const FULLPAGE_ILLUSTRATION_ICON_SIZE = getSpacing(50)
// small illustrations should be imported with ILLUSTRATION_SMALL_SIZE
export const ILLUSTRATION_SMALL_SIZE = getSpacing(25)

export const REM_TO_PX = 16
Loading