-
Notifications
You must be signed in to change notification settings - Fork 17
feat: responsive notifications #985
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bf7ea8e
feat: responsive notifications
elibosley ee884f1
fix: remove unused date-fns
elibosley 5b8b8c1
fix: marked single input
elibosley 6251a2f
fix: downgrade marked to fix changelog preview issue
elibosley 544e3a3
fix: render function fixed
elibosley eb6c071
fix: 12 hour timestamp logic corrected
elibosley d2f3358
Update web/components/Notifications/Sidebar.vue
elibosley 04ee78a
fix: recreate package-lock to fix issues
elibosley e5bd1ad
feat: viewport watch refactor
elibosley e18a874
fix: improve typing and format lookup
elibosley 0a2cf0a
feat: use text-secondary-foreground instead of gray
elibosley 3303cc6
fix: edit settings padding issue
elibosley 2a9af10
fix: check width before changing viewport
elibosley 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <script setup lang="ts"> | ||
| import { Button } from '@/components/shadcn/button'; | ||
| import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/shadcn/sheet'; | ||
| import { useMutation, useQuery } from '@vue/apollo-composable'; | ||
| import { Button } from '@/components/shadcn/button'; | ||
| // eslint-disable-next-line @typescript-eslint/consistent-type-imports -- false positive :( | ||
| import { Importance, NotificationType } from '~/composables/gql/graphql'; | ||
| import { | ||
|
|
@@ -47,86 +47,84 @@ const overview = computed(() => { | |
| <span class="sr-only">Notifications</span> | ||
| <NotificationsIndicator :overview="overview" /> | ||
| </SheetTrigger> | ||
|
|
||
| <!-- We remove the horizontal padding from the container to keep the NotificationList's scrollbar in the right place --> | ||
| <SheetContent | ||
| :to="teleportTarget" | ||
| class="w-full max-w-[100vw] sm:max-w-[540px] h-screen px-0" | ||
| class="w-full max-w-[100vw] sm:max-w-[540px] max-h-screen h-screen min-h-screen px-0 flex flex-col gap-5 pb-0" | ||
| > | ||
| <div class="flex flex-col h-full gap-5"> | ||
| <SheetHeader class="ml-1 px-6 flex items-baseline gap-1"> | ||
| <SheetTitle class="text-2xl">Notifications</SheetTitle> | ||
| <a href="/Settings/Notifications"> | ||
| <Button variant="link" size="sm" class="p-0 h-auto"> Edit Settings </Button> | ||
| </a> | ||
| </SheetHeader> | ||
| <div class="relative flex flex-col h-full w-full"> | ||
| <SheetHeader class="ml-1 px-6 items-baseline gap-1 pb-2"> | ||
| <SheetTitle class="text-2xl">Notifications</SheetTitle> | ||
| <a href="/Settings/Notifications"> | ||
| <Button variant="link" size="sm" class="p-0 h-auto">Edit Settings</Button> | ||
| </a> | ||
| </SheetHeader> | ||
| <Tabs | ||
| default-value="unread" | ||
| class="flex flex-1 flex-col min-h-0" | ||
| aria-label="Notification filters" | ||
| > | ||
| <div class="flex flex-row justify-between items-center flex-wrap gap-5 px-6"> | ||
|
Contributor
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. Unneeded flex-row. |
||
| <TabsList class="flex" aria-label="Filter notifications by status"> | ||
| <TabsTrigger value="unread"> | ||
| Unread <span v-if="overview">({{ overview.unread.total }})</span> | ||
| </TabsTrigger> | ||
| <TabsTrigger value="archived"> | ||
| Archived <span v-if="overview">({{ overview.archive.total }})</span> | ||
| </TabsTrigger> | ||
| </TabsList> | ||
| <TabsContent value="unread" class="flex-col items-end"> | ||
| <Button | ||
| :disabled="loadingArchiveAll" | ||
| variant="link" | ||
| size="sm" | ||
| class="text-foreground hover:text-destructive transition-none" | ||
| @click="confirmAndArchiveAll" | ||
| > | ||
| Archive All | ||
| </Button> | ||
| </TabsContent> | ||
| <TabsContent value="archived" class="flex-col items-end"> | ||
| <Button | ||
| :disabled="loadingDeleteAll" | ||
| variant="link" | ||
| size="sm" | ||
| class="text-foreground hover:text-destructive transition-none" | ||
| @click="confirmAndDeleteArchives" | ||
| > | ||
| Delete All | ||
| </Button> | ||
| </TabsContent> | ||
|
|
||
| <!-- min-h-0 prevents the flex container from expanding beyond its containing bounds. --> | ||
| <!-- this is necessary because flex items have a default min-height: auto, --> | ||
| <!-- which means they won't shrink below the height of their content, even if you use flex-1 or other flex properties. --> | ||
| <Tabs default-value="unread" class="flex-1 flex flex-col min-h-0" activation-mode="manual"> | ||
| <div class="flex flex-row justify-between items-center flex-wrap gap-5 px-6"> | ||
| <TabsList class="ml-[1px]"> | ||
| <TabsTrigger value="unread"> | ||
| Unread <span v-if="overview">({{ overview.unread.total }})</span> | ||
| </TabsTrigger> | ||
| <TabsTrigger value="archived"> | ||
| Archived <span v-if="overview">({{ overview.archive.total }})</span> | ||
| </TabsTrigger> | ||
| </TabsList> | ||
| <TabsContent value="unread"> | ||
| <Button | ||
| :disabled="loadingArchiveAll" | ||
| variant="link" | ||
| size="sm" | ||
| class="text-foreground hover:text-destructive transition-none" | ||
| @click="confirmAndArchiveAll" | ||
| > | ||
| Archive All | ||
| </Button> | ||
| </TabsContent> | ||
| <TabsContent value="archived"> | ||
| <Button | ||
| :disabled="loadingDeleteAll" | ||
| variant="link" | ||
| size="sm" | ||
| class="text-foreground hover:text-destructive transition-none" | ||
| @click="confirmAndDeleteArchives" | ||
| > | ||
| Delete All | ||
| </Button> | ||
| </TabsContent> | ||
|
|
||
| <Select | ||
| @update:model-value=" | ||
| (val) => { | ||
| importance = val === 'all' ? undefined : (val as Importance); | ||
| } | ||
| " | ||
| > | ||
| <SelectTrigger class="h-auto"> | ||
| <SelectValue class="text-gray-400 leading-6" placeholder="Filter By" /> | ||
| </SelectTrigger> | ||
| <SelectContent :to="teleportTarget"> | ||
| <SelectGroup> | ||
| <SelectLabel>Notification Types</SelectLabel> | ||
| <SelectItem value="all">All Types</SelectItem> | ||
| <SelectItem :value="Importance.Alert"> Alert </SelectItem> | ||
| <SelectItem :value="Importance.Info">Info</SelectItem> | ||
| <SelectItem :value="Importance.Warning">Warning</SelectItem> | ||
| </SelectGroup> | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
| <Select | ||
| @update:model-value=" | ||
| (val) => { | ||
| importance = val === 'all' ? undefined : (val as Importance); | ||
| } | ||
| " | ||
| > | ||
| <SelectTrigger class="h-auto"> | ||
| <SelectValue class="text-gray-400 leading-6" placeholder="Filter By" /> | ||
| </SelectTrigger> | ||
| <SelectContent :to="teleportTarget"> | ||
| <SelectGroup> | ||
| <SelectLabel>Notification Types</SelectLabel> | ||
| <SelectItem value="all">All Types</SelectItem> | ||
| <SelectItem :value="Importance.Alert"> Alert </SelectItem> | ||
| <SelectItem :value="Importance.Info">Info</SelectItem> | ||
| <SelectItem :value="Importance.Warning">Warning</SelectItem> | ||
| </SelectGroup> | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
|
|
||
| <TabsContent value="unread" class="flex-1 min-h-0 mt-5"> | ||
| <NotificationsList :importance="importance" :type="NotificationType.Unread" /> | ||
| </TabsContent> | ||
| <TabsContent value="unread" class="flex-col flex-1 min-h-0"> | ||
| <NotificationsList :importance="importance" :type="NotificationType.Unread" /> | ||
| </TabsContent> | ||
|
|
||
| <TabsContent value="archived" class="flex-1 min-h-0 mt-5"> | ||
| <NotificationsList :importance="importance" :type="NotificationType.Archive" /> | ||
| </TabsContent> | ||
| </Tabs> | ||
| <TabsContent value="archived" class="flex-col flex-1 min-h-0"> | ||
| <NotificationsList :importance="importance" :type="NotificationType.Archive" /> | ||
| </TabsContent> | ||
| </Tabs> | ||
| </div> | ||
| </SheetContent> | ||
| </Sheet> | ||
|
|
||
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 |
|---|---|---|
| @@ -1,14 +1,45 @@ | ||
| <script setup lang="ts"> | ||
| import { DialogRoot, type DialogRootEmits, type DialogRootProps, useForwardPropsEmits } from 'radix-vue' | ||
| import { DialogRoot, useForwardPropsEmits, type DialogRootEmits, type DialogRootProps } from 'radix-vue'; | ||
|
|
||
| const props = defineProps<DialogRootProps & { class?: string }>() | ||
| const emits = defineEmits<DialogRootEmits>() | ||
| const MOBILE_VIEWPORT = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0' as const; | ||
|
|
||
| const forwarded = useForwardPropsEmits(props, emits) | ||
| const props = defineProps<DialogRootProps & { class?: string }>(); | ||
| const emits = defineEmits<DialogRootEmits>(); | ||
|
|
||
| const getViewport = (): string => { | ||
| return document.querySelector('meta[name="viewport"]')?.getAttribute('content') ?? 'width=1300'; | ||
| }; | ||
| const updateViewport = (viewport: string): void => { | ||
| if (window.innerWidth < 500) { | ||
| const meta = document.querySelector('meta[name="viewport"]'); | ||
| if (meta) { | ||
| meta.setAttribute('content', viewport); | ||
| } else { | ||
| const meta = document.createElement('meta'); | ||
| meta.name = 'viewport'; | ||
| meta.content = viewport; | ||
| document.head.appendChild(meta); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| const forwarded = useForwardPropsEmits(props, emits); | ||
| const initialViewport = ref(getViewport()); | ||
| const openListener = (opened: boolean) => { | ||
| if (opened) { | ||
| updateViewport(MOBILE_VIEWPORT); | ||
| } else { | ||
| updateViewport(initialViewport.value); | ||
| } | ||
| }; | ||
|
|
||
| onUnmounted(() => { | ||
| updateViewport(initialViewport.value); | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <DialogRoot v-bind="forwarded"> | ||
| <DialogRoot v-bind="forwarded" @update:open="openListener"> | ||
| <slot /> | ||
| </DialogRoot> | ||
| </template> |
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
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.
Display flex defaults to flex row can remove flex-row.