mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-28 17:20:13 +02:00
styling
This commit is contained in:
56
src/components/Text.jsx
Normal file
56
src/components/Text.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user