Skip to content

Commit

Permalink
doc: Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 16, 2022
1 parent 9db1f6c commit 428da4a
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 428da4a

Please sign in to comment.