-
Notifications
You must be signed in to change notification settings - Fork 2
/
Hero.tsx
43 lines (37 loc) · 1.52 KB
/
Hero.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React, { ForwardedRef, forwardRef } from "react";
import { View } from "react-native";
import { IOTheme, useIOExperimentalDesign, useIOTheme } from "../../core";
import { IOFontFamily, IOFontSize, IOFontWeight } from "../../utils/fonts";
import { IOText, IOTextProps, TypographicStyleProps } from "./IOText";
const defaultColor: keyof IOTheme = "textHeading-default";
export const heroFontSize: IOFontSize = 32;
export const heroLineHeight = 48;
const fontName: IOFontFamily = "Titillio";
const fontWeight: IOFontWeight = "Semibold";
// TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
const legacyHeroFontSize: IOFontSize = 35;
const legacyHeroLineHeight = 49;
const legacyFontName: IOFontFamily = "TitilliumSansPro";
const legacyFontWeight: IOFontWeight = "Semibold";
/**
* `Hero` typographic style
*/
export const Hero = forwardRef<View, TypographicStyleProps>(
({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
const theme = useIOTheme();
const { isExperimental } = useIOExperimentalDesign();
const HeroProps: IOTextProps = {
...props,
font: isExperimental ? fontName : legacyFontName,
weight: isExperimental ? fontWeight : legacyFontWeight,
size: isExperimental ? heroFontSize : legacyHeroFontSize,
lineHeight: isExperimental ? heroLineHeight : legacyHeroLineHeight,
color: customColor ?? theme[defaultColor]
};
return (
<IOText ref={ref} {...HeroProps}>
{props.children}
</IOText>
);
}
);