sizeUtils.ts ×13

Frontier kind: Joint frontier

unlabeled · c_3fe946e3607f

8 tests · 7788 LOC · 37 files · introduces 1 test · 425 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges425 lines · 3 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1080 ranges7788 lines · 37 files · Browse complete extent
All tests (intent)
8 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationsizeUtils.ts ×1 · 9 introduced LOCsizeUtils.ts ×1sizeUtils.ts ×1 · 2 introduced LOCsizeUtils.ts ×1sizeUtils.ts ×2 · 4 introduced LOCsizeUtils.ts ×2sizeUtils.ts ×1 · 2 introduced LOCsizeUtils.ts ×1sizeUtils.ts ×1 · 2 introduced LOCsizeUtils.ts ×1async.ts ×1 · 3 introduced LOCasync.ts ×1async.ts ×3 · 4 introduced LOCasync.ts ×3async.ts ×1 · 5 introduced LOCasync.ts ×1async.ts ×202 · 1247 introduced LOCasync.ts ×202resources.ts ×23 · 253 introduced LOCresources.ts ×23network.ts ×20 · 292 introduced LOCnetwork.ts ×20strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…extpath.ts ×17 · 91 introduced LOCextpath.ts ×17strings.ts ×101 · 542 introduced LOCstrings.ts ×101jsonContributionRegistry.ts ×9 · 100 introduced LOCjsonContributionRegistry…event.ts ×1 · 1 introduced LOCevent.ts ×1event.ts ×5 · 10 introduced LOCevent.ts ×5cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…event.ts ×8 · 30 introduced LOCevent.ts ×8cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18lifecycle.ts ×2 · 3 introduced LOClifecycle.ts ×2event.ts ×3 · 4 introduced LOCevent.ts ×3event.ts ×1 · 1 introduced LOCevent.ts ×1event.ts ×4 · 9 introduced LOCevent.ts ×4event.ts ×2 · 4 introduced LOCevent.ts ×2lifecycle.ts ×2 · 6 introduced LOClifecycle.ts ×2event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93platform.ts ×1 · 2 introduced LOCplatform.ts ×1platform.ts ×1 · 6 introduced LOCplatform.ts ×1types.test|title=Types isString|occurrence=1 · 0 introduced LOCtypes.test|title=Types i…uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13nls.ts ×6 · 13 introduced LOCnls.ts ×6platform.ts ×5 · 46 introduced LOCplatform.ts ×5types.ts ×1 · 2 introduced LOCtypes.ts ×1jsonSchema.ts ×3 · 194 introduced LOCjsonSchema.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2types.ts ×1 · 2 introduced LOCtypes.ts ×1assert.ts ×2 · 2 introduced LOCassert.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1lifecycle.ts ×3 · 9 introduced LOClifecycle.ts ×3types.ts ×2 · 5 introduced LOCtypes.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1types.ts ×1 · 2 introduced LOCtypes.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×2 · 2 introduced LOClifecycle.ts ×2lazy.ts ×1 · 2 introduced LOClazy.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/async.ts · 2749 LOCcommon/async.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/extpath.ts · 433 LOCcommon/extpath.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/jsonSchema.ts · 330 LOCcommon/jsonSchema.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/network.ts · 440 LOCcommon/network.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/resources.ts · 444 LOCcommon/resources.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/symbols.ts · 9 LOCcommon/symbols.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/jsonschemas/common/jsonContributionRegistry.ts · 143 LOCcommon/jsonContributionR…src/vs/platform/registry/common/platform.ts · 63 LOCcommon/platform.tssrc/vs/platform/theme/common/sizeRegistry.ts · 9 LOCcommon/sizeRegistry.tssrc/vs/platform/theme/common/sizeUtils.ts · 285 LOCcommon/sizeUtils.tssrc/vs/platform/theme/common/sizes/baseSizes.ts · 181 LOCsizes/baseSizes.tscancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…types.test|title=Types isString|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/types.test|title=Types isString|occurrence=1types.test|title=Types i…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…sizeRegistry.test|title=Size Registry asCssVariable should create CSS variable reference|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry asCssVariable should create CSS variable reference|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry asCssVariableName should convert identifier to CSS variable name|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry asCssVariableName should convert identifier to CSS variable name|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry deregisterSize should remove a size token|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry deregisterSize should remove a size token|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry registerSize should register a size token|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry registerSize should register a size token|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry registerSize should work with sizeForAllThemes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry registerSize should work with sizeForAllThemes|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry size tokens should be available|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry size tokens should be available|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry sizeForAllThemes should create same value for all themes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry sizeForAllThemes should create same value for all themes|occurrence=1sizeRegistry.test|title=…sizeRegistry.test|title=Size Registry sizeValueToCss should convert size value to CSS string|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/theme/test/common/sizeRegistry.test|title=Size Registry sizeValueToCss should convert size value to CSS string|occurrence=1sizeRegistry.test|title=…Focused concept · sizeUtils.ts ×13 · 425 introduced LOCsizeUtils.ts ×13

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 425 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/theme/common/sizeUtils.ts 235 introduced LOC · 13 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- sizeUtils.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 { Emitter, Event } from '../../../base/common/event.js';
7 > import { IJSONSchema } from '../../../base/common/jsonSchema.js';
8 > import { IJSONContributionRegistry, Extensions as JSONExtensions } from '../../jsonschemas/common/jsonContributionRegistry.js';
9 > import * as platform from '../../registry/common/platform.js';
10 > import { IColorTheme } from './themeService.js';
11 > import { Disposable } from '../../../base/common/lifecycle.js';
12 > import { RunOnceScheduler } from '../../../base/common/async.js';
13 >
14 > // ------ API types
15 >
16 > export type SizeIdentifier = string;
17 >
18 > /**
19 > * Size value unit types supported by the registry.
20 > * Use `''` for unitless values such as font weights.
21 > */
22 > export type SizeUnit = 'px' | 'rem' | 'em' | '%' | '';
23 >
24 > /**
25 > * A size value with a numeric amount and unit
26 > */
27 > export interface SizeValue {
28 > readonly value: number;
29 > readonly unit: SizeUnit;
30 > }
31 >
32 > export interface SizeContribution {
33 > readonly id: SizeIdentifier;
34 > readonly description: string;
35 > readonly defaults: SizeDefaults | SizeValue | null;
36 > readonly deprecationMessage: string | undefined;
37 > }
38 >
39 > /**
40 > * Returns the css variable name for the given size identifier. Dots (`.`) are replaced with hyphens (`-`) and
41 > * everything is prefixed with `--vscode-`.
42 > *
43 > * @sample `editor.fontSize` is `--vscode-editor-fontSize`.
44 > */
45 > export function asCssVariableName(sizeIdent: SizeIdentifier): string {
46 return `--vscode-${sizeIdent.replace(/\./g, '-')}`;
47 }
49 > export function asCssVariable(size: SizeIdentifier): string {
50 return `var(${asCssVariableName(size)})`;
51 }
53 > export function asCssVariableWithDefault(size: SizeIdentifier, defaultCssValue: string): string {
54 return `var(${asCssVariableName(size)}, ${defaultCssValue})`;
55 }
57 > export interface SizeDefaults {
58 > light: SizeValue | null;
59 > dark: SizeValue | null;
60 > hcDark: SizeValue | null;
61 > hcLight: SizeValue | null;
62 > }
63 >
64 > export function isSizeDefaults(value: unknown): value is SizeDefaults {
65 > return value !== null && typeof value === 'object' && 'light' in value && 'dark' in value;
66 > }
67 >
68 > /**
69 > * Helper function to create a size value
70 > */
71 > export function size(value: number, unit: SizeUnit = 'px'): SizeValue {
72 > return { value, unit };
73 > }
74 >
75 > /**
76 > * Helper function to create size defaults that use the same value for all themes
77 > */
78 > export function sizeForAllThemes(value: number, unit: SizeUnit = 'px'): SizeDefaults {
79 > const sizeValue = size(value, unit);
80 > return {
81 > light: sizeValue,
82 > dark: sizeValue,
83 > hcDark: sizeValue,
84 > hcLight: sizeValue
85 > };
86 > }
87 >
88 > /**
89 > * Convert a size value to a CSS string.
90 > * When the unit is `''` the raw numeric value is returned (e.g. font weights).
91 > */
92 > export function sizeValueToCss(sizeValue: SizeValue): string {
93 return sizeValue.unit === '' ? `${sizeValue.value}` : `${sizeValue.value}${sizeValue.unit}`;
94 }
96 > // size registry
97 > export const Extensions = {
98 > SizeContribution: 'base.contributions.sizes'
99 > };
100 >
101 > export const DEFAULT_SIZE_CONFIG_VALUE = 'default';
102 >
103 > export interface ISizeRegistry {
104 >
105 > readonly onDidChangeSchema: Event<void>;
106 >
107 > /**
108 > * Register a size to the registry.
109 > * @param id The size id as used in theme description files
110 > * @param defaults The default values
111 > * @param description the description
112 > */
113 > registerSize(id: string, defaults: SizeDefaults | SizeValue | null, description: string): SizeIdentifier;
114 >
115 > /**
116 > * Deregister a size from the registry.
117 > */
118 > deregisterSize(id: string): void;
119 >
120 > /**
121 > * Get all size contributions
122 > */
123 > getSizes(): SizeContribution[];
124 >
125 > /**
126 > * Gets the default size of the given id
127 > */
128 > resolveDefaultSize(id: SizeIdentifier, theme: IColorTheme): SizeValue | undefined;
129 >
130 > /**
131 > * JSON schema for an object to assign size values to one of the size contributions.
132 > */
133 > getSizeSchema(): IJSONSchema;
134 >
135 > /**
136 > * JSON schema for a reference to a size contribution.
137 > */
138 > getSizeReferenceSchema(): IJSONSchema;
139 >
140 > /**
141 > * Notify when the color theme or settings change.
142 > */
143 > notifyThemeUpdate(theme: IColorTheme): void;
144 >
145 > }
146 >
147 > type IJSONSchemaForSizes = IJSONSchema & { properties: { [name: string]: IJSONSchema } };
148 >
149 > class SizeRegistry extends Disposable implements ISizeRegistry {
150 >
151 > private readonly _onDidChangeSchema = this._register(new Emitter<void>());
152 > readonly onDidChangeSchema: Event<void> = this._onDidChangeSchema.event;
153 >
154 > private sizesById: { [key: string]: SizeContribution };
155 > private sizeSchema: IJSONSchemaForSizes = { type: 'object', properties: {} };
156 > private sizeReferenceSchema: IJSONSchema & { enum: string[]; enumDescriptions: string[] } = { type: 'string', enum: [], enumDescriptions: [] };
157 >
158 > constructor() {
159 > super();
160 > this.sizesById = {};
161 > }
162 >
163 > public notifyThemeUpdate(theme: IColorTheme) {
164 for (const key of Object.keys(this.sizesById)) {
165 const sizeVal = this.resolveDefaultSize(key, theme);
170 this._onDidChangeSchema.fire();
171 }
172 > sizeUtils.ts
173 > public registerSize(id: string, defaults: SizeDefaults | SizeValue | null, description: string, deprecationMessage?: string): SizeIdentifier {
174 > const sizeContribution: SizeContribution = { id, description, defaults, deprecationMessage };
175 > this.sizesById[id] = sizeContribution;
176 >
177 > // Determine whether this token uses unitless values (e.g. font weights).
178 > // The pattern is chosen per-token so that length tokens still require a unit.
179 > const isUnitless = (() => {
180 > if (!defaults) { return false; }
181 > if (isSizeDefaults(defaults)) {
182 > const sample = defaults.dark ?? defaults.light ?? defaults.hcDark ?? defaults.hcLight;
183 > return sample?.unit === '';
184 > }
185 return defaults.unit === '';
186 > })(); sizeUtils.ts
187 >
188 > const propertySchema: IJSONSchema = isUnitless
189 > ? {
190 > type: 'string',
191 > pattern: '^(?:\\d+|default)$',
192 > patternErrorMessage: 'Value must be an integer (e.g., "400") or "default"'
193 > }
194 > : {
195 > type: 'string',
196 > pattern: '^(?:\\d+(\\.\\d+)?(px|rem|em|%)|default)$',
197 > patternErrorMessage: 'Size must be a number followed by px, rem, em, or % (e.g., "12px", "1.5rem") or "default"'
198 > };
199 >
200 > if (deprecationMessage) {
201 > propertySchema.deprecationMessage = deprecationMessage;
202 > }
203 >
204 > this.sizeSchema.properties[id] = {
205 > description,
206 > ...propertySchema
207 > };
208 >
209 > this.sizeReferenceSchema.enum.push(id);
210 > this.sizeReferenceSchema.enumDescriptions.push(description);
211 >
212 > this._onDidChangeSchema.fire();
213 > return id;
214 > }
215 >
216 > public deregisterSize(id: string): void {
217 delete this.sizesById[id];
218 delete this.sizeSchema.properties[id];
224 this._onDidChangeSchema.fire();
225 }
226 > sizeUtils.ts
227 > public getSizes(): SizeContribution[] {
228 return Object.keys(this.sizesById).map(id => this.sizesById[id]);
229 }
230 > sizeUtils.ts
231 > public resolveDefaultSize(id: SizeIdentifier, theme: IColorTheme): SizeValue | undefined {
232 const sizeDesc = this.sizesById[id];
233 if (sizeDesc?.defaults) {
237 return undefined;
238 }
239 > sizeUtils.ts
240 > public getSizeSchema(): IJSONSchema {
241 > return this.sizeSchema;
242 > }
243 >
244 > public getSizeReferenceSchema(): IJSONSchema {
245 return this.sizeReferenceSchema;
246 }
247 > sizeUtils.ts
248 > public override toString() {
249 const sorter = (a: string, b: string) => {
250 const cat1 = a.indexOf('.') === -1 ? 0 : 1;
258 return Object.keys(this.sizesById).sort(sorter).map(k => `- \`${k}\`: ${this.sizesById[k].description}`).join('\n');
259 }
260 > sizeUtils.ts
261 > }
262 >
263 > const sizeRegistry = new SizeRegistry();
264 > platform.Registry.add(Extensions.SizeContribution, sizeRegistry);
265 >
266 > export function registerSize(id: string, defaults: SizeDefaults | SizeValue | null, description: string, deprecationMessage?: string): SizeIdentifier {
267 > return sizeRegistry.registerSize(id, defaults, description, deprecationMessage);
268 > }
269 >
270 > export function getSizeRegistry(): ISizeRegistry {
271 return sizeRegistry;
272 }
273 > sizeUtils.ts
274 > export const workbenchSizesSchemaId = 'vscode://schemas/workbench-sizes';
275 >
276 > const schemaRegistry = platform.Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
277 > schemaRegistry.registerSchema(workbenchSizesSchemaId, sizeRegistry.getSizeSchema());
278 >
279 > const delayer = new RunOnceScheduler(() => schemaRegistry.notifySchemaChanged(workbenchSizesSchemaId), 200);
280 >
281 > sizeRegistry.onDidChangeSchema(() => {
282 > if (!delayer.isScheduled()) {
283 > delayer.schedule();
284 > }
285 > });
src/vs/platform/theme/common/sizes/baseSizes.ts 181 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- baseSizes.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 * as nls from '../../../../nls.js';
7 > import { registerSize, sizeForAllThemes } from '../sizeUtils.js';
8 >
9 > // ------ Font Sizes
10 >
11 > /** @deprecated Use {@link fontSizeBody1} instead. */
12 > export const bodyFontSize = registerSize('bodyFontSize',
13 > sizeForAllThemes(13, 'px'),
14 > nls.localize('bodyFontSize', "Base font size. This size is used if not overridden by a component."),
15 > nls.localize('bodyFontSize.deprecated', "Deprecated: use `fontSize.body1` instead."));
16 >
17 > /** @deprecated Use {@link fontSizeLabel1} instead. */
18 > export const bodyFontSizeSmall = registerSize('bodyFontSize.small',
19 > sizeForAllThemes(12, 'px'),
20 > nls.localize('bodyFontSizeSmall', "Small font size for secondary content."),
21 > nls.localize('bodyFontSizeSmall.deprecated', "Deprecated: use `fontSize.label1` instead."));
22 >
23 > /** @deprecated Use {@link fontSizeBody2} instead. */
24 > export const bodyFontSizeXSmall = registerSize('bodyFontSize.xSmall',
25 > sizeForAllThemes(11, 'px'),
26 > nls.localize('bodyFontSizeXSmall', "Extra small font size for less prominent content."),
27 > nls.localize('bodyFontSizeXSmall.deprecated', "Deprecated: use `fontSize.body2` instead."));
28 >
29 > // ------ Font ramp
30 > //
31 > // A generic font-size ramp (headings, body and labels) mirroring the agents
32 > // window ramp. "Strong" variants are NOT separate size tokens: reuse the
33 > // matching size token paired with `fontWeight.semiBold` (600). Regular text
34 > // pairs with `fontWeight.regular` (400).
35 >
36 > export const fontSizeHeading1 = registerSize('fontSize.heading1',
37 > sizeForAllThemes(26, 'px'),
38 > nls.localize('fontSizeHeading1', "Heading 1 font size (largest heading)."));
39 >
40 > export const fontSizeHeading2 = registerSize('fontSize.heading2',
41 > sizeForAllThemes(18, 'px'),
42 > nls.localize('fontSizeHeading2', "Heading 2 font size (title)."));
43 >
44 > export const fontSizeHeading3 = registerSize('fontSize.heading3',
45 > sizeForAllThemes(13, 'px'),
46 > nls.localize('fontSizeHeading3', "Heading 3 font size (subtitle)."));
47 >
48 > export const fontSizeBody1 = registerSize('fontSize.body1',
49 > sizeForAllThemes(13, 'px'),
50 > nls.localize('fontSizeBody1', "Primary body font size."));
51 >
52 > export const fontSizeBody2 = registerSize('fontSize.body2',
53 > sizeForAllThemes(11, 'px'),
54 > nls.localize('fontSizeBody2', "Secondary body font size."));
55 >
56 > export const fontSizeLabel1 = registerSize('fontSize.label1',
57 > sizeForAllThemes(12, 'px'),
58 > nls.localize('fontSizeLabel1', "Label 1 font size (section title, tabs)."));
59 >
60 > export const fontSizeLabel2 = registerSize('fontSize.label2',
61 > sizeForAllThemes(11, 'px'),
62 > nls.localize('fontSizeLabel2', "Label 2 font size (metadata)."));
63 >
64 > export const fontSizeLabel3 = registerSize('fontSize.label3',
65 > sizeForAllThemes(10, 'px'),
66 > nls.localize('fontSizeLabel3', "Label 3 font size (badge)."));
67 >
68 > // ------ Font weights
69 > //
70 > // A two-weight ramp (regular/semiBold). "Strong" emphasis reuses the matching
71 > // font-size token paired with `fontWeight.semiBold`.
72 >
73 > export const fontWeightRegular = registerSize('fontWeight.regular',
74 > sizeForAllThemes(400, ''),
75 > nls.localize('fontWeightRegular', "Regular font weight (400) for body, labels and metadata."));
76 >
77 > export const fontWeightSemiBold = registerSize('fontWeight.semiBold',
78 > sizeForAllThemes(600, ''),
79 > nls.localize('fontWeightSemiBold', "SemiBold font weight (600) for headings and strong emphasis."));
80 >
81 > export const codiconFontSize = registerSize('codiconFontSize',
82 > sizeForAllThemes(16, 'px'),
83 > nls.localize('codiconFontSize', "Base font size for codicons."));
84 >
85 > export const codiconFontSizeCompact = registerSize('codiconFontSize.compact',
86 > sizeForAllThemes(12, 'px'),
87 > nls.localize('codiconFontSizeCompact', "Compact font size for codicons."));
88 >
89 > // ------ Corner Radii
90 >
91 > export const cornerRadiusMedium = registerSize('cornerRadius.medium',
92 > sizeForAllThemes(6, 'px'),
93 > nls.localize('cornerRadiusMedium', "Base corner radius for UI elements."));
94 >
95 > export const cornerRadiusXSmall = registerSize('cornerRadius.xSmall',
96 > sizeForAllThemes(2, 'px'),
97 > nls.localize('cornerRadiusXSmall', "Extra small corner radius for very compact UI elements."));
98 >
99 > export const cornerRadiusSmall = registerSize('cornerRadius.small',
100 > sizeForAllThemes(4, 'px'),
101 > nls.localize('cornerRadiusSmall', "Small corner radius for compact UI elements."));
102 >
103 > export const cornerRadiusLarge = registerSize('cornerRadius.large',
104 > sizeForAllThemes(8, 'px'),
105 > nls.localize('cornerRadiusLarge', "Large corner radius for prominent UI elements."));
106 >
107 > export const cornerRadiusXLarge = registerSize('cornerRadius.xLarge',
108 > sizeForAllThemes(12, 'px'),
109 > nls.localize('cornerRadiusXLarge', "Extra large corner radius for very prominent UI elements."));
110 >
111 > export const cornerRadiusCircle = registerSize('cornerRadius.circle',
112 > sizeForAllThemes(9999, 'px'),
113 > nls.localize('cornerRadiusCircle', "Circular corner radius for fully rounded UI elements."));
114 >
115 > // ------ Stroke Thickness
116 >
117 > export const strokeThickness = registerSize('strokeThickness',
118 > sizeForAllThemes(1, 'px'),
119 > nls.localize('strokeThickness', "Base stroke thickness for borders and outlines."));
120 >
121 > // ------ Spacing ramp
122 > //
123 > // A fixed ramp of spacing tokens used for padding, margins and gaps. Numeric tokens
124 > // encode the value in tenths of a pixel (e.g. `size200` is 20px). `sizeNone`
125 > // represents 0px, matching the design system's spacing ramp.
126 >
127 > export const spacingNone = registerSize('spacing.sizeNone',
128 > sizeForAllThemes(0, 'px'),
129 > nls.localize('spacingNone', "No spacing (0px)."));
130 >
131 > export const spacingSize20 = registerSize('spacing.size20',
132 > sizeForAllThemes(2, 'px'),
133 > nls.localize('spacingSize20', "Spacing of 2px."));
134 >
135 > export const spacingSize40 = registerSize('spacing.size40',
136 > sizeForAllThemes(4, 'px'),
137 > nls.localize('spacingSize40', "Spacing of 4px."));
138 >
139 > export const spacingSize60 = registerSize('spacing.size60',
140 > sizeForAllThemes(6, 'px'),
141 > nls.localize('spacingSize60', "Spacing of 6px."));
142 >
143 > export const spacingSize80 = registerSize('spacing.size80',
144 > sizeForAllThemes(8, 'px'),
145 > nls.localize('spacingSize80', "Spacing of 8px."));
146 >
147 > export const spacingSize100 = registerSize('spacing.size100',
148 > sizeForAllThemes(10, 'px'),
149 > nls.localize('spacingSize100', "Spacing of 10px."));
150 >
151 > export const spacingSize120 = registerSize('spacing.size120',
152 > sizeForAllThemes(12, 'px'),
153 > nls.localize('spacingSize120', "Spacing of 12px."));
154 >
155 > export const spacingSize160 = registerSize('spacing.size160',
156 > sizeForAllThemes(16, 'px'),
157 > nls.localize('spacingSize160', "Spacing of 16px."));
158 >
159 > export const spacingSize200 = registerSize('spacing.size200',
160 > sizeForAllThemes(20, 'px'),
161 > nls.localize('spacingSize200', "Spacing of 20px."));
162 >
163 > export const spacingSize240 = registerSize('spacing.size240',
164 > sizeForAllThemes(24, 'px'),
165 > nls.localize('spacingSize240', "Spacing of 24px."));
166 >
167 > export const spacingSize280 = registerSize('spacing.size280',
168 > sizeForAllThemes(28, 'px'),
169 > nls.localize('spacingSize280', "Spacing of 28px."));
170 >
171 > export const spacingSize320 = registerSize('spacing.size320',
172 > sizeForAllThemes(32, 'px'),
173 > nls.localize('spacingSize320', "Spacing of 32px."));
174 >
175 > export const spacingSize360 = registerSize('spacing.size360',
176 > sizeForAllThemes(36, 'px'),
177 > nls.localize('spacingSize360', "Spacing of 36px."));
178 >
179 > export const spacingSize400 = registerSize('spacing.size400',
180 > sizeForAllThemes(40, 'px'),
181 > nls.localize('spacingSize400', "Spacing of 40px."));
src/vs/platform/theme/common/sizeRegistry.ts 9 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- sizeRegistry.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 > export * from './sizeUtils.js';
7 >
8 > // Make sure all size files are exported
9 > export * from './sizes/baseSizes.js';