-
Notifications
You must be signed in to change notification settings - Fork 7
feat: team logos #40
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
feat: team logos #40
Changes from all commits
ed738f2
b5fb714
41cdd0b
5058adf
99d24f6
86fec26
5e4d110
f9513b8
a9b2e52
7563586
63ca1fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| These avatars are sourced from [Outspace Studios](https://avatars.outpace.systems/). | ||
| The original source is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from "vue"; | ||
|
|
||
| type Props = { | ||
| teamName: string; | ||
| logoUrl: string | null; | ||
| classNames?: string; | ||
| }; | ||
|
|
||
| const props = withDefaults(defineProps<Props>(), { | ||
| classNames: "size-5 rounded-full object-cover", | ||
| }); | ||
|
|
||
| const AVATAR_BASE = "/assets/forms_pro/avatars/avatar-"; | ||
|
|
||
| /** Derives a stable 1–50 index from the team name (length + first/last char) so the same name always maps to the same avatar when no logoUrl is set. */ | ||
| function avatarIndex(name: string): number { | ||
| const n = name.length; | ||
| if (n === 0) return 1; | ||
| const h = n + name.charCodeAt(0) + (n > 1 ? name.charCodeAt(n - 1) : 0); | ||
| return (((h % 50) + 50) % 50) + 1; | ||
| } | ||
|
|
||
| const avatarSrc = computed(() => | ||
| props.logoUrl ? props.logoUrl : `${AVATAR_BASE}${avatarIndex(props.teamName)}.jpg` | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <img :src="avatarSrc" :alt="teamName" :class="classNames" /> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <script setup lang="ts"> | ||
| import { useUser } from "@/stores/user"; | ||
| import { Dropdown } from "frappe-ui"; | ||
| import { ChevronsUpDown } from "lucide-vue-next"; | ||
| import { computed, inject, ref } from "vue"; | ||
| import CreateTeamDialog from "@/components/team/CreateTeamDialog.vue"; | ||
| import TeamSwitcherItem from "@/components/team/TeamSwitcherItem.vue"; | ||
| import TeamLogo from "@/components/team/TeamLogo.vue"; | ||
|
|
||
| const isSidebarCollapsed = inject("isSidebarCollapsed"); | ||
|
|
||
| const showCreateTeamDialog = ref(false); | ||
| const userStore = useUser(); | ||
|
|
||
| const teamOptions = computed(() => { | ||
| return userStore.userTeams | ||
| ?.filter((team) => team.name !== userStore.currentTeam?.name) | ||
| .map((team) => ({ | ||
| label: `${team.team_name}`, | ||
| logoUrl: team.logo ?? undefined, | ||
| isTeam: true, | ||
| onClick: () => { | ||
| userStore.switchTeam(team); | ||
| }, | ||
| })); | ||
| }); | ||
|
|
||
| const groupOptions = computed(() => { | ||
| return [ | ||
| { | ||
| group: "Switch Team", | ||
| items: teamOptions.value, | ||
| }, | ||
| { | ||
| group: "", | ||
| items: [ | ||
| { | ||
| label: "Create New Team", | ||
| onClick: () => { | ||
| showCreateTeamDialog.value = true; | ||
| }, | ||
| icon: "plus", | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
| }); | ||
| </script> | ||
| <template> | ||
| <CreateTeamDialog v-model="showCreateTeamDialog" /> | ||
| <Dropdown :options="groupOptions"> | ||
| <template #default="{ open }"> | ||
| <div | ||
| class="flex items-center gap-2 p-2 rounded cursor-pointer transition-colors duration-150 ease-[cubic-bezier(0.4, 0, 0.2, 1)] hover:bg-surface-gray-2" | ||
| :class="{ 'bg-surface-white': open, 'px-1.5 ': isSidebarCollapsed }" | ||
| > | ||
| <TeamLogo | ||
| v-if="isSidebarCollapsed" | ||
| :team-name="userStore.currentTeam!.team_name" | ||
| :logo-url="userStore.currentTeam?.logo ?? null" | ||
| /> | ||
| <div v-else class="flex items-center gap-2 justify-between w-full"> | ||
| <TeamSwitcherItem | ||
| :label="userStore.currentTeam!.team_name" | ||
| :logo-url="userStore.currentTeam?.logo ?? null" | ||
| /> | ||
| <ChevronsUpDown class="size-4 text-ink-gray-6" /> | ||
| </div> | ||
| </div> | ||
| </template> | ||
| <template #item="{ item }"> | ||
| <!-- @vue-expect-error --> | ||
| <TeamSwitcherItem | ||
| v-if="item.isTeam" | ||
| class="p-2 w-full hover:bg-surface-gray-2 cursor-pointer rounded" | ||
| :label="item.label" | ||
| :logo-url="item.logoUrl" | ||
| /> | ||
| <Button | ||
| v-else | ||
| variant="ghost" | ||
| @click="item.onClick" | ||
| :icon-left="item.icon" | ||
| class="w-full" | ||
| :label="item.label" | ||
| /> | ||
| </template> | ||
| </Dropdown> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||||||||||||||||||||||||
| import TeamLogo from "./TeamLogo.vue"; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| type props = { | ||||||||||||||||||||||||||||||||||||||||||
| label: string; | ||||||||||||||||||||||||||||||||||||||||||
| logoUrl: string | null; | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const props = defineProps<props>(); | ||||||||||||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||||||||||||
| <template> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="flex items-center gap-2 shrink-0"> | ||||||||||||||||||||||||||||||||||||||||||
| <TeamLogo :team-name="label" :logo-url="logoUrl" /> | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix TypeScript error: The CI pipeline reports TS2322 on Line 13. The Proposed fix- <TeamLogo :team-name="label" :logo-url="logoUrl" />
+ <TeamLogo :team-name="label" :logo-url="logoUrl ?? undefined" />Alternatively, align the prop type with 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Frontend TypeScript[error] 13-13: TS2322: Type 'string | null' is not assignable to type 'string | undefined'. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| <span class="text-base font-medium text-ink-gray-7 whitespace-nowrap"> | ||||||||||||||||||||||||||||||||||||||||||
| {{ label }} | ||||||||||||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.