From fa57727abb2a385f34ab77e8ecb2f249475ef001 Mon Sep 17 00:00:00 2001 From: hyper Date: Tue, 30 Jun 2026 18:28:40 +0800 Subject: [PATCH] feat(md-font): Add color prop support --- src/components/md-font.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/md-font.tsx b/src/components/md-font.tsx index ac558e1..2287db5 100644 --- a/src/components/md-font.tsx +++ b/src/components/md-font.tsx @@ -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 = { + 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, });