@gisce/react-ooui 1.1.28 → 1.1.30
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/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/react-ooui.es.js +10 -15
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +13 -13
- package/dist/react-ooui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/iconMapper.test.ts +11 -0
- package/src/helpers/iconMapper.ts +4 -4
package/package.json
CHANGED
|
@@ -16,4 +16,15 @@ describe("A IconMapper instance", () => {
|
|
|
16
16
|
const icon = iconMapper("gtk-find-and-replace");
|
|
17
17
|
expect(icon).toBe(findAndReplaceIcon);
|
|
18
18
|
})
|
|
19
|
+
test("should return gtk-go", () => {
|
|
20
|
+
const findAndReplaceIcon = Icons.FileSearchOutlined;
|
|
21
|
+
const icon = iconMapper("gtk-find-and-replace");
|
|
22
|
+
expect(icon).toBe(findAndReplaceIcon);
|
|
23
|
+
})
|
|
24
|
+
describe("If key doesn't exist in iconMapper", () => {
|
|
25
|
+
test("should return undefined", () => {
|
|
26
|
+
const icon = iconMapper("gtk-foo-bar");
|
|
27
|
+
expect(icon).toBe(undefined);
|
|
28
|
+
})
|
|
29
|
+
})
|
|
19
30
|
});
|
|
@@ -103,8 +103,7 @@ const iconMapping: { [key: string]: string } = {
|
|
|
103
103
|
export default (key: string) => {
|
|
104
104
|
if (key.indexOf("gtk-") !== -1) {
|
|
105
105
|
const rootIcon = key.replace("gtk-", "").replace(/\-/g, "_");
|
|
106
|
-
|
|
107
|
-
return getIconForKey(iconMapping[newKey]);
|
|
106
|
+
key = `STOCK_${rootIcon.toUpperCase()}`;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
if (iconMapping.hasOwnProperty(key)) {
|
|
@@ -114,7 +113,7 @@ export default (key: string) => {
|
|
|
114
113
|
return getIconForKey(key);
|
|
115
114
|
};
|
|
116
115
|
|
|
117
|
-
function toCamelCase(key: string)
|
|
116
|
+
function toCamelCase(key: string): string {
|
|
118
117
|
return `${key
|
|
119
118
|
.split("-")
|
|
120
119
|
.map((word) =>
|
|
@@ -126,7 +125,8 @@ function toCamelCase(key: string) : string {
|
|
|
126
125
|
.join("")}`;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
function getIconForKey(
|
|
128
|
+
function getIconForKey(key: string) {
|
|
129
|
+
let IconCamelCase = key.charAt(0).toUpperCase() + key.slice(1); // Capitalize first letter
|
|
130
130
|
if (IconCamelCase.indexOf("-") !== -1) {
|
|
131
131
|
IconCamelCase = toCamelCase(IconCamelCase);
|
|
132
132
|
}
|