@gisce/react-ooui 0.20.1 → 0.21.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/dist/helpers/iconMapper.d.ts +1 -0
- package/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/helpers/iconMapper.js +13 -3
- package/dist/helpers/iconMapper.js.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -1
- package/src/helpers/iconMapper.ts +13 -7
- package/src/stories/Button.stories.tsx +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@gisce/ooui": "^0.16.1",
|
|
28
28
|
"@gisce/react-formiga-table": "^0.5.0",
|
|
29
29
|
"@monaco-editor/react": "^4.4.5",
|
|
30
|
+
"@tabler/icons": "^1.95.1",
|
|
30
31
|
"fiber-diagram": "github:gisce/fiber-diagram",
|
|
31
32
|
"file-type": "^16.5.0",
|
|
32
33
|
"react-grid-layout": "^1.3.4",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import * as Icons from "@ant-design/icons";
|
|
1
|
+
import Icon, * as Icons from "@ant-design/icons";
|
|
2
|
+
import * as TablerIcons from "@tabler/icons";
|
|
3
|
+
import React from "react";
|
|
2
4
|
|
|
3
5
|
const iconMapping: { [key: string]: React.ElementType } = {
|
|
4
6
|
STOCK_HELP: Icons.QuestionOutlined,
|
|
@@ -96,13 +98,17 @@ export default (key: string): React.ElementType => {
|
|
|
96
98
|
}
|
|
97
99
|
if (iconMapping.hasOwnProperty(key)) {
|
|
98
100
|
return iconMapping[key];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
}
|
|
102
|
+
const IconCamelCase = `${key.split("-").map((word) => (
|
|
103
|
+
word.replace(/\w\S*/g, (w) => (w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())))
|
|
104
|
+
).join("")}`;
|
|
105
|
+
const antKey = `${IconCamelCase}Outlined`
|
|
106
|
+
if (Icons.hasOwnProperty(antKey)) {
|
|
103
107
|
// @ts-ignore
|
|
104
108
|
return Icons[antKey];
|
|
105
109
|
}
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
const tablerKey = `Icon${IconCamelCase}`;
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
const CustomIcon = () => React.createElement(Icon, {component: TablerIcons[tablerKey]});
|
|
113
|
+
return CustomIcon
|
|
108
114
|
};
|
|
@@ -73,6 +73,19 @@ export const WithUnexistingdIcon = (): React.ReactElement => {
|
|
|
73
73
|
);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
export const WithTablerIcon = (): React.ReactElement => {
|
|
77
|
+
const ooui = new ButtonOoui({
|
|
78
|
+
name: "button_field",
|
|
79
|
+
string: "Lorem ipsum",
|
|
80
|
+
icon: "bulb-off"
|
|
81
|
+
});
|
|
82
|
+
return (
|
|
83
|
+
<LocaleProvider lang="en_US">
|
|
84
|
+
<Button ooui={ooui} />
|
|
85
|
+
</LocaleProvider>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
76
89
|
export const PrimaryButton = (): React.ReactElement => {
|
|
77
90
|
const ooui = new ButtonOoui({
|
|
78
91
|
name: "button_field",
|