Skip to content

Commit 55c6c2b

Browse files
committed
Merge remote-tracking branch 'origin/feature-7.3.0' into icon-binocs
2 parents 23fa865 + f946a3e commit 55c6c2b

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@
7474
"license": "MIT",
7575
"sideEffects": [
7676
"icons/imports/"
77-
]
77+
],
78+
"web-types": "dist/ionic.web-types.json"
7879
}

scripts/build.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ async function build(rootDir: string) {
3131

3232
await createCheatsheet(version, rootDir, distDir, svgSymbolsContent, srcSvgData);
3333

34+
await createWebTypes(version, rootDir, distDir, srcSvgData);
35+
3436
await copyToTesting(rootDir, distDir, srcSvgData);
3537
} catch (e) {
3638
console.error(e);
@@ -273,6 +275,31 @@ async function createCheatsheet(
273275
await fs.writeFile(distCheatsheetFilePath, html);
274276
}
275277

278+
async function createWebTypes(
279+
version: string,
280+
rootDir: string,
281+
distDir: any,
282+
srcSvgData: SvgData[]
283+
) {
284+
const srcWebTypeFilePath = join(rootDir, 'src/ionicons.web-types.json');
285+
const distWebTypesFilePath = join(distDir, 'ionicons.web-types.json');
286+
287+
const webTypes = JSON.parse(await fs.readFile(srcWebTypeFilePath, 'utf8'))
288+
289+
webTypes.version = version
290+
291+
const icons = webTypes.contributions.html.ionicons
292+
for (let data of srcSvgData) {
293+
icons.push({
294+
name: data.iconName,
295+
icon: "dist/svg/" + data.fileName
296+
})
297+
}
298+
299+
const jsonStr = JSON.stringify(webTypes, null, 2) + '\n';
300+
await fs.writeFile(distWebTypesFilePath, jsonStr);
301+
}
302+
276303
async function getSvgs(srcSvgDir: string, distSvgDir: string, distIoniconsDir: string): Promise<SvgData[]> {
277304
const optimizedSvgDir = join(distIoniconsDir, 'svg');
278305
await fs.emptyDir(optimizedSvgDir);

src/ionicons.web-types.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"$schema": "http://json.schemastore.org/web-types",
3+
"name": "ionicons",
4+
"version": "0.0.0",
5+
"description-markup": "markdown",
6+
"contributions": {
7+
"html": {
8+
"elements": [
9+
{
10+
"name": "ion-icon",
11+
"description": "The Ionicons Web Component is an easy and performant way to use Ionicons in your app. The component will dynamically load an SVG for each icon, so your app is only requesting the icons that you need.",
12+
"doc-url": "https://ionic.io/ionicons/usage",
13+
"attributes": [
14+
{
15+
"name": "name",
16+
"description": "The name of the built-in icon from the Ionicons package.",
17+
"priority": "high",
18+
"doc-url": "https://ionic.io/ionicons/usage#basic-usage",
19+
"value": {
20+
"type": "symbol"
21+
},
22+
"values": [
23+
{
24+
"name": "The ion-icon",
25+
"pattern": {
26+
"items": "ionicons"
27+
}
28+
}
29+
]
30+
},
31+
{
32+
"name": "src",
33+
"priority": "high",
34+
"description": "Provide url of a custom SVG icon. The `src` attribute works the same as `<img src=\"...\">` in that the url must be accessible from the webpage that's making a request for the image. Additionally, the external file can only be a valid `svg` and does not allow scripts or events within the `svg` element.",
35+
"doc-url": "https://ionic.io/ionicons/usage#basic-usage"
36+
},
37+
{
38+
"name": "md",
39+
"description": "Provide icon variant specific to MD platform",
40+
"priority": "high",
41+
"doc-url": "https://ionic.io/ionicons/usage#basic-usage",
42+
"value": {
43+
"type": "symbol"
44+
},
45+
"values": [
46+
{
47+
"name": "The ion-icon",
48+
"pattern": {
49+
"items": "ionicons"
50+
}
51+
}
52+
]
53+
},
54+
{
55+
"name": "ios",
56+
"description": "Provide icon variant specific to iOS platform",
57+
"priority": "high",
58+
"doc-url": "https://ionic.io/ionicons/usage#basic-usage",
59+
"value": {
60+
"type": "symbol"
61+
},
62+
"values": [
63+
{
64+
"name": "The ion-icon",
65+
"pattern": {
66+
"items": "ionicons"
67+
}
68+
}
69+
]
70+
},
71+
{
72+
"name": "size",
73+
"description": "Specify the icon size using one of the pre-defined font sizes.\n\nAlternatively you can set a specific size by applying the `font-size` CSS property on the `ion-icon` component. It's recommended to use pixel sizes that are a multiple of 8 (8, 16, 32, 64, etc.)",
74+
"doc-url": "https://ionic.io/ionicons/usage#basic-usage",
75+
"priority": "high",
76+
"value": {
77+
"type": "enum"
78+
},
79+
"values": [
80+
{
81+
"name": "small"
82+
},
83+
{
84+
"name": "large"
85+
}
86+
]
87+
}
88+
]
89+
}
90+
],
91+
"ionicons": [
92+
]
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)