Skip to content

Commit

Permalink
type: Add type file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 15, 2022
1 parent 4020a16 commit 8f5585b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

export type ColorScheme = 'light' | 'dark';
export type ColorSchemeChangeEvent = CustomEvent<{ colorScheme: ColorScheme }>;
export class DarkMode extends HTMLElement {
mode?: ColorScheme;
dark?: string;
light?: string;
style?: React.CSSProperties;
}

declare global {
interface HTMLElementTagNameMap {
'dark-mode': DarkMode;
}
interface GlobalEventHandlersEventMap {
'colorschemechange': ColorSchemeChangeEvent;
}
}

declare namespace JSX {
interface IntrinsicElements {
'dark-mode': DarkMode;
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"module": "./dist/dark-mode.min.js",
"exports": "./dist/dark-mode.min.js",
"unpkg": "./dist/dark-mode.min.js",
"types": "./main.d.ts",
"scripts": {
"clean": "shx rm -rf ./dist && mkdir dist",
"build": "npm run clean && npx terser ./main.js --toplevel --mangle-props regex=\\\"^_\\\" --comments /@license/ --ecma=8 -o ./dist/dark-mode.min.js"
Expand Down

0 comments on commit 8f5585b

Please sign in to comment.