-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #528 from gobitfly/BIDS-2859/frontend-subscription…
…-to-notifications-modal (BIDS-2859) frontend - subscription to notifications modal
- Loading branch information
Showing
34 changed files
with
1,223 additions
and
215 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -27,6 +27,7 @@ a { | |
pointer-events: none; | ||
} | ||
} | ||
|
||
.link { | ||
color: var(--link-color); | ||
cursor: pointer; | ||
|
This file contains 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,46 @@ | ||
<script setup lang="ts"> | ||
import type { Nullable } from 'primevue/ts-helpers' | ||
import InputNumber from 'primevue/inputnumber' | ||
const props = defineProps<{ | ||
min: number, | ||
max: number, | ||
maxFractionDigits: number | ||
}>() | ||
const parentVmodel = defineModel<number>({ required: true }) | ||
const bridgedVmodel = usePrimitiveRefBridge<number, Nullable<number>>(parentVmodel, n => (isNaN(n) ? null : n), n => (n ?? NaN)) | ||
function sendValue (input: Nullable<number>) : void { | ||
if (input === undefined || input === null || isNaN(input) || input < props.min || input > props.max) { | ||
input = NaN | ||
} else { | ||
const stringifyied = String(input) | ||
const comma = stringifyied.indexOf('.') | ||
if (comma >= 0 && stringifyied.length - comma - 1 > props.maxFractionDigits) { | ||
input = NaN | ||
} | ||
} | ||
bridgedVmodel.pauseBridgeFromNowOn() // this allows us to output the value to the parent v-model without causing an injection of the value back into the InputNumber v-model (that would empty InputNumber at each key stroke if the input is invalid) | ||
parentVmodel.value = input | ||
bridgedVmodel.wakeupBridgeAtNextTick() | ||
} | ||
</script> | ||
|
||
<template> | ||
<InputNumber | ||
v-model="bridgedVmodel" | ||
:min="min" | ||
:max="max" | ||
:max-fraction-digits="maxFractionDigits" | ||
locale="en-US" | ||
class="why-the-hell-dont-they-fix-this-bug" | ||
@input="input => { if (typeof input.value !== 'string') sendValue(input.value) }" | ||
/> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.why-the-hell-dont-they-fix-this-bug { | ||
:deep(input) { width: 100%; } | ||
} | ||
</style> |
This file contains 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,55 @@ | ||
<script setup lang="ts"> | ||
import type { MultiBarItem } from '~/types/multiBar' | ||
import { IconNetwork } from '#components' | ||
import { ChainInfo, ChainIDs } from '~/types/network' | ||
const props = defineProps<{ | ||
readonlyNetworks?: ChainIDs[] | ||
}>() | ||
const { availableNetworks, isNetworkDisabled } = useNetworkStore() | ||
/** If prop `:readonly-networks` is given: | ||
* the networks in array `:readonly-networks` are shown to the user and they are unclickable, | ||
* Otherwise, give a v-model. If the v-model is | ||
* a ChainIDs: only one network can be selected by the user, | ||
* an array of ChainIDs: several networks can be selected by the user */ | ||
const selection = defineModel<ChainIDs|ChainIDs[]>({ required: false }) | ||
let barSelection: Ref<string> | Ref<string[]> | ||
if (props.readonlyNetworks) { | ||
barSelection = ref<string[]>([]) | ||
} else if (Array.isArray(selection.value)) { | ||
barSelection = useArrayRefBridge<ChainIDs, string>(selection as Ref<ChainIDs[]>) | ||
} else { | ||
barSelection = usePrimitiveRefBridge<ChainIDs, string>(selection as Ref<ChainIDs>) | ||
} | ||
const buttons = computed(() => { | ||
const list: MultiBarItem[] = [] | ||
const source = props.readonlyNetworks || availableNetworks.value | ||
for (const chainId of source) { | ||
list.push({ | ||
component: IconNetwork, | ||
componentProps: { chainId, harmonizePerceivedSize: true, colored: true }, | ||
componentClass: 'maximum', | ||
value: String(chainId), | ||
disabled: isNetworkDisabled(chainId), | ||
tooltip: ChainInfo[chainId].name | ||
}) | ||
} | ||
return list | ||
}) | ||
</script> | ||
|
||
<template> | ||
<BcToggleMultiBar v-if="Array.isArray(barSelection)" v-model="barSelection" :buttons="buttons" :readonly-mode="!!readonlyNetworks" /> | ||
<BcToggleSingleBar v-else v-model="barSelection" :buttons="buttons" layout="minimal" /> | ||
</template> | ||
|
||
<style lang="scss"> | ||
.maximum { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> |
This file contains 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 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 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 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 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.