From 428da4a9e180e0e862eca1182b02dcb62be2f03d Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 17 Mar 2022 00:30:23 +0800 Subject: [PATCH] doc: Update README.md --- README.md | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 450df50..e03e7af 100644 --- a/README.md +++ b/README.md @@ -69,34 +69,6 @@ document.addEventListener('colorschemechange', (e) => { }); ``` -## Properties - -Properties can be set directly on the custom element at creation time, or dynamically via JavaScript. - -```typescript -export type ColorScheme = 'light' | 'dark'; -export class DarkMode extends HTMLElement { - mode?: ColorScheme; - /** - * Defaults to not remember the last choice. - * If present remembers the last selected mode (`dark` or `light`), - * which allows the user to permanently override their usual preferred color scheme. - */ - permanent?: boolean; - /** - * Any string value that represents the label for the "dark" mode. - */ - dark?: string; - /** - * Any string value that represents the label for the "light" mode. - */ - light?: string; - style?: React.CSSProperties; -} -``` - -## Complete Example - Interacting with the custom element: ```js @@ -139,6 +111,32 @@ document.addEventListener('permanentcolorscheme', (e) => { }); ``` +## Properties + +Properties can be set directly on the custom element at creation time, or dynamically via JavaScript. + +```typescript +export type ColorScheme = 'light' | 'dark'; +export class DarkMode extends HTMLElement { + mode?: ColorScheme; + /** + * Defaults to not remember the last choice. + * If present remembers the last selected mode (`dark` or `light`), + * which allows the user to permanently override their usual preferred color scheme. + */ + permanent?: boolean; + /** + * Any string value that represents the label for the "dark" mode. + */ + dark?: string; + /** + * Any string value that represents the label for the "light" mode. + */ + light?: string; + style?: React.CSSProperties; +} +``` + ## Events - `colorschemechange`: Fired when the color scheme gets changed.