1
>
/*---------------------------------------------------------------------------------------------
themables.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { Codicon } from './codicons.js';
7
>
8
>
export type ColorIdentifier = string;
9
>
10
>
export type IconIdentifier = string;
11
>
12
>
export interface ThemeColor {
13
>
id: string;
14
>
}
15
>
16
>
export namespace ThemeColor {
17
>
export function isThemeColor(obj: unknown): obj is ThemeColor {
18
return !!obj && typeof obj === 'object' && typeof (<ThemeColor>obj).id === 'string';
19
}
21
>
22
>
export function themeColorFromId(id: ColorIdentifier) {
23
return { id };
24
}
26
>
27
>
export interface ThemeIcon {
28
>
readonly id: string;
29
>
readonly color?: ThemeColor;
30
>
}
31
>
32
>
export namespace ThemeIcon {
33
>
export const iconNameSegment = '[A-Za-z0-9]+';
34
>
export const iconNameExpression = '[A-Za-z0-9-]+';
35
>
export const iconModifierExpression = '~[A-Za-z]+';
36
>
export const iconNameCharacter = '[A-Za-z0-9~-]';
37
>
38
>
const ThemeIconIdRegex = new RegExp(`^(${iconNameExpression})(${iconModifierExpression})?$`);
39
>
40
>
export function asClassNameArray(icon: ThemeIcon): string[] {
41
const match = ThemeIconIdRegex.exec(icon.id);
42
if (!match) {