1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-28 17:20:13 +02:00
This commit is contained in:
Kushagra Gour
2024-03-12 23:38:05 +05:30
parent 6e5e33a146
commit 00b105a352
4 changed files with 127 additions and 6 deletions

56
src/components/Text.jsx Normal file
View File

@@ -0,0 +1,56 @@
import { forwardRef } from 'preact/compat';
const appearanceStyles = {
normal: {
color: 'var(--color-text)'
},
primary: {
color: 'var(--color-heading)'
},
secondary: {
color: 'var(--color-text-light)'
},
tertiary: {
color: 'var(--color-text-lightest-final)'
},
brand: {
color: 'var(--color-brand)'
}
};
export const Text = forwardRef(
(
{
size = 0,
weight = 'normal',
tag,
style = 'normal',
appearance = 'normal',
letterSpacing = 0,
lineHeight = 1.4,
align = 'left',
classes = '',
children
},
ref
) => {
const Tag = tag || 'span';
const styles = {
letterSpacing: letterSpacing,
fontSize: `var(--font-size-${size})`,
fontWeight: weight,
textAlign: align,
lineHeight: lineHeight,
fontStyle: style === 'italic' ? 'italic' : 'normal',
...appearanceStyles[appearance]
};
return (
<Tag style={styles} className={classes} ref={ref}>
{children}
</Tag>
);
}
);