| 1 |
import { |
| 2 |
TypographyValue, |
| 3 |
getTypography, |
| 4 |
} from "@tableberg/shared/utils/typography"; |
| 5 |
|
| 6 |
import FontFamilyControl from "./FontFamilyControl"; |
| 7 |
import FontSizeControl from "./FontSizeControl"; |
| 8 |
import FontAppearanceControl from "./FontAppearanceControl"; |
| 9 |
import LineHeightControl from "./LineHeightControl"; |
| 10 |
import LetterSpacingControl from "./LetterSpacingControl"; |
| 11 |
import TextDecorationControl from "./TextDecorationControl"; |
| 12 |
import TextTransformControl from "./TextTransformControl"; |
| 13 |
|
| 14 |
interface Props { |
| 15 |
value?: Partial<TypographyValue>; |
| 16 |
onChange: (updates: Partial<TypographyValue>) => void; |
| 17 |
panelId?: string; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* The whole typography group in one go: the same options the core blocks |
| 22 |
* offer, as ToolsPanelItems, so a block only has to put them in a ToolsPanel |
| 23 |
* and store the values. Individual controls are exported too, for a block |
| 24 |
* that wants just one of them. |
| 25 |
*/ |
| 26 |
export default function TypographyControls({ |
| 27 |
value, |
| 28 |
onChange, |
| 29 |
panelId, |
| 30 |
}: Props) { |
| 31 |
const typography = getTypography(value); |
| 32 |
|
| 33 |
return ( |
| 34 |
<> |
| 35 |
<FontFamilyControl |
| 36 |
panelId={panelId} |
| 37 |
value={typography.fontFamily} |
| 38 |
onChange={fontFamily => onChange({ fontFamily })} |
| 39 |
/> |
| 40 |
<FontSizeControl |
| 41 |
panelId={panelId} |
| 42 |
value={typography.fontSize} |
| 43 |
onChange={fontSize => onChange({ fontSize })} |
| 44 |
/> |
| 45 |
<FontAppearanceControl |
| 46 |
panelId={panelId} |
| 47 |
fontFamily={typography.fontFamily} |
| 48 |
value={{ |
| 49 |
fontStyle: typography.fontStyle, |
| 50 |
fontWeight: typography.fontWeight, |
| 51 |
}} |
| 52 |
onChange={appearance => onChange(appearance)} |
| 53 |
/> |
| 54 |
<LineHeightControl |
| 55 |
panelId={panelId} |
| 56 |
value={typography.lineHeight} |
| 57 |
onChange={lineHeight => onChange({ lineHeight })} |
| 58 |
/> |
| 59 |
<TextTransformControl |
| 60 |
panelId={panelId} |
| 61 |
value={typography.textTransform} |
| 62 |
onChange={textTransform => onChange({ textTransform })} |
| 63 |
/> |
| 64 |
<LetterSpacingControl |
| 65 |
panelId={panelId} |
| 66 |
value={typography.letterSpacing} |
| 67 |
onChange={letterSpacing => onChange({ letterSpacing })} |
| 68 |
/> |
| 69 |
<TextDecorationControl |
| 70 |
panelId={panelId} |
| 71 |
value={typography.textDecoration} |
| 72 |
onChange={textDecoration => onChange({ textDecoration })} |
| 73 |
/> |
| 74 |
</> |
| 75 |
); |
| 76 |
} |
| 77 |
|