-
-
Notifications
You must be signed in to change notification settings - Fork 15
Make EmergencyBadge tooltip work on touch devices and simplify #442
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
mindmonk
merged 8 commits into
develop
from
feature/emergency-badge-popover-mobile-tooltip
May 4, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae9f0d9
switch EmergencyBadge tooltip to popover with anchor positioning for …
mindmonk 39935ac
simplify EmergencyBadge to warning/error types and drop position prop
mindmonk 0b6c801
undo
mindmonk c4e2524
use error type for broken vault EmergencyBadge
mindmonk 4babd92
replace popover API with CSS-only hover tooltip in EmergencyBadge
mindmonk aace846
remove arrow, add min-width and flip-block fallback to EmergencyBadge…
mindmonk bc3dd54
clean up EmergencyBadge style
mindmonk a4f27a7
shift EmergencyBadge tooltip away from viewport edge and suppress des…
mindmonk 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
Some comments aren't visible on the classic Files Changed page.
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
121 changes: 30 additions & 91 deletions
121
frontend/src/components/emergencyaccess/EmergencyBadge.vue
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,107 +1,46 @@ | ||
| <template> | ||
| <div v-if="type !== 'none'" class="relative mr-3 group/badge"> | ||
| <!-- Badge --> | ||
| <span | ||
| class="inline-flex items-center gap-2 rounded-full px-2 py-2 text-xs font-medium cursor-default ring-1" | ||
| :class="badgeClasses" | ||
| <div class="group mr-3 inline-block" @click.stop.prevent> | ||
| <button | ||
| type="button" | ||
| class="inline-flex items-center gap-2 rounded-full p-2 text-xs font-medium cursor-default ring-1 outline-none focus-visible:ring-2" | ||
| :class="isError ? 'bg-red-100 ring-red-300/70 text-red-800' : 'bg-yellow-50 ring-yellow-300/70 text-yellow-800'" | ||
| :style="{ anchorName: anchor }" | ||
| :aria-label="title" | ||
| > | ||
| <ExclamationTriangleIcon class="h-4 w-4" :class="iconColor" /> | ||
| </span> | ||
|
|
||
| <!-- Tooltip --> | ||
| <div | ||
| class="invisible opacity-0 group-hover/badge:visible group-hover/badge:opacity-100 transition-opacity duration-150 absolute -top-2 transform -translate-y-full w-max max-w-xs z-20" | ||
| :class="positionClasses" | ||
| <ExclamationTriangleIcon class="size-4" :class="isError ? 'text-red-600' : 'text-yellow-500'" /> | ||
| </button> | ||
|
|
||
| <div | ||
| class="tooltip-panel fixed mb-2 z-20 px-2 py-1 rounded shadow-sm border text-xs hyphens-auto invisible opacity-0 transition-[opacity,visibility] duration-150 group-hover:visible group-hover:opacity-100 group-has-focus-visible:visible group-has-focus-visible:opacity-100 pointer-coarse:group-focus-within:visible pointer-coarse:group-focus-within:opacity-100" | ||
| :class="isError ? 'bg-red-50 border-red-300 text-red-900' : 'bg-yellow-50 border-yellow-300 text-yellow-900'" | ||
| :style="{ positionAnchor: anchor }" | ||
| role="tooltip" | ||
| > | ||
| <div class="px-2 py-1 rounded shadow-sm text-xs hyphens-auto border relative" :class="tooltipClasses"> | ||
| <b>{{ title }}</b><br /> | ||
| <span>{{ message }}</span> | ||
|
|
||
| <!-- Arrow --> | ||
| <div | ||
| class="absolute bottom-0 transform translate-y-1/2 rotate-45 w-2 h-2 border-r border-b" | ||
| :class="[arrowClasses, arrowPositionClasses]" | ||
| ></div> | ||
| </div> | ||
| <p class="font-bold">{{ title }}</p> | ||
| <p>{{ message }}</p> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue'; | ||
| import { computed, useId } from 'vue'; | ||
| import { ExclamationTriangleIcon } from '@heroicons/vue/24/solid'; | ||
|
|
||
| const props = defineProps<{ | ||
| type: 'notCouncil' | 'broken' | 'noRedundancy' | 'insufficientCouncilMembers' | 'none'; | ||
| type: 'warning' | 'error'; | ||
| title: string; | ||
| message: string; | ||
| position?: 'center' | 'left' | 'right'; | ||
| }>(); | ||
|
|
||
| const positionClasses = computed(() => { | ||
| switch (props.position) { | ||
| case 'left': | ||
| return 'left-0'; | ||
| case 'right': | ||
| return 'right-0'; | ||
| case 'center': | ||
| default: | ||
| return 'left-1/2 -translate-x-1/2'; | ||
| } | ||
| }); | ||
|
|
||
| const badgeClasses = computed(() => { | ||
| switch (props.type) { | ||
| case 'notCouncil': | ||
| case 'insufficientCouncilMembers': | ||
| case 'noRedundancy': | ||
| return 'bg-yellow-50 ring-yellow-300/70 text-yellow-800'; | ||
| case 'broken': | ||
| return 'bg-red-100 ring-red-300/70 text-red-800'; | ||
| default: | ||
| return ''; | ||
| } | ||
| }); | ||
|
|
||
| const tooltipClasses = computed(() => { | ||
| switch (props.type) { | ||
| case 'notCouncil': | ||
| case 'insufficientCouncilMembers': | ||
| case 'noRedundancy': | ||
| return 'bg-yellow-50 border-yellow-300 text-yellow-900'; | ||
| case 'broken': | ||
| return 'bg-red-50 border-red-300 text-red-900'; | ||
| default: | ||
| return ''; | ||
| } | ||
| }); | ||
|
|
||
| const arrowClasses = computed(() => { | ||
| switch (props.type) { | ||
| case 'notCouncil': | ||
| case 'insufficientCouncilMembers': | ||
| case 'noRedundancy': | ||
| return 'bg-yellow-50 border-yellow-300'; | ||
| case 'broken': | ||
| return 'bg-red-50 border-red-300'; | ||
| default: | ||
| return ''; | ||
| } | ||
| }); | ||
|
|
||
| const arrowPositionClasses = computed(() => { | ||
| switch (props.position) { | ||
| case 'left': | ||
| return 'left-2'; | ||
| case 'right': | ||
| return 'right-2'; | ||
| case 'center': | ||
| default: | ||
| return 'left-1/2 -translate-x-1/2'; | ||
| } | ||
| }); | ||
|
|
||
| const iconColor = computed(() => { | ||
| return props.type === 'broken' ? 'text-red-600' : 'text-yellow-500'; | ||
| }); | ||
| const anchor = `--ea-anchor-${useId()}`; | ||
| const isError = computed(() => props.type === 'error'); | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tooltip-panel { | ||
| bottom: anchor(top); | ||
| left: max(1rem, calc(anchor(center) - 10rem)); | ||
| right: max(1rem, calc(anchor(center) - 10rem)); | ||
| position-try-fallbacks: flip-block; | ||
| } | ||
| </style> |
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.
Uh oh!
There was an error while loading. Please reload this page.