Skip to content

Commit

Permalink
💄 Add line height property to body
Browse files Browse the repository at this point in the history
Because utils method to convert lineheight token to lineheight style is here
  • Loading branch information
valentinmagrez committed Aug 23, 2024
1 parent 188b064 commit fca594c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/typography/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@ import { StyleProp, Text, TextStyle } from 'react-native';
import type { TextProps } from 'react-native-paper';
import { useTheme } from '../../styles/themes';
import { tokens } from '@zerogachis/smartway-design-token';
import { getFont } from './utils';
import { LineHeight } from '@zerogachis/smartway-design-token/dist/cjs/src/Tokens/TokensType';
import { getFont, getLineHeight } from './utils';

type BodyTypography = keyof typeof tokens.typography.body;

export interface BodyProps extends TextProps<Text> {
typography?: BodyTypography;
lineHeight?: keyof LineHeight;
}

export const Body = ({ typography = 'n4', children, style, ...props }: BodyProps) => {
export const Body = ({
typography = 'n4',
lineHeight = 'normal',
children,
style,
...props
}: BodyProps) => {
const theme = useTheme();

const bodyStyle: StyleProp<TextStyle> = {
color: theme.sw.color.neutral[800],
fontSize: tokens.typography.body[typography]?.fontSize,
fontFamily: getFont(tokens.typography.body[typography]),
lineHeight: getLineHeight(
tokens.lineHeight[lineHeight],
tokens.typography.headline[typography]?.fontSize,
),
};

return (
Expand Down

0 comments on commit fca594c

Please sign in to comment.