@arcblock/nft-display 2.5.61 → 2.5.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { NFTColor } from './color';
3
3
  export * from './color';
4
4
  export type NFTLayout = (data: string, width: any, height: any) => string;
5
5
  export type NFTVariant = LiteralUnion<'did-space' | 'app-space' | 'app-passport' | 'app-purchase', string>;
6
+ export type NFTTagVariant = LiteralUnion<'info' | 'success' | 'error' | 'warning', string>;
6
7
  export type NFTChain = LiteralUnion<'arcblock' | 'ethereum' | '', string>;
7
8
  export type NFTSubject = {
8
9
  name: string;
@@ -24,7 +25,8 @@ export type NFTProps = {
24
25
  extra: NFTExtra;
25
26
  verifiable?: boolean;
26
27
  chain?: NFTChain;
27
- revoked?: boolean;
28
+ tag?: string;
29
+ tagVariant?: NFTTagVariant;
28
30
  };
29
31
  export declare const formatDid: (did: string, length?: number) => string;
30
32
  export declare const getLayoutSvg: (variant: NFTVariant, id: string, color: NFTColor) => NFTLayout;
@@ -35,5 +37,5 @@ export declare const getDidSvg: (did: string, id: string, fontSize?: number) =>
35
37
  export declare const getVerifiableBadge: (id: string) => string;
36
38
  export declare const getChainBadge: (chain: NFTChain, only: boolean, id: string) => string;
37
39
  export declare const getBadgesSvg: (verifiable: boolean, chain: NFTChain, id: string) => string;
38
- export declare const getRevokedSvg: (revoked: boolean, id: string) => string;
40
+ export declare const getTagSvg: (tag: string, variant: NFTTagVariant, id: string) => string;
39
41
  export declare const getSvg: (props: NFTProps) => string;
package/lib/index.js CHANGED
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getSvg = exports.getRevokedSvg = exports.getBadgesSvg = exports.getChainBadge = exports.getVerifiableBadge = exports.getDidSvg = exports.getExtraSvg = exports.getIssuerSvg = exports.getHeaderSvg = exports.getLayoutSvg = exports.formatDid = void 0;
29
+ exports.getSvg = exports.getTagSvg = exports.getBadgesSvg = exports.getChainBadge = exports.getVerifiableBadge = exports.getDidSvg = exports.getExtraSvg = exports.getIssuerSvg = exports.getHeaderSvg = exports.getLayoutSvg = exports.formatDid = void 0;
30
30
  const nanoid_1 = require("nanoid");
31
31
  const DidMotif = __importStar(require("@arcblock/did-motif"));
32
32
  const color_1 = require("./color");
@@ -779,21 +779,27 @@ const getBadgesSvg = (verifiable, chain, id) => {
779
779
  return [verifiableBadge, chainBadge].filter(Boolean).join('');
780
780
  };
781
781
  exports.getBadgesSvg = getBadgesSvg;
782
- const getRevokedSvg = (revoked, id) => {
783
- if (revoked) {
784
- const filterId = getId(id, 'revoked-distort');
785
- return `<g id="${getId(id, 'revoked')}" transform="translate(112,-36) rotate(45)">
786
- <rect x="60" y="0" width="90" height="30" stroke="rgba(255,0,0,0.8)" stroke-width="2" />
782
+ const getTagSvg = (tag, variant, id) => {
783
+ const colors = {
784
+ success: '#34BE74',
785
+ error: '#F16E6E',
786
+ info: '#0775F8',
787
+ warning: '#DE9E37',
788
+ };
789
+ if (tag) {
790
+ const filterId = getId(id, 'tag-distort');
791
+ return `<g id="${getId(id, 'tag')}" transform="translate(112,-36) rotate(45)">
792
+ <rect x="60" y="0" width="95" height="30" stroke="${colors[variant]}" stroke-width="2" />
787
793
  <text
788
- x="64"
794
+ x="104"
789
795
  y="12"
790
- font-size="15"
796
+ font-size="14"
791
797
  font-weight="bold"
792
798
  font-family="Helvetica, Arial, sans-serif"
793
- fill="rgba(255,0,0,0.8)"
794
- text-anchor="start"
799
+ fill="${colors[variant]}"
800
+ text-anchor="middle"
795
801
  alignment-baseline="middle"
796
- dominant-baseline="middle" filter="url(#${filterId})">REVOKED</text>
802
+ dominant-baseline="middle" filter="url(#${filterId})">${tag.toUpperCase()}</text>
797
803
  <defs>
798
804
  <filter id="${filterId}">
799
805
  <feTurbulence baseFrequency="0.01 0.01" numOctaves="1" result="noise" />
@@ -804,7 +810,7 @@ const getRevokedSvg = (revoked, id) => {
804
810
  }
805
811
  return '';
806
812
  };
807
- exports.getRevokedSvg = getRevokedSvg;
813
+ exports.getTagSvg = getTagSvg;
808
814
  const getSvg = (props) => {
809
815
  const id = props.id || (0, nanoid_1.nanoid)(8);
810
816
  const width = props.width || DEFAULT_WIDTH;
@@ -816,7 +822,7 @@ const getSvg = (props) => {
816
822
  const extra = (0, exports.getExtraSvg)(props.extra, id);
817
823
  const badges = (0, exports.getBadgesSvg)(props.verifiable, props.chain, id);
818
824
  const identity = (0, exports.getDidSvg)(props.did, id);
819
- const revoked = (0, exports.getRevokedSvg)(props.revoked || false, id);
820
- return layout([header, issuer, extra, badges, identity, revoked].filter(Boolean).join(''), width, height);
825
+ const tag = (0, exports.getTagSvg)(props.tag, props.tagVariant, id);
826
+ return layout([header, issuer, extra, badges, identity, tag].filter(Boolean).join(''), width, height);
821
827
  };
822
828
  exports.getSvg = getSvg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/nft-display",
3
- "version": "2.5.61",
3
+ "version": "2.5.62",
4
4
  "description": "arcblock's nft display generic component",
5
5
  "keywords": [
6
6
  "nft"
@@ -42,5 +42,5 @@
42
42
  "ts-node": "^10.9.1",
43
43
  "typescript": "^5.0.4"
44
44
  },
45
- "gitHead": "382f83849428e3dff23540983b06a65f658ef1b2"
45
+ "gitHead": "c3067dee4e427fcedbe7e2d254159dd99606823c"
46
46
  }