-
-
Notifications
You must be signed in to change notification settings - Fork 187
font switcher #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
font switcher #604
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cc70200
font switcher
Rich-Harris 9a66c09
Update packages/site-kit/src/lib/styles/tokens.css
dummdidumm cbfd217
Update packages/site-kit/src/lib/components/FontDropdown.svelte
dummdidumm 3882ba0
fix
Rich-Harris 668af8b
Merge branch 'font-switcher' of github.com:sveltejs/svelte.dev into f…
Rich-Harris aa6dbf6
use atkinson hyperlegible
Rich-Harris 530f7f9
icons
Rich-Harris 98026bf
Merge branch 'main' into font-switcher
Rich-Harris 710629d
make it a two-way toggle
Rich-Harris 87dade8
tidy up
Rich-Harris 54f8675
oops
Rich-Harris 05e66d0
tidy up
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,76 @@ | ||
<script lang="ts"> | ||
import Dropdown from './Dropdown.svelte'; | ||
import Icon from './Icon.svelte'; | ||
|
||
let { top }: { top: boolean } = $props(); | ||
|
||
let font = $state('elegant'); | ||
|
||
$effect(() => { | ||
font = localStorage.getItem('svelte:font') ?? 'elegant'; | ||
}); | ||
|
||
function choose(value: 'elegant' | 'boring' | 'accessible') { | ||
console.log('choosing', value); | ||
|
||
font = value; | ||
|
||
document.documentElement.classList.remove('font-elegant'); | ||
document.documentElement.classList.remove('font-boring'); | ||
document.documentElement.classList.remove('font-accessible'); | ||
|
||
document.documentElement.classList.add(`font-${font}`); | ||
localStorage.setItem('svelte:font', font); | ||
} | ||
</script> | ||
|
||
<Dropdown align="right" {top}> | ||
<div class="icons"> | ||
<Icon name="font-toggle" /> | ||
<Icon name="chevron-down" /> | ||
</div> | ||
|
||
{#snippet dropdown()} | ||
<div class="buttons"> | ||
<button aria-pressed={font === 'elegant'} onclick={() => choose('elegant')}>Serif</button> | ||
<button aria-pressed={font === 'boring'} onclick={() => choose('boring')}>Sans-serif</button> | ||
<button aria-pressed={font === 'accessible'} onclick={() => choose('accessible')} | ||
>Accessible</button | ||
> | ||
</div> | ||
{/snippet} | ||
</Dropdown> | ||
|
||
<style> | ||
.icons { | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
button { | ||
display: block; | ||
font: var(--sk-font-ui-medium); | ||
padding: 1rem 1.3rem; | ||
line-height: 1; | ||
width: 100%; | ||
margin: 0; | ||
text-align: left; | ||
|
||
&:hover { | ||
background-color: var(--sk-back-4); | ||
} | ||
|
||
&:first-child { | ||
padding-top: 1.3rem; | ||
} | ||
|
||
&:last-child { | ||
padding-bottom: 1.3rem; | ||
} | ||
|
||
&[aria-pressed='true'] { | ||
color: var(--sk-theme-1); | ||
} | ||
} | ||
</style> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.