-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
426 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: localStorageKey | ||
description: The key used to store the mode in local storage. | ||
tagline: API Reference | ||
--- | ||
|
||
<script> | ||
import { Callout } from '$lib/components' | ||
</script> | ||
|
||
The key used to store the mode in local storage. | ||
|
||
## Usage | ||
|
||
If you wanted to clear the history of the user's mode preference, you could use the `localStorageKey` like so: | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { localStorageKey } from "mode-watcher"; | ||
function clearModeFromLocalStorage() { | ||
localStorage.removeItem(localStorageKey); | ||
} | ||
</script> | ||
<p>Clear the user's mode preference history.</p> | ||
<button on:click={clearModeFromLocalStorage}>Clear</button> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: mode | ||
description: A store for tracking the current mode. | ||
tagline: API Reference | ||
--- | ||
|
||
A readable store that contains the current mode. It can be `"light"` or `"dark"`, or if evaluated on the server, `undefined`. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { setMode, mode } from "mode-watcher"; | ||
function handleModeChange() { | ||
if ($mode === "light") { | ||
setMode("dark"); | ||
} else { | ||
setMode("light"); | ||
} | ||
} | ||
</script> | ||
<button on:click={handleModeChange}>{$mode}</button> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: resetMode | ||
description: Programatically reset the mode to system preference. | ||
tagline: API Reference | ||
--- | ||
|
||
A function that resets the mode to system preferences. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { resetMode } from "mode-watcher"; | ||
</script> | ||
<button on:click={resetMode}>System</button> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: setMode | ||
description: Programatically set the mode. | ||
tagline: API Reference | ||
--- | ||
|
||
A function that sets the current mode. It accepts a string with the value `"light"`, `"dark"` or `"system"`. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { setMode } from "mode-watcher"; | ||
</script> | ||
<button on:click={() => setMode("light")}>Set Light Mode</button> | ||
<button on:click={() => setMode("dark")}>Set Dark Mode</button> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: systemPrefersMode | ||
description: A store for tracking the system's preferred mode. | ||
tagline: API Reference | ||
--- | ||
|
||
A readable store that represents the operating system's mode preference. It can be `"light"` or `"dark"`, or if evaluated on the server, `undefined`. | ||
|
||
This store will automatically track changes to the operating system's mode preference unless this is disabled by setting the `track` prop to `false` in the [ModeWatcher](/docs/api-reference/mode-watcher) component. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { systemPrefersMode } from "mode-watcher"; | ||
</script> | ||
<p>The system prefers mode is: {$systemPrefersMode}</p> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: toggleMode | ||
description: Programatically toggle the mode. | ||
tagline: API Reference | ||
--- | ||
|
||
A function that can be used to programatically toggle the mode. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { toggleMode } from "mode-watcher"; | ||
</script> | ||
<button on:click={toggleMode}>Toggle Mode</button> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: userPrefersMode | ||
description: A store for tracking the user's preferred mode. | ||
tagline: API Reference | ||
--- | ||
|
||
A writeable store that represents the user's mode preference. It can be "light", "dark" or "system". | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { userPrefersMode } from "mode-watcher"; | ||
</script> | ||
<p>Your preferred mode is: {$userPrefersMode}</p> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.