Repository navigation
feat(sidebar): workspace switcher with Platform's menu, links and avatar colors #2154
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
Open
PabloWiedemann
wants to merge
4
commits into
main
Choose a base branch
from
PabloWiedemann/workspace-switcher-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+822
−579
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ce630da
feat(sidebar): workspace switcher with Platform's menu, links and ava…
PabloWiedemann 8b05c25
refactor(sidebar): build the workspace switcher on the design-system …
PabloWiedemann 03fd3b5
fix(sidebar): translate workspace plan names
PabloWiedemann 7c27c84
fix(sidebar): always offer one Personal row in the workspace switcher
PabloWiedemann 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
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
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,32 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { mount } from '@vue/test-utils' | ||
|
|
||
| import WorkspaceAvatar from './WorkspaceAvatar.vue' | ||
|
|
||
| function initialOf(workspaceName: string): string { | ||
| return mount(WorkspaceAvatar, { props: { workspaceName, subscriptionTier: null } }).text() | ||
| } | ||
|
|
||
| describe('WorkspaceAvatar', () => { | ||
| it('shows the first letter of the name in upper case', () => { | ||
| expect(initialOf('harbor')).toBe('H') | ||
| }) | ||
|
|
||
| it('skips leading spaces', () => { | ||
| expect(initialOf(' harbor')).toBe('H') | ||
| }) | ||
|
|
||
| it('keeps a whole emoji or accented letter', () => { | ||
| expect(initialOf('🇩🇪 Berlin')).toBe('🇩🇪') | ||
| expect(initialOf('👩💻 Studio')).toBe('👩💻') | ||
| expect(initialOf('école')).toBe('É') | ||
| }) | ||
|
|
||
| it('keeps a letter whose upper case is two letters', () => { | ||
| expect(initialOf('ßtudio')).toBe('ß') | ||
| }) | ||
|
|
||
| it('shows a question mark for a blank name', () => { | ||
| expect(initialOf(' ')).toBe('?') | ||
| }) | ||
| }) |
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,41 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { workspaceAvatarStyle } from '@comfyorg/design-system/workspaceAvatar' | ||
|
|
||
| const { | ||
| workspaceName, | ||
| subscriptionTier, | ||
| size = 'md' | ||
| } = defineProps<{ | ||
| workspaceName: string | ||
| subscriptionTier: string | null | undefined | ||
| size?: 'sm' | 'md' | ||
| }>() | ||
|
|
||
| const graphemes = new Intl.Segmenter() | ||
|
|
||
| function firstGrapheme(text: string): string | undefined { | ||
| return graphemes.segment(text.trim())[Symbol.iterator]().next().value?.segment | ||
| } | ||
|
|
||
| function initialOf(name: string): string { | ||
| const first = firstGrapheme(name) | ||
| if (!first) return '?' | ||
| const upper = first.toUpperCase() | ||
| return firstGrapheme(upper) === upper ? upper : first | ||
| } | ||
|
|
||
| const initial = computed(() => initialOf(workspaceName)) | ||
| const avatarStyle = computed(() => workspaceAvatarStyle(workspaceName, subscriptionTier)) | ||
| </script> | ||
|
|
||
| <template> | ||
| <span | ||
| class="inline-flex shrink-0 items-center justify-center bg-card font-semibold text-foreground" | ||
| :class="size === 'sm' ? 'size-6 rounded-sm text-xs' : 'size-8 rounded-md text-sm'" | ||
| :style="avatarStyle" | ||
| data-testid="workspace-avatar" | ||
| aria-hidden="true" | ||
| >{{ initial }}</span | ||
| > | ||
| </template> | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Nit —
new Intl.Segmenter()is constructed inside<script setup>, so every avatar instance builds its own segmenter; with one avatar per workspace row plus the trigger and submenu header this is avoidable allocation. Hoist it to module scope. Raised by 1 of 8 reviewers (gemini-3.1-pro adversarial).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changing: there are only a few avatars per menu, and hoisting needs a second script block. That costs more code than the allocation it saves.