-
-
Notifications
You must be signed in to change notification settings - Fork 364
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 #3771 from preschian/refactor-identity-composition…
…-api
- Loading branch information
Showing
42 changed files
with
571 additions
and
546 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
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
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,77 @@ | ||
<template> | ||
<div | ||
v-if=" | ||
((showTwitter && twitter) || !showTwitter) && | ||
((showDiscord && discord) || !showDiscord) | ||
" | ||
class="is-flex-wrap-wrap is-flex-grow-1"> | ||
<IdentitySocial | ||
v-if="(showTwitter && twitter) || (showDiscord && discord)" | ||
:twitter="twitter" | ||
:show-twitter="showTwitter" | ||
:discord="discord" | ||
:show-discord="showDiscord" /> | ||
<IdentityChain | ||
v-else | ||
:show-onchain-identity="showOnchainIdentity" | ||
:hide-identity-popover="hideIdentityPopover" | ||
:is-fetching-identity="isFetchingIdentity" | ||
:identity="identity" | ||
:address="address" | ||
:shortened-address="shortenedAddress" | ||
:name="name" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { GenericAccountId } from '@polkadot/types/generic/AccountId' | ||
import { defineEmits } from '#app' | ||
import useIdentity from './utils/useIdentity' | ||
type Address = string | GenericAccountId | undefined | ||
const IdentitySocial = defineAsyncComponent( | ||
() => import('./module/IdentitySocial.vue') | ||
) | ||
const IdentityChain = defineAsyncComponent( | ||
() => import('./module/IdentityChain.vue') | ||
) | ||
const props = defineProps<{ | ||
address?: Address | ||
emit?: boolean | ||
showTwitter?: boolean | ||
showDiscord?: boolean | ||
showOnchainIdentity?: boolean | ||
hideIdentityPopover?: boolean | ||
customNameOption?: string | ||
}>() | ||
const { | ||
identity, | ||
isFetchingIdentity, | ||
shortenedAddress, | ||
twitter, | ||
discord, | ||
name, | ||
} = useIdentity({ | ||
address: props.address, | ||
customNameOption: props.customNameOption, | ||
}) | ||
provide('address', props.address) | ||
provide('shortenedAddress', shortenedAddress.value) | ||
provide( | ||
'identity', | ||
computed(() => identity.value) | ||
) | ||
const emit = defineEmits(['change']) | ||
watch(identity, () => { | ||
if (props.emit) { | ||
emit('change', identity.value) | ||
} | ||
}) | ||
</script> |
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,56 @@ | ||
<template v-else> | ||
<div> | ||
<span | ||
v-if="showOnchainIdentity" | ||
class="is-inline-flex is-align-items-center"> | ||
{{ shortenedAddress }} | ||
<img | ||
v-if="isFetchingIdentity" | ||
src="/infinity.svg" | ||
class="ml-1 infinity-loader" /> | ||
<template v-else> | ||
<span v-if="identity?.display" class="ml-1"> | ||
({{ identity?.display }}) | ||
</span> | ||
</template> | ||
</span> | ||
<template v-else-if="!hideIdentityPopover && !isMobileDevice"> | ||
<IdentityPopover v-if="address"> | ||
<template #trigger> | ||
{{ name }} | ||
</template> | ||
</IdentityPopover> | ||
</template> | ||
<span v-else> | ||
{{ name }} | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { GenericAccountId } from '@polkadot/types/generic/AccountId' | ||
import { isMobileDevice } from '@/utils/extension' | ||
type IdentityFields = Record<string, string> | ||
type Address = string | GenericAccountId | undefined | ||
const IdentityPopover = defineAsyncComponent( | ||
() => import('./IdentityPopover.vue') | ||
) | ||
defineProps<{ | ||
showOnchainIdentity?: boolean | ||
hideIdentityPopover?: boolean | ||
isFetchingIdentity?: boolean | ||
identity?: IdentityFields | ||
address?: Address | ||
shortenedAddress?: string | ||
name?: string | object | ||
}>() | ||
</script> | ||
|
||
<style scoped> | ||
.infinity-loader { | ||
height: 20px; | ||
} | ||
</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,44 @@ | ||
<template> | ||
<v-tippy | ||
class="tippy-container" | ||
interactive | ||
:animate-fill="false" | ||
placement="bottom" | ||
:delay="[100, 800]" | ||
data-cy="identity"> | ||
<template #trigger> | ||
<slot name="trigger" /> | ||
</template> | ||
<div class="popover-content-container p-4 ms-dos-shadow"> | ||
<IdentityPopoverHeader /> | ||
<hr style="height: 1px" class="m-0" /> | ||
<IdentityPopoverFooter /> | ||
</div> | ||
</v-tippy> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
const IdentityPopoverHeader = defineAsyncComponent( | ||
() => import('./IdentityPopoverHeader.vue') | ||
) | ||
const IdentityPopoverFooter = defineAsyncComponent( | ||
() => import('./IdentityPopoverFooter.vue') | ||
) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import '@/styles/abstracts/variables'; | ||
.tippy-container { | ||
display: inline-block; | ||
} | ||
.popover-content-container { | ||
border: 2px solid $primary; | ||
max-width: 350px; | ||
} | ||
.ms-dos-shadow { | ||
box-shadow: $dropdown-content-shadow; | ||
} | ||
</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
Oops, something went wrong.