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

mega menu - fixing click area #481

Merged
merged 2 commits into from
Jun 14, 2024
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
17 changes: 12 additions & 5 deletions frontend/assets/css/prime_megamenu.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
.p-megamenu {
background: var(--container-background);
user-select: none;
z-index: 1; // without this, the menu keeps a very high z-index when it is open in mobile mode and then the window is enlarged (the change of mode closes the menu but does not reset its z-index, so the menu bar floats above the search bar)
z-index: 1; // without this, the menu keeps a very high z-index when it is open in mobile mode and then the window is enlarged (the change of mode closes the menu but does not reset its z-index, so the menu bar floats above the search bar)

.p-megamenu-root-list:focus {
outline: none;
}

.p-menuitem-active{
.p-menuitem-active {
.p-submenu-icon {
transform: rotate(90deg);
}
}

.p-menuitem > .p-menuitem-content .p-menuitem-link {
padding: 12px 16px;
display: flex;
align-items: center;
.p-menuitem-text {
padding: 0 16px;
> a,
> div {
flex-grow: 1;
padding: 12px 0;
display: flex;
align-items: center;
.p-menuitem-text {
flex-grow: 1;
}
}
}
.p-menuitem:not(.orange-box) > .p-menuitem-content .p-menuitem-link {
Expand Down Expand Up @@ -84,7 +91,7 @@
}
&:not(.p-highlight):not(.p-disabled) > .p-menuitem-content:hover {
background: var(--container-background);
.p-menuitem-link >.p-menuitem-text {
.p-menuitem-link > .p-menuitem-text {
opacity: 0.8;
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/bc/header/MegaMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,9 @@ defineExpose({
<span>{{ item.label }}</span>
</span>
</BcLink>
<span v-else class="pointer p-menuitem-text" :class="[item.class]" @click="item.command?.(null as any)">
<div v-else class="pointer p-menuitem-text" :class="[item.class]" @click="item.command?.(null as any)">
{{ item.label }}
</span>
</div>
<FontAwesomeIcon v-if="hasSubmenu" :icon="faCaretRight" class="p-icon p-submenu-icon" />
</span>
</template>
Expand Down
26 changes: 15 additions & 11 deletions frontend/composables/useCurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function useCurrency () {
const { networkInfo } = useNetworkStore()
const { t: $t } = useI18n()
const showInDevelopment = Boolean(useRuntimeConfig().public.showInDevelopment)
const available = ref<Currency[]>([])
const withLabel = ref<{currency: Currency, label: string}[]>([])

const selectedCurrency = useCookie<Currency>(COOKIE_KEY.CURRENCY, { default: () => 'NAT' })
function setCurrency (newCurrency: Currency) {
Expand All @@ -26,26 +28,28 @@ export function useCurrency () {
)
})

const available = computed<Currency[]>(() => {
const list: Currency[] = [networkInfo.value.elCurrency]
watch([latestState, networkInfo], () => {
let list: Currency[] = [networkInfo.value.elCurrency]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, when the user switches between networks, the list of available currencies might stay outdated for a few seconds until the rates changes.
I am thinking about a switch between Gnosis (GNO + xDAI) and Ethereum (where these currencies might not be listed) for example.

A possible fix would be on line 31:

watch([latestState,networkInfo], () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense - changed!

if (networkInfo.value.clCurrency !== networkInfo.value.elCurrency) {
list.push(networkInfo.value.clCurrency)
}
if (showInDevelopment) {
list.splice(0, 1, 'NAT')
}
return list.concat((latestState.value?.exchange_rates || []).map(r => r.code as Currency))
})
list = list.concat((latestState.value?.exchange_rates || []).map(r => r.code as Currency))
// make sure we update the currency list only if it really changed (to prevent reactivity triggers)
if (JSON.stringify(list) !== JSON.stringify(available.value)) {
available.value = list

withLabel.value = list.map(currency => ({
currency,
label: $t(`currency.label.${currency}`, {}, rates.value?.[currency]?.currency || currency)
}))
}
}, { immediate: true })

const currency = computed(() => selectedCurrency.value && available.value.includes(selectedCurrency.value) ? selectedCurrency.value : available.value[0])

const withLabel = computed(() => {
return available.value?.map(currency => ({
currency,
label: $t(`currency.label.${currency}`, {}, rates.value?.[currency]?.currency || currency)
}))
})

watch([latestState, selectedCurrency], () => {
// once we loaded our latestState and see that we don't support the currency we switch back to the first item
if (latestState.value && !available.value.includes(selectedCurrency.value)) {
Expand Down
Loading