mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
22 lines
661 B
TypeScript
22 lines
661 B
TypeScript
import { asset } from "$fresh/runtime.ts";
|
|
import { Component, ContextType } from "preact";
|
|
import { GlobalCtx } from "./GlobalContext.tsx";
|
|
|
|
export type StyleSheetType = {
|
|
href: string;
|
|
};
|
|
|
|
export default class StyleSheet extends Component<StyleSheetType, unknown> {
|
|
static contextType = GlobalCtx;
|
|
declare context: ContextType<typeof GlobalCtx>;
|
|
render() {
|
|
const href = this.props.href;
|
|
if (this.context) {
|
|
const sheets = this.context.stylesheets;
|
|
if (sheets.has(href)) return null;
|
|
sheets.add(href);
|
|
}
|
|
return <link rel="stylesheet" href={asset(this.props.href)} />;
|
|
}
|
|
}
|