feat(md-font): Add color prop support
This commit is contained in:
parent
f337acd142
commit
fa57727abb
|
|
@ -8,6 +8,8 @@ export interface FontProps {
|
|||
source?: "google" | "emfont" | "local";
|
||||
/** Font weight (for google and emfont sources) */
|
||||
weight?: string;
|
||||
/** Font color (CSS color value, e.g. #ff00dd, rgb(255,0,0)) */
|
||||
color?: string;
|
||||
}
|
||||
|
||||
function buildLinkHref(
|
||||
|
|
@ -27,7 +29,7 @@ function buildLinkHref(
|
|||
|
||||
customElement(
|
||||
"md-font",
|
||||
{ source: "local", weight: "400" },
|
||||
{ source: "local", weight: "400", color: undefined },
|
||||
(props, { element }) => {
|
||||
noShadowDOM();
|
||||
|
||||
|
|
@ -49,10 +51,18 @@ customElement(
|
|||
? [{ href, dataset: { mdFontSource: source, mdFontName: font } }]
|
||||
: [];
|
||||
|
||||
const styles: Partial<CSSStyleDeclaration> = {
|
||||
fontFamily: `"${font}", sans-serif`,
|
||||
} as any;
|
||||
|
||||
if (props.color) {
|
||||
(styles as any).color = props.color;
|
||||
}
|
||||
|
||||
const handle = registerStyle({
|
||||
key: "fontFamily",
|
||||
article: articleEl,
|
||||
styles: { fontFamily: `"${font}", sans-serif` },
|
||||
styles,
|
||||
links,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue