Merge pull request #20324 from coopernetes/gh20093-extend-typography

feat: support strings for fontSize in BackstageTypography
This commit is contained in:
Fredrik Adelöw
2023-10-05 11:51:38 +02:00
committed by GitHub
4 changed files with 30 additions and 13 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/theme': patch
---
Added support for string `fontSize` values (e.g. `"2.5rem"`) in themes in addition to numbers. Also added an optional `fontFamily` prop for header typography variants to allow further customization.
+12 -6
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;
};
@@ -57,7 +57,7 @@ export function createBaseThemeOptions<PaletteOptions>(
throw new Error(`${defaultPageTheme} is not defined in pageTheme.`);
}
const defaultTypography = {
const defaultTypography: BackstageTypography = {
htmlFontSize,
fontFamily,
h1: {
+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;
};