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

[C-3709 C-3814] Fix native text aligment issues #7598

Merged
merged 2 commits into from
Feb 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
2 changes: 1 addition & 1 deletion packages/harmony/src/components/text/Text/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const variantStylesMap = {
},
label: {
fontSize: { xs: '2xs', s: 'xs', m: 's', l: 'm', xl: 'xl' },
lineHeight: { xs: 'xs', s: 'xs', m: 's', l: 's', xl: 'l' },
lineHeight: { xs: 'xs', s: 's', m: 's', l: 'm', xl: 'l' },
fontWeight: { default: 'bold', strong: 'heavy' },
css: { textTransform: 'uppercase' as const, letterSpacing: 0.5 }
},
Expand Down
10 changes: 8 additions & 2 deletions packages/mobile/src/harmony-native/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { variantStylesMap } from '@audius/harmony/src/components/text'
import type { BaseTextProps } from '@audius/harmony/src/components/text'
import { css } from '@emotion/native'
import type { TextProps as NativeTextProps, TextStyle } from 'react-native'
import { Text as TextBase } from 'react-native'
import { Platform, Text as TextBase } from 'react-native'

import { useTheme } from '../../foundations/theme'

Expand Down Expand Up @@ -34,6 +34,8 @@ export const Text = forwardRef<TextBase, TextProps>((props, ref) => {
const variantStyles = variant && variantStylesMap[variant]
const t = theme.typography

const fontWeight = variantStyles?.fontWeight[strength]

const textStyles: TextStyle = css({
...(variantStyles && {
fontSize: t.size[variantStyles.fontSize[size]],
Expand All @@ -43,7 +45,11 @@ export const Text = forwardRef<TextBase, TextProps>((props, ref) => {
}),
...(color && { color }),
...(shadow && t.shadow[shadow]),
textAlign
textAlign,
// Fixes demiBold text misalignment on iOS
...(fontWeight === 'demiBold' && Platform.OS === 'ios'
? { marginTop: 2 }
: {})
})

const isHeading = variant === 'display' || variant === 'heading'
Expand Down