Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
primogenial
/
plugins
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
base
/
hooks
:
use-typography-props.ts
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/* eslint-disable @wordpress/no-unsafe-wp-apis */ /** * External dependencies */ import { isObject } from '@woocommerce/types'; import { parseStyle } from '@woocommerce/base-utils'; type WithStyle = { style: Record< string, unknown >; }; export const useTypographyProps = ( attributes: unknown ): WithStyle => { const attributesObject = isObject( attributes ) ? attributes : {}; const style = parseStyle( attributesObject.style ); const typography = isObject( style.typography ) ? ( style.typography as Record< string, unknown > ) : {}; return { style: { fontSize: attributesObject.fontSize ? `var(--wp--preset--font-size--${ attributesObject.fontSize })` : typography.fontSize, lineHeight: typography.lineHeight, fontWeight: typography.fontWeight, textTransform: typography.textTransform, fontFamily: attributesObject.fontFamily, }, }; };