-
Notifications
You must be signed in to change notification settings - Fork 5
fix: update component styling to defer more to MUI theme #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
edbcd9d
fb4990b
3386d42
40aaa11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish I didn't need to make a function like this, but it really felt like it was the best way to ensure that the theme logic doesn't randomly break. One of the problems with the base MUI theme object that Backstage gives you by default is that it's light on the number of font sizes. You generally want very few sizes for longform text, but for UI, you need more variety to have better information hierarchy I was able to get pretty close to the old design without needing this function, but then I needed to access weird properties like
I think it's safe to say that most users will at least look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be on the wrong page, but should we not just use |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* A custom focus color chosen to look close to a system default, while | ||
* remaining visible in dark and light themes. The focus values from Backstage's | ||
* theme object are too low-contrast to meet accessibility requirements. | ||
*/ | ||
export const CUSTOM_FOCUS_COLOR = 'hsl(213deg, 94%, 68%)'; | ||
|
||
export function scaleCssUnit( | ||
baseSize: string | number | undefined, | ||
scale: number, | ||
): string { | ||
if (!Number.isFinite(scale)) { | ||
return '1rem'; | ||
} | ||
|
||
if (baseSize === undefined) { | ||
return `${scale}rem`; | ||
} | ||
|
||
if (typeof baseSize === 'number') { | ||
if (!Number.isFinite(baseSize)) { | ||
return `${scale}rem`; | ||
} | ||
|
||
return `${baseSize * scale}px`; | ||
} | ||
|
||
const sizeRe = /^\s*(?<value>\d+(?:\.\d+))?s*(?<unit>px|r?em)\s*$/i; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm taking your regular expressions away it's for your own good. |
||
const { value, unit } = sizeRe.exec(baseSize)?.groups ?? {}; | ||
const numValue = Number(value); | ||
|
||
if (Number.isNaN(numValue) || unit === undefined) { | ||
return `${scale}rem`; | ||
} | ||
|
||
return `${scale * numValue}${unit}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍