PluginProbe
Code Snippets / 3.10.2
Code Snippets v3.10.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / Badge.tsx

Badge.tsx in Code Snippets 3.10.2, at js/components/common/Badge.tsx

29 lines 860 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import classnames from 'classnames'
3 import type { ReactNode } from 'react'
4 import type { SnippetType } from '../../types/Snippet'
5
6 export type BadgeName = SnippetType | 'core' | 'pro' | 'ai' | 'cloud' | 'bundles' | 'cloud_search' | 'beta'
7
8 const badgeIcons: Partial<Record<BadgeName, string>> = {
9 cond: 'randomize',
10 cloud: 'cloud',
11 bundles: 'screenoptions',
12 cloud_search: 'search'
13 }
14
15 export interface BadgeProps {
16 name: BadgeName
17 small?: boolean
18 inverted?: boolean
19 children?: ReactNode
20 }
21
22 export const Badge: React.FC<BadgeProps> = ({ name, small, inverted, children }) =>
23 <span className={classnames('badge', `${name}-badge`, { 'small-badge': small, 'inverted-badge': inverted })}>
24 {badgeIcons[name]
25 ? <span className={`dashicons dashicons-${badgeIcons[name]}`} aria-hidden="true" />
26 : children ?? name
27 }
28 </span>
29