Skip to content

Commit 36b1df4

Browse files
committed
Add icons for packages and elements
1 parent 676c483 commit 36b1df4

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
<!-- ### Removed -->
1818
<!-- ### Fixed -->
1919

20+
<!-- ## [x.y.z] - YYYY-MM-DD -->
21+
## Unreleased
22+
<!-- ### Changed -->
23+
### Added
24+
25+
- Added the `icons` field to `Package` and `CustomElement` to describe available
26+
icons for those objects.
27+
28+
<!-- ### Removed -->
29+
<!-- ### Fixed -->
30+
31+
2032
## [2.1.0] - 2024-05-16
2133

2234
### Added

schema.d.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export interface Package {
3636
*/
3737
readme?: string;
3838

39+
/**
40+
* The icons that represent this package.
41+
*/
42+
icons?: Array<Icon>;
43+
3944
/**
4045
* An array of the modules this package contains.
4146
*/
@@ -48,6 +53,75 @@ export interface Package {
4853
deprecated?: boolean | string;
4954
}
5055

56+
/**
57+
* Represents an icon for a Package or CustomElement to be used in a specific
58+
* context. For example, you can add icons to represent your elements in
59+
* different tools such as documentation viewers, catalogs, or IDEs.
60+
*
61+
* This interface follows the [Web App Manifest icons
62+
* member](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/icons).
63+
*/
64+
export interface Icon {
65+
/**
66+
* A string that specifies the path to the icon image file. The path is
67+
* relative to the package root. Icon files should be included in the
68+
* package.
69+
*/
70+
src: string;
71+
72+
/**
73+
* A string that specifies one or more sizes at which the icon file can be
74+
* used. Each size is specified as `<width in pixels>x<height in pixels>`. If
75+
* multiple sizes are specified, they are separated by spaces; for example,
76+
* `48x48 96x96`. When multiple icons are available, tools may select the
77+
* most suitable icon for a particular display context. For raster formats
78+
* like PNG, specifying the exact available sizes is recommended. For vector
79+
* formats like SVG, you can use any to indicate scalability. If `sizes` is
80+
* not specified, the selection and display of the icon may vary depending on
81+
* the tools's implementation.
82+
*/
83+
sizes?: string;
84+
85+
/**
86+
* A string that specifies the MIME type of the icon. The value should be in
87+
* the format image/<subtype>, where <subtype> is a specific image format; for
88+
* example, image/png indicates a PNG image. If omitted, tools typically
89+
* infer the image type from the file extension.
90+
*/
91+
type?: string;
92+
93+
/**
94+
* A case-sensitive keyword string that specifies one or more contexts in
95+
* which the icon can be used a tool. The value can be a single keyword or
96+
* multiple space-separated keywords. If omitted, the tool can use the icon
97+
* for any purpose.
98+
*
99+
* Tools use these values as hints to determine where and how an icon is
100+
* displayed. For example, a monochrome icon might be used as a badge or
101+
* pinned icon with a solid fill, which is visually distinct from a full-color
102+
* launch icon. With multiple keywords, say monochrome maskable, the tool
103+
* can use the icon for any of those purposes. If an unrecognized purpose is
104+
* included along with valid values (e.g., monochrome fizzbuzz), the icon can
105+
* still be used for the valid purposes. However, if only unrecognized
106+
* purposes are specified (e.g., fizzbuzz), then it will be ignored.
107+
*
108+
* Valid values include:
109+
*
110+
* - `monochrome` Indicates that the icon is intended to be used as a
111+
* monochrome icon with a solid fill. With this value, a browser discards
112+
* the color information in the icon and uses only the alpha channel as a
113+
* mask over any solid fill.
114+
*
115+
* - `maskable` Indicates that the icon is designed with icon masks and safe
116+
* zone in mind, such that any part of the image outside the safe zone can
117+
* be ignored and masked away.
118+
*
119+
* - `any` Indicates that the icon can be used in any context. This is the
120+
* default value.
121+
*/
122+
purpose?: string;
123+
}
124+
51125
// This type may expand in the future to include JSON, CSS, or HTML
52126
// modules.
53127
export type Module = JavaScriptModule;
@@ -231,6 +305,11 @@ export interface CustomElement extends ClassLike {
231305
*/
232306
tagName?: string;
233307

308+
/**
309+
* The icons that represent this element.
310+
*/
311+
icons?: Array<Icon>;
312+
234313
/**
235314
* The attributes that this element is known to understand.
236315
*/

schema.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@
372372
},
373373
"type": "array"
374374
},
375+
"icons": {
376+
"description": "The icons that represent this element.",
377+
"items": {
378+
"$ref": "#/definitions/Icon"
379+
},
380+
"type": "array"
381+
},
375382
"kind": {
376383
"enum": [
377384
"class"
@@ -522,6 +529,13 @@
522529
},
523530
"type": "array"
524531
},
532+
"icons": {
533+
"description": "The icons that represent this element.",
534+
"items": {
535+
"$ref": "#/definitions/Icon"
536+
},
537+
"type": "array"
538+
},
525539
"kind": {
526540
"enum": [
527541
"mixin"
@@ -714,6 +728,31 @@
714728
],
715729
"type": "object"
716730
},
731+
"Icon": {
732+
"description": "Represents an icon for a Package or CustomElement to be used in a specific\ncontext. For example, you can add icons to represent your elements in\ndifferent tools such as documentation viewers, catalogs, or IDEs.\n\nThis interface follows the [Web App Manifest icons\nmember](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/icons).",
733+
"properties": {
734+
"purpose": {
735+
"description": "A case-sensitive keyword string that specifies one or more contexts in\nwhich the icon can be used a tool. The value can be a single keyword or\nmultiple space-separated keywords. If omitted, the tool can use the icon\nfor any purpose.\n\nTools use these values as hints to determine where and how an icon is\ndisplayed. For example, a monochrome icon might be used as a badge or\npinned icon with a solid fill, which is visually distinct from a full-color\nlaunch icon. With multiple keywords, say monochrome maskable, the tool\ncan use the icon for any of those purposes. If an unrecognized purpose is\nincluded along with valid values (e.g., monochrome fizzbuzz), the icon can\nstill be used for the valid purposes. However, if only unrecognized\npurposes are specified (e.g., fizzbuzz), then it will be ignored.\n\nValid values include:\n\n- `monochrome` Indicates that the icon is intended to be used as a\n monochrome icon with a solid fill. With this value, a browser discards\n the color information in the icon and uses only the alpha channel as a\n mask over any solid fill.\n\n- `maskable` Indicates that the icon is designed with icon masks and safe\n zone in mind, such that any part of the image outside the safe zone can\n be ignored and masked away.\n\n- `any` Indicates that the icon can be used in any context. This is the\n default value.",
736+
"type": "string"
737+
},
738+
"sizes": {
739+
"description": "A string that specifies one or more sizes at which the icon file can be\nused. Each size is specified as `<width in pixels>x<height in pixels>`. If\nmultiple sizes are specified, they are separated by spaces; for example,\n`48x48 96x96`. When multiple icons are available, tools may select the\nmost suitable icon for a particular display context. For raster formats\nlike PNG, specifying the exact available sizes is recommended. For vector\nformats like SVG, you can use any to indicate scalability. If `sizes` is\nnot specified, the selection and display of the icon may vary depending on\nthe tools's implementation.",
740+
"type": "string"
741+
},
742+
"src": {
743+
"description": "A string that specifies the path to the icon image file. The path is\nrelative to the package root. Icon files should be included in the\npackage.",
744+
"type": "string"
745+
},
746+
"type": {
747+
"description": "A string that specifies the MIME type of the icon. The value should be in\nthe format image/<subtype>, where <subtype> is a specific image format; for\nexample, image/png indicates a PNG image. If omitted, tools typically\ninfer the image type from the file extension.",
748+
"type": "string"
749+
}
750+
},
751+
"required": [
752+
"src"
753+
],
754+
"type": "object"
755+
},
717756
"JavaScriptExport": {
718757
"properties": {
719758
"declaration": {
@@ -1114,6 +1153,13 @@
11141153
"boolean"
11151154
]
11161155
},
1156+
"icons": {
1157+
"description": "The icons that represent this package.",
1158+
"items": {
1159+
"$ref": "#/definitions/Icon"
1160+
},
1161+
"type": "array"
1162+
},
11171163
"modules": {
11181164
"description": "An array of the modules this package contains.",
11191165
"items": {

0 commit comments

Comments
 (0)