feat: support strings for fontSize in Typography

Signed-off-by: Thomas Cooper <57812123+coopernetes@users.noreply.github.com>
This commit is contained in:
Thomas Cooper
2023-10-02 15:38:30 -04:00
parent 0507326be6
commit 5ad5344756
3 changed files with 65 additions and 13 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/theme': patch
---
Fixed a bug to support string fontSize values (`"2.5rem"`) instead of forcing numeric-only values & requiring casts. In addition, added an optional fontFamily prop for h1-h6 BackstageTypography variants to allow further customization.
+48 -7
View File
@@ -117,32 +117,38 @@ export type BackstageTypography = {
htmlFontSize: number;
fontFamily: string;
h1: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h2: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h3: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h4: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h5: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h6: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
@@ -172,7 +178,42 @@ export function createBaseThemeOptions<PaletteOptions>(
options: BaseThemeOptionsInput<PaletteOptions>,
): {
palette: PaletteOptions;
typography: BackstageTypography;
typography:
| BackstageTypography
| {
htmlFontSize: number;
fontFamily: string;
h1: {
fontSize: number;
fontWeight: number;
marginBottom: number;
};
h2: {
fontSize: number;
fontWeight: number;
marginBottom: number;
};
h3: {
fontSize: number;
fontWeight: number;
marginBottom: number;
};
h4: {
fontWeight: number;
fontSize: number;
marginBottom: number;
};
h5: {
fontWeight: number;
fontSize: number;
marginBottom: number;
};
h6: {
fontWeight: number;
fontSize: number;
marginBottom: number;
};
};
page: PageTheme;
getPageTheme: ({ themeId }: PageThemeSelector) => PageTheme;
};
+12 -6
View File
@@ -124,32 +124,38 @@ export type BackstageTypography = {
htmlFontSize: number;
fontFamily: string;
h1: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h2: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h3: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h4: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h5: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};
h6: {
fontSize: number;
fontFamily?: string;
fontSize: number | string;
fontWeight: number;
marginBottom: number;
};