Skip to content

Commit

Permalink
✨ Adjust line height #1890
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandolucchesi committed Oct 6, 2023
1 parent b4a64a5 commit 07b2a1e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
15 changes: 11 additions & 4 deletions web/components/src/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StyledTextProps = {

const StyledText = styled(Typography)<StyledTextProps>`
font-size: var(--size);
line-height: var(--lineHeight-3);
line-height: var(--lineHeight);
/* @TODO: Let's consider to move all the margin woo to the article layout
We should. Not move, but scope. For both news and topic pages. But this will
require a lot of retest, since in some of the uses cases we will need to reintroduce the margin */
Expand Down Expand Up @@ -42,6 +42,7 @@ const StyledText = styled(Typography)<StyledTextProps>`

export type TextProps = {
size?: 'regular' | 'md' | 'small' | 'lg'
lineHeight?: '1' | '2' | '2_5' | '3'
bold?: boolean
italic?: boolean
centered?: boolean
Expand All @@ -57,12 +58,17 @@ const sizes = {
small: 'var(--typeScale-0)',
}

const lineHeights = {
1: 'var(--lineHeight-1)',
2: 'var(--lineHeight-2)',
'2_5': 'var(--lineHeight-2_5)',
3: 'var(--lineHeight-3)',
}

export const Text = forwardRef<HTMLDivElement, TextProps>(function Text(
{ size = 'regular', style, children, inverted = false, ...rest },
{ size = 'regular', lineHeight = '3', style, children, inverted = false, ...rest },
ref,
) {
if (size === 'lg') console.log(ref)

return (
<StyledText
ref={ref}
Expand All @@ -71,6 +77,7 @@ export const Text = forwardRef<HTMLDivElement, TextProps>(function Text(
{
...style,
'--size': sizes[size],
'--lineHeight': lineHeights[lineHeight],
} as CSSProperties
}
{...rest}
Expand Down
6 changes: 5 additions & 1 deletion web/pageComponents/shared/Teaser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ const Teaser = ({ data, anchor }: TeaserProps) => {
value={text}
components={{
block: {
normal: ({ children }: { children: React.ReactNode }) => <Text size="lg">{children}</Text>,
normal: ({ children }: { children: React.ReactNode }) => (
<Text size="lg" lineHeight="2_5">
{children}
</Text>
),
} as BlockType,
}}
/>
Expand Down
6 changes: 5 additions & 1 deletion web/pageComponents/topicPages/TextBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ const TextBlock = ({ data, anchor }: TextBlockProps) => {
value={ingress}
components={{
block: {
normal: ({ children }: { children: React.ReactNode }) => <Text size="lg">{children}</Text>,
normal: ({ children }: { children: React.ReactNode }) => (
<Text lineHeight="2_5" size="lg">
{children}
</Text>
),
} as BlockType,
}}
/>
Expand Down
1 change: 1 addition & 0 deletions web/styles/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const typography = css`
/* Should probably do something more clever here */
--lineHeight-1: inherit;
--lineHeight-2: 1.2;
--lineHeight-2_5: 1.35;
--lineHeight-3: 1.5;
/* Font weights */
Expand Down

0 comments on commit 07b2a1e

Please sign in to comment.