feat: use dropdown for primary color setting
This commit is contained in:
1 parent
94a5c0b9ae
commit
78067cc890
1 file changed
+8
-71
@@ -3,7 +3,6 @@
|
|||||||
import {
|
import {
|
||||||
PRIMARY_COLOR_PALETTE,
|
PRIMARY_COLOR_PALETTE,
|
||||||
initPrimaryColor,
|
initPrimaryColor,
|
||||||
primaryColorByName,
|
|
||||||
setPrimaryColor,
|
setPrimaryColor,
|
||||||
storedPrimaryColor,
|
storedPrimaryColor,
|
||||||
} from '../primary-color.svelte'
|
} from '../primary-color.svelte'
|
||||||
@@ -32,38 +31,17 @@
|
|||||||
|
|
||||||
<div class="sc-primary-color">
|
<div class="sc-primary-color">
|
||||||
<span class="sc-label">{label}</span>
|
<span class="sc-label">{label}</span>
|
||||||
<div class="sc-primary-color-options" role="radiogroup" aria-label={label}>
|
<select
|
||||||
<button
|
class="sc-input"
|
||||||
type="button"
|
aria-label={label}
|
||||||
role="radio"
|
value={selected}
|
||||||
aria-checked={selected === ''}
|
onchange={(event) => choose(event.currentTarget.value)}
|
||||||
aria-label="Default"
|
|
||||||
title="Default"
|
|
||||||
class:sc-primary-color-selected={selected === ''}
|
|
||||||
onclick={() => choose('')}
|
|
||||||
>
|
>
|
||||||
<span class="sc-primary-color-default">—</span>
|
<option value="">Default</option>
|
||||||
</button>
|
|
||||||
{#each PRIMARY_COLOR_PALETTE as color (color.name)}
|
{#each PRIMARY_COLOR_PALETTE as color (color.name)}
|
||||||
<button
|
<option value={color.name}>{color.name}</option>
|
||||||
type="button"
|
|
||||||
role="radio"
|
|
||||||
aria-checked={selected === color.name}
|
|
||||||
aria-label={color.name}
|
|
||||||
title={color.name}
|
|
||||||
class:sc-primary-color-selected={selected === color.name}
|
|
||||||
style={'--sc-picker-color:' + color.light}
|
|
||||||
onclick={() => choose(color.name)}
|
|
||||||
>
|
|
||||||
<span></span>
|
|
||||||
</button>
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</select>
|
||||||
{#if selected}
|
|
||||||
<span class="sc-primary-color-name">{primaryColorByName(selected)?.name}</span>
|
|
||||||
{:else}
|
|
||||||
<span class="sc-primary-color-name">Default</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -71,45 +49,4 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sc-primary-color-options {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sc-primary-color-options button {
|
|
||||||
display: grid;
|
|
||||||
width: 1.75rem;
|
|
||||||
height: 1.75rem;
|
|
||||||
place-items: center;
|
|
||||||
padding: 0;
|
|
||||||
border: 1px solid var(--sc-border);
|
|
||||||
border-radius: 9999px;
|
|
||||||
background: var(--sc-surface);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sc-primary-color-options button > span {
|
|
||||||
width: 1.25rem;
|
|
||||||
height: 1.25rem;
|
|
||||||
border-radius: 9999px;
|
|
||||||
background: var(--sc-picker-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sc-primary-color-options button:focus-visible,
|
|
||||||
.sc-primary-color-options button.sc-primary-color-selected {
|
|
||||||
outline: 2px solid var(--sc-ring);
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sc-primary-color-default {
|
|
||||||
color: var(--sc-muted-fg);
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sc-primary-color-name {
|
|
||||||
color: var(--sc-muted-fg);
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user