feat: migrate project secrets and user-scoped colors
This commit is contained in:
1 parent
f723afa369
commit
07e25a3cf3
13 files changed
+280
-15
No files matched your search
@@ -1,9 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
import Header from './Header.svelte';
|
||||
import NotificationStack from './NotificationStack.svelte';
|
||||
import PageHeader from './PageHeader.svelte';
|
||||
import { initPrimaryColor, setPrimaryColorUser } from '../primary-color.svelte';
|
||||
|
||||
let {
|
||||
aboutHref,
|
||||
@@ -52,6 +54,12 @@
|
||||
item.href === '/' ? currentPath === '/' : currentPath === item.href || currentPath.startsWith(`${item.href}/`),
|
||||
),
|
||||
);
|
||||
|
||||
$effect(() => {
|
||||
setPrimaryColorUser(username);
|
||||
});
|
||||
|
||||
onMount(() => initPrimaryColor(brand, username));
|
||||
</script>
|
||||
|
||||
<div class={`sc-root sc-app-shell ${className}`} data-theme={theme === 'system' ? undefined : theme}>
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import {
|
||||
PRIMARY_COLOR_PALETTE,
|
||||
initPrimaryColor,
|
||||
primaryColorByName,
|
||||
setPrimaryColor,
|
||||
storedPrimaryColor,
|
||||
} from '../primary-color.svelte'
|
||||
|
||||
let {
|
||||
projectKey,
|
||||
label = 'Primary color',
|
||||
}: {
|
||||
projectKey: string
|
||||
label?: string
|
||||
} = $props()
|
||||
|
||||
let selected = $state('')
|
||||
|
||||
onMount(() => {
|
||||
selected = storedPrimaryColor(projectKey)
|
||||
const stop = initPrimaryColor(projectKey)
|
||||
return stop
|
||||
})
|
||||
|
||||
function choose(name: string) {
|
||||
selected = name
|
||||
setPrimaryColor(projectKey, name)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="sc-primary-color">
|
||||
<span class="sc-label">{label}</span>
|
||||
<div class="sc-primary-color-options" role="radiogroup" aria-label={label}>
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={selected === ''}
|
||||
aria-label="Default"
|
||||
title="Default"
|
||||
class:sc-primary-color-selected={selected === ''}
|
||||
onclick={() => choose('')}
|
||||
>
|
||||
<span class="sc-primary-color-default">—</span>
|
||||
</button>
|
||||
{#each PRIMARY_COLOR_PALETTE as color (color.name)}
|
||||
<button
|
||||
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}
|
||||
</div>
|
||||
{#if selected}
|
||||
<span class="sc-primary-color-name">{primaryColorByName(selected)?.name}</span>
|
||||
{:else}
|
||||
<span class="sc-primary-color-name">Default</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sc-primary-color {
|
||||
display: grid;
|
||||
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>
|
||||
Reference in new issue
Block a user