Skip to content
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

workspace color fixes part2 #5045

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@
import Toggle from '$lib/components/Toggle.svelte'

let colorEnabled = false
let workspaceColor = $usersWorkspaceStore?.workspaces.find(w => w.id === $workspaceStore)?.color
let workspaceColor: string | undefined = undefined
let savedWorkspaceColor: string | undefined = undefined
let lastWorkspace: string | undefined = undefined

export let open = false

$: if ($usersWorkspaceStore && $workspaceStore !== lastWorkspace) {
lastWorkspace = $workspaceStore
savedWorkspaceColor = $usersWorkspaceStore.workspaces.find(
(w) => w.id === $workspaceStore
)?.color
workspaceColor = savedWorkspaceColor
}

$: colorEnabled = !!workspaceColor
$: if (colorEnabled && !workspaceColor) generateRandomColor()

function generateRandomColor() {
Expand All @@ -34,19 +45,18 @@
})

usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces())
workspaceColor = colorToSave

savedWorkspaceColor = colorToSave
sendUserToast(`Workspace color updated.`)
}
</script>

<div>
<p class="font-semibold text-sm">Workspace Color</p>
<div class="flex flex-row gap-0.5 items-center">
{#if workspaceColor}
{#if savedWorkspaceColor}
<div
class="w-5 h-5 rounded-full border border-gray-300 dark:border-gray-600"
style="background-color: {workspaceColor}"
style="background-color: {savedWorkspaceColor}"
/>
{:else}
<span class="text-xs text-secondary">No color set</span>
Expand All @@ -72,7 +82,9 @@
<span class="text-secondary text-sm">Workspace color</span>
<div class="flex items-center gap-2">
<Toggle bind:checked={colorEnabled} options={{ right: 'Enable' }} />
<input class="w-10" type="color" bind:value={workspaceColor} disabled={!colorEnabled} />
{#if colorEnabled}
<input class="w-10" type="color" bind:value={workspaceColor} disabled={!colorEnabled} />
{/if}
<input
type="text"
class="w-24 text-sm"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/sidebar/WorkspaceMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
await toggleSwitchWorkspace(workspace.id)
}}
>
<div class="flex items-center justify-between">
<div class="flex items-center justify-between min-w-0 w-full">
<div>
<div class="text-primary pl-4 truncate text-left text-[1.2em]">{workspace.name}</div>
<div class="text-tertiary font-mono pl-4 text-2xs whitespace-nowrap truncate text-left">
Expand Down