// Glass icons: a tinted back shape, the same shape blurred behind a frosted // front pane, a rim, and the detail strokes on top. The shapes are ours; every // colour comes from the stylesheet (tone classes and the --gi-* tokens), never // from a style attribute, which the page's CSP would drop. import { iconSvg } from '../../shared/icons'; import { markup } from '../dom'; export type Tone = 'grey' | 'blue' | 'green' | 'red' | 'orange'; interface Shape { /** The tinted back shape. */ b: string; /** The frosted front pane. */ f: string; /** Detail strokes on the pane; null: the AmneziaVPN mark instead. */ d: string | null; } const GL: Record = { phone: { b: '', f: '', d: '', }, mobile: { b: '', f: '', d: '', }, tablet: { b: '', f: '', d: '', }, computer: { b: '', f: '', d: '', }, router: { b: '', f: '', d: '', }, other: { b: '', f: '', d: '' }, plus: { b: '', f: '', d: '', }, globe: { b: '', f: '', d: '', }, home: { b: '', f: '', d: '', }, shield: { b: '', f: '', d: '', }, chart: { b: '', f: '', d: '', }, calendar: { b: '', f: '', d: '', }, clock: { b: '', f: '', d: '' }, pause: { b: '', f: '', d: '', }, server: { b: '', f: '', d: '', }, link: { b: '', f: '', d: '', }, key: { b: '', f: '', d: '', }, lock: { b: '', f: '', d: '', }, check: { b: '', f: '', d: '', }, trash: { b: '', f: '', d: '', }, refresh: { b: '', f: '', d: '', }, app: { b: '', f: '', d: null }, file: { b: '', f: '', d: '', }, lan: { b: '', f: '', d: '', }, }; /** The AmneziaVPN mark without its own svg: drawn on the "app" pane. */ const amneziaMark = () => iconSvg('amnezia', '') .replace(/^]*>/, '') .replace(/<\/svg>$/, ''); let gid = 0; /** A glass icon as markup (`cls`: its classes, e.g. "gi xl"). */ export function glassSvg(name: string, tone: Tone = 'grey', cls = 'gi'): string { const g = GL[name] ?? GL.other; const id = `gl${++gid}`; const detail = g.d === null ? `${amneziaMark()}` : `${g.d}`; return ( `` ); } /** A glass icon as an element. */ export const glass = (name: string, tone: Tone = 'grey', cls = 'gi'): Element => markup(glassSvg(name, tone, cls));