FontSizes
Interface
Structure
interface FontSizes {
[key: string]: string;
}
type FontSize = keyof FontSizes;
Usage
// Types are re-exported for ease of use by other packages
// like @morfeo/core, @morfeo/web or @morfeo/react
import { FontSize, FontSizes } from '@morfeo/spec';
Examples
Using the CLI compose command:
fontSizes.morfeo.ts
// Remove this line to add the slice to all of your themes
export const themeName = 'My Theme Name';
// Optional if you name the file fontSizes.morfeo.ts
export const sliceName = 'fontSizes';
export default {
'2xs': '11px',
xs: '14px',
s: '16px',
m: '18px',
l: '26px',
xl: '36px',
'2xl': '44px',
none: '0px',
};
Or manually:
fontSizes.ts
import { FontSizes } from '@morfeo/spec';
const fontSizes: FontSizes = {
'2xs': '11px',
xs: '14px',
s: '16px',
m: '18px',
l: '26px',
xl: '36px',
'2xl': '44px',
none: '0px',
};
theme.ts
import { fontSizes } from './fontSizes';
const myTheme = {
fontSizes,
...restOfTheTheme,
};
morfeo.setTheme('My Theme Name', myTheme);
Properties
In this table is shown the property you pass to morfeo.resolve
, the actual CSS property or properties that will be generated,
an example of usage, and the correspondent output:
name | css property | example | output |
---|---|---|---|
fontSize | fontSize | { fontSize: "l"} | {"fontSize":"26px"} |
Extend Slice with custom properties
If you're using typescript and you add custom colors to your theme configuration, you'll need to merge
the default FontSizes
interface with your custom one.
We suggest creating a declaration file (for example: morfeo.d.ts
or types.d.ts
) like the following one:
import { fontSizes } from './path/to/your/custom/fontSizes';
type MyFontSizes = typeof fontSizes;
declare module '@morfeo/spec' {
export interface FontSizes extends MyFontSizes {}
}
Read more about how to extend the default Morfeo Theme here.