mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 12:11:04 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
// Copyright 2017-2021 @polkadot/vue-identicon authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { polkadotIcon } from '@polkadot/ui-shared';
|
|
|
|
interface Data {
|
|
svgHtml: string;
|
|
}
|
|
|
|
interface This {
|
|
address: string;
|
|
isAlternative?: boolean;
|
|
}
|
|
|
|
/**
|
|
* @name Polkadot
|
|
* @description The Polkadot default identicon
|
|
*/
|
|
export const Polkadot = Vue.extend({
|
|
created: function (): void {
|
|
this.createSvgHtml();
|
|
},
|
|
data: function (): Data {
|
|
return {
|
|
// eslint-disable-next-line quotes
|
|
svgHtml: `<svg viewBox="0 0 64 64" />`
|
|
};
|
|
},
|
|
methods: {
|
|
createSvgHtml: function (): void {
|
|
const circles = polkadotIcon(this.address, { isAlternative: (this as This).isAlternative || false }).map(({ cx, cy, fill, r }) =>
|
|
`<circle cx=${cx} cy=${cy} fill="${fill}" r=${r} />`
|
|
).join('');
|
|
|
|
this.svgHtml = `<svg height=${this.size as number} viewBox='0 0 64 64' width=${this.size as number}>${circles}</svg>`;
|
|
}
|
|
},
|
|
props: ['address', 'isAlternative', 'size'],
|
|
// eslint-disable-next-line quotes
|
|
template: `<div v-html="svgHtml" />`
|
|
});
|