Skip to content

Commit

Permalink
feat(): Export iife theme sync script.
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanCQ committed Dec 20, 2023
1 parent 25fdd98 commit f32bd6f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

<!-- Or you can load custom head-tag JavaScript: -->

<!-- <script
<script
src="dist/src/utils/syncTheme.js"
type="application/javascript"
></script> -->
></script>

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
Expand Down
24 changes: 22 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import peerDepsExternal from "rollup-plugin-peer-deps-external";
import preserveDirectives from "rollup-plugin-preserve-directives";
import { terser } from "rollup-plugin-terser";

export default {
export default [{
onwarn(warning, warn) {
if (
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
Expand Down Expand Up @@ -39,4 +39,24 @@ export default {
terser({ compress: { directives: false } }),
preserveDirectives(),
],
};

}, {
input: "src/utils/syncTheme.ts",
output: [
{
dir: "dist/src/utils/",
format: "iife",
name: "syncTheme",
},
],
plugins: [
resolve(),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
outDir: "dist/src/utils/",
declaration: false,
}),
terser(),
],
}];
1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export * from "./darkMode";
// export * from "./syncTheme";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
9 changes: 5 additions & 4 deletions src/utils/syncTheme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// import { theme } from "./darkMode";
import { theme } from "./darkMode"

// This script sets up event listeners to set the appropriate css class in the DOM for the current theme. It's intended to be executed in the head of the document hence it is immediately invoked (IIFE).
// (() => {
// theme.syncTheme();
// })();
(() => {
theme.syncTheme()
})()

0 comments on commit f32bd6f

Please sign in to comment.