feat: Enable tailwind theme variables in twindv1 Options (#1776)

This commit is contained in:
Mathias Tværmose Gleerup
2023-09-18 17:00:10 +00:00
committed by GitHub
parent 3850131063
commit c35f1f6519
+13 -3
View File
@@ -1,11 +1,18 @@
import { JSX, options as preactOptions, VNode } from "preact";
import { setup as twSetup, Sheet, tw, TwindConfig } from "../twindv1_deps.ts";
import {
BaseTheme,
setup as twSetup,
Sheet,
tw,
TwindConfig,
} from "$fresh/plugins/twindv1_deps.ts";
type PreactOptions = typeof preactOptions & { __b?: (vnode: VNode) => void };
export const STYLE_ELEMENT_ID = "__FRSH_TWIND";
export interface Options extends TwindConfig {
export interface Options<Theme extends BaseTheme = BaseTheme>
extends TwindConfig<Theme> {
/** The import.meta.url of the module defining these options. */
selfURL: string;
}
@@ -19,7 +26,10 @@ declare module "preact" {
}
}
export function setup({ selfURL: _selfURL, ...config }: Options, sheet: Sheet) {
export function setup<Theme extends BaseTheme = BaseTheme>(
{ selfURL: _selfURL, ...config }: Options<Theme>,
sheet: Sheet,
) {
twSetup(config, sheet);
// Hook into options._diff which is called whenever a new comparison