@sb1/ffe-symbols-react 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +2 -2
- package/scripts/fetchSymbolNames.js +18 -0
- package/scripts/generateSymbolTypings.js +29 -0
- package/src/index.d.ts +2 -1
- package/src/typings/symbolNames.ts +3299 -0
- package/types/index.d.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@2.0.4...@sb1/ffe-symbols-react@3.0.0) (2023-11-03)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **ffe-symbols-react:** legg til typings for symbol ([2a93040](https://github.com/SpareBank1/designsystem/commit/2a93040d0091b434335ced7080f6914916647b78))
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
- **ffe-symbols-react:** I forrige versjon som ble feilmarkert som minor.
|
|
15
|
+
Endringen innebærer at symbolnavn settes via ikon-prop og ikke children-prop.
|
|
16
|
+
|
|
6
17
|
## [2.0.4](https://github.com/SpareBank1/designsystem/compare/@sb1/ffe-symbols-react@2.0.3...@sb1/ffe-symbols-react@2.0.4) (2023-11-02)
|
|
7
18
|
|
|
8
19
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-symbols-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "React-komponenter for Material Symbols tilpasset Sb1 sine behov",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "1e12f8223e50e127b733fc99ef41a8b003bedafc"
|
|
39
39
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Fetches all the icon names by using the codepoints in the font */
|
|
2
|
+
const fetchSymbolNames = async () => {
|
|
3
|
+
let folderNames = [];
|
|
4
|
+
const url =
|
|
5
|
+
'https://raw.githubusercontent.com/google/material-design-icons/master/variablefont/MaterialSymbolsRounded%5BFILL%2CGRAD%2Copsz%2Cwght%5D.codepoints';
|
|
6
|
+
const response = await fetch(url);
|
|
7
|
+
const data = await response.text();
|
|
8
|
+
|
|
9
|
+
const lines = data.split('\n');
|
|
10
|
+
const names = lines
|
|
11
|
+
.filter(line => line.trim() !== '')
|
|
12
|
+
.map(line => `'${line.split(' ')[0]}'`);
|
|
13
|
+
folderNames = [...folderNames, ...names];
|
|
14
|
+
|
|
15
|
+
return folderNames;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = fetchSymbolNames;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This function is manually triggered, and will fetch all the names of the symbols.
|
|
3
|
+
The names are then gathered in an array that is used for typescript typings in the symbols component.
|
|
4
|
+
|
|
5
|
+
Important to only run this when we update the icon-font files, as we might sometimes be out of sync with whats
|
|
6
|
+
the latest in material icons.
|
|
7
|
+
*/
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs').promises;
|
|
10
|
+
const fetchSymbolNames = require('./fetchSymbolNames');
|
|
11
|
+
|
|
12
|
+
const writeToFile = async (filePath, content) => {
|
|
13
|
+
try {
|
|
14
|
+
await fs.writeFile(filePath, content);
|
|
15
|
+
console.log('File written successfully');
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Error writing file:', error);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const generateSymbolTypings = async () => {
|
|
22
|
+
const symbolNames = await fetchSymbolNames();
|
|
23
|
+
const fileContent = `export type SymbolName = ${symbolNames.join(' | ')}`;
|
|
24
|
+
const filePath = path.join(__dirname, '../src/typings/symbolNames.ts');
|
|
25
|
+
|
|
26
|
+
await writeToFile(filePath, fileContent);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
generateSymbolTypings();
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { SymbolName } from './typings/symbolNames.ts';
|
|
2
3
|
|
|
3
4
|
export interface SymbolProps {
|
|
4
5
|
fill?: boolean;
|
|
5
6
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
7
|
weight?: 300 | 400 | 500;
|
|
7
|
-
icon:
|
|
8
|
+
icon: SymbolName;
|
|
8
9
|
className?: string;
|
|
9
10
|
ariaLabel?: string;
|
|
10
11
|
}
|