@unbxd-ui/unbxd-react-components 0.2.100 → 0.2.101-beta.1

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.
Files changed (140) hide show
  1. package/.babelrc +4 -0
  2. package/.eslintrc.js +38 -0
  3. package/CONTRIBUTE.md +105 -0
  4. package/components/Form/RangeSlider.js +3 -7
  5. package/components/Tooltip/Tooltip.js +2 -11
  6. package/components/core.css +1 -3
  7. package/components/theme.css +0 -2
  8. package/package.json +23 -13
  9. package/src/Intro.stories.mdx +119 -0
  10. package/src/components/Accordian/Accordian.js +89 -0
  11. package/src/components/Accordian/Accordian.stories.js +92 -0
  12. package/src/components/Accordian/accordianCore.scss +8 -0
  13. package/src/components/Accordian/accordianTheme.scss +6 -0
  14. package/src/components/Accordian/index.js +3 -0
  15. package/src/components/Button/Button.js +67 -0
  16. package/src/components/Button/Button.stories.js +103 -0
  17. package/src/components/Button/DropdownButton.js +60 -0
  18. package/src/components/Button/DropdownButton.stories.js +38 -0
  19. package/src/components/Button/buttonTheme.css +1 -0
  20. package/src/components/Button/buttonTheme.scss +45 -0
  21. package/src/components/Button/index.js +5 -0
  22. package/src/components/DataLoader/DataLoader.js +86 -0
  23. package/src/components/DataLoader/DataLoader.stories.js +72 -0
  24. package/src/components/DataLoader/index.js +3 -0
  25. package/src/components/Form/Checkbox.js +73 -0
  26. package/src/components/Form/DragDropFileUploader.js +67 -0
  27. package/src/components/Form/Dropdown.js +415 -0
  28. package/src/components/Form/FileUploader.js +64 -0
  29. package/src/components/Form/Form.js +83 -0
  30. package/src/components/Form/FormElementWrapper.js +22 -0
  31. package/src/components/Form/Input.js +121 -0
  32. package/src/components/Form/RadioList.js +86 -0
  33. package/src/components/Form/RangeSlider.js +100 -0
  34. package/src/components/Form/ServerPaginatedDDList.js +226 -0
  35. package/src/components/Form/Textarea.js +76 -0
  36. package/src/components/Form/Toggle.js +96 -0
  37. package/src/components/Form/form.css +1 -0
  38. package/src/components/Form/formCore.scss +142 -0
  39. package/src/components/Form/formTheme.scss +27 -0
  40. package/src/components/Form/index.js +13 -0
  41. package/src/components/Form/stories/Checkbox.stories.js +41 -0
  42. package/src/components/Form/stories/DragDropFileUploader.stories.js +21 -0
  43. package/src/components/Form/stories/Dropdown.stories.js +124 -0
  44. package/src/components/Form/stories/FileUploader.stories.js +21 -0
  45. package/src/components/Form/stories/FormDefault.stories.js +87 -0
  46. package/src/components/Form/stories/RadioList.stories.js +48 -0
  47. package/src/components/Form/stories/RangeSlider.stories.js +84 -0
  48. package/src/components/Form/stories/TextInput.stories.js +77 -0
  49. package/src/components/Form/stories/Textarea.stories.js +43 -0
  50. package/src/components/Form/stories/Toggle.stories.js +14 -0
  51. package/src/components/Form/stories/form.stories.js +216 -0
  52. package/src/components/InlineModal/InlineModal.js +135 -0
  53. package/src/components/InlineModal/InlineModal.stories.js +54 -0
  54. package/src/components/InlineModal/index.js +4 -0
  55. package/src/components/InlineModal/inlineModal.css +1 -0
  56. package/src/components/InlineModal/inlineModalCore.scss +31 -0
  57. package/src/components/InlineModal/inlineModalTheme.scss +16 -0
  58. package/src/components/List/List.js +72 -0
  59. package/src/components/List/index.js +3 -0
  60. package/src/components/List/list.stories.js +28 -0
  61. package/src/components/List/listCore.css +1 -0
  62. package/src/components/List/listCore.scss +6 -0
  63. package/src/components/Modal/Modal.js +99 -0
  64. package/src/components/Modal/Modal.stories.js +54 -0
  65. package/src/components/Modal/index.js +3 -0
  66. package/src/components/Modal/modal.css +1 -0
  67. package/src/components/Modal/modalCore.scss +34 -0
  68. package/src/components/NotificationComponent/NotificationComponent.js +58 -0
  69. package/src/components/NotificationComponent/NotificationComponent.stories.js +28 -0
  70. package/src/components/NotificationComponent/index.js +3 -0
  71. package/src/components/NotificationComponent/notificationComponent.css +1 -0
  72. package/src/components/NotificationComponent/notificationTheme.scss +30 -0
  73. package/src/components/ProgressBar/ProgressBar.js +45 -0
  74. package/src/components/ProgressBar/ProgressBar.stories.js +14 -0
  75. package/src/components/ProgressBar/index.js +3 -0
  76. package/src/components/ProgressBar/progressBarCore.css +1 -0
  77. package/src/components/ProgressBar/progressBarCore.scss +14 -0
  78. package/src/components/ProgressBar/progressBarTheme.css +0 -0
  79. package/src/components/ProgressBar/progressBarTheme.scss +0 -0
  80. package/src/components/Table/BaseTable.js +306 -0
  81. package/src/components/Table/PaginationComponent.js +73 -0
  82. package/src/components/Table/Table.js +295 -0
  83. package/src/components/Table/Table.stories.js +198 -0
  84. package/src/components/Table/index.js +8 -0
  85. package/src/components/Table/table.css +1 -0
  86. package/src/components/Table/tableCore.scss +94 -0
  87. package/src/components/Table/tableTheme.scss +34 -0
  88. package/src/components/TabsComponent/TabsComponent.js +99 -0
  89. package/src/components/TabsComponent/TabsComponent.stories.js +69 -0
  90. package/src/components/TabsComponent/index.js +3 -0
  91. package/src/components/TabsComponent/tabs.css +1 -0
  92. package/src/components/TabsComponent/tabsCore.scss +59 -0
  93. package/src/components/TabsComponent/tabsTheme.css +0 -0
  94. package/src/components/TabsComponent/tabsTheme.scss +0 -0
  95. package/src/components/Tooltip/Tooltip.js +87 -0
  96. package/src/components/Tooltip/Tooltip.stories.js +16 -0
  97. package/src/components/Tooltip/index.js +3 -0
  98. package/src/components/Tooltip/tooltipCore.scss +22 -0
  99. package/src/components/Tooltip/tooltipTheme.scss +21 -0
  100. package/src/components/core.css +1 -0
  101. package/src/components/core.scss +29 -0
  102. package/src/components/index.js +38 -0
  103. package/src/components/theme.css +1 -0
  104. package/src/components/theme.scss +11 -0
  105. package/src/core/Validators.js +34 -0
  106. package/src/core/customHooks.js +20 -0
  107. package/src/core/dataLoader.js +143 -0
  108. package/src/core/dataLoader.stories.js +123 -0
  109. package/src/core/index.js +3 -0
  110. package/src/core/utils.js +95 -0
  111. package/src/index.js +68 -0
  112. package/vscode-templates/NewStoryTemplate.stories.js +8 -0
  113. package/core/Validators.js +0 -48
  114. package/core/customHooks.js +0 -41
  115. package/core/dataLoader.js +0 -235
  116. package/core/dataLoader.stories.js +0 -153
  117. package/core/index.js +0 -31
  118. package/core/utils.js +0 -112
  119. package/index.js +0 -193
  120. /package/{Readme.md → README.md} +0 -0
  121. /package/{components → src/components}/Accordian/accordianCore.css +0 -0
  122. /package/{components → src/components}/Accordian/accordianTheme.css +0 -0
  123. /package/{components/Button/buttonTheme.css → src/components/Button/button.css} +0 -0
  124. /package/{components → src/components}/Form/formCore.css +0 -0
  125. /package/{components → src/components}/Form/formTheme.css +0 -0
  126. /package/{components → src/components}/InlineModal/inlineModalCore.css +0 -0
  127. /package/{components → src/components}/InlineModal/inlineModalTheme.css +0 -0
  128. /package/{components/List/listCore.css → src/components/List/list.css} +0 -0
  129. /package/{components → src/components}/List/listTheme.css +0 -0
  130. /package/{components/Modal/modalTheme.css → src/components/List/listTheme.scss} +0 -0
  131. /package/{components → src/components}/Modal/modalCore.css +0 -0
  132. /package/{components/ProgressBar/progressBarTheme.css → src/components/Modal/modalTheme.css} +0 -0
  133. /package/{components/TabsComponent/tabsTheme.css → src/components/Modal/modalTheme.scss} +0 -0
  134. /package/{components → src/components}/NotificationComponent/notificationTheme.css +0 -0
  135. /package/{components/ProgressBar/progressBarCore.css → src/components/ProgressBar/progressBar.css} +0 -0
  136. /package/{components → src/components}/Table/tableCore.css +0 -0
  137. /package/{components → src/components}/Table/tableTheme.css +0 -0
  138. /package/{components → src/components}/TabsComponent/tabsCore.css +0 -0
  139. /package/{components → src/components}/Tooltip/tooltipCore.css +0 -0
  140. /package/{components → src/components}/Tooltip/tooltipTheme.css +0 -0
@@ -0,0 +1,198 @@
1
+ import React, { useState, Fragment, useCallback } from "react";
2
+ import Table from "./Table";
3
+ import DataLoader from "../DataLoader";
4
+ import dataLoader from "../../core/dataLoader";
5
+ import { Input } from "../Form";
6
+ import { TODOS, FRUITS_LIST } from "../../../public/Constants";
7
+
8
+ const getFruitsColumnConfigs = () => {
9
+ let columnConfigs = [
10
+ {
11
+ label: "Id",
12
+ key: "id",
13
+ sortable: true
14
+ },
15
+ {
16
+ label: "Task Name",
17
+ key: "name",
18
+ sortable: true
19
+ }
20
+ ];
21
+
22
+ return columnConfigs;
23
+ };
24
+
25
+ const getTodosColumnConfigs = () => {
26
+ let columnConfigs = [
27
+ {
28
+ label: "Id",
29
+ key: "id",
30
+ },
31
+ {
32
+ label: "Task Name",
33
+ key: "title",
34
+ },
35
+ {
36
+ label: "Status",
37
+ key: "completed",
38
+ valueFormatter: function({ value }) {
39
+ return value ? "Completed" : "Not Started";
40
+ },
41
+ },
42
+ ];
43
+
44
+ return columnConfigs;
45
+ };
46
+
47
+ const getUsersColumnConfigs = () => {
48
+ let columnConfigs = [
49
+ {
50
+ label: "Avatar",
51
+ key: "avatar",
52
+ /* eslint-disable react/prop-types */
53
+ valueFormatter: function renderUserImage({ value }) {
54
+ return <img src={value} />;
55
+ },
56
+ /* eslint-enable react/prop-types */
57
+ },
58
+ {
59
+ label: "first_name",
60
+ key: "name",
61
+ sortable: true,
62
+ valueFormatter: function({ record }) {
63
+ const { first_name, last_name } = record;
64
+
65
+ return `${first_name} ${last_name}`;
66
+ },
67
+ },
68
+ ];
69
+
70
+ return columnConfigs;
71
+ };
72
+
73
+ /* eslint-disable react/prop-types */
74
+ const TODODetail = props => {
75
+ const { parentRecord = {} } = props;
76
+ const { id } = parentRecord;
77
+ const [todoData, setTodoData] = useState({});
78
+ const { title, completed } = todoData;
79
+
80
+ dataLoader.addRequestConfig("getTodoById", {
81
+ method: "GET",
82
+ url: function(params) {
83
+ return `https://jsonplaceholder.typicode.com/todos/${params.id}`;
84
+ },
85
+ });
86
+
87
+ const onDataLoaded = ([todoData]) => {
88
+ setTodoData(todoData);
89
+ };
90
+
91
+ const requests = [
92
+ {
93
+ requestId: "getTodoById",
94
+ urlParams: {
95
+ id
96
+ },
97
+ },
98
+ ];
99
+
100
+ return (
101
+ <DataLoader requests={requests} onDataLoaded={onDataLoaded}>
102
+ <div>
103
+ <b>Title:</b> {title}{" "}
104
+ </div>
105
+ <div>
106
+ <b>Status:</b> {completed ? "Completed" : "Not Completed"}{" "}
107
+ </div>
108
+ </DataLoader>
109
+ );
110
+ };
111
+ /* eslint-enable react/prop-types */
112
+
113
+ export const SimpleUsage = () => {
114
+ return <Table records={FRUITS_LIST}
115
+ columnConfigs={getFruitsColumnConfigs()} />;
116
+ };
117
+
118
+ export const ExpandedTable = () => {
119
+ return (
120
+ <Table
121
+ records={TODOS}
122
+ columnConfigs={getTodosColumnConfigs()}
123
+ isExpandableTable={true}
124
+ ExpandedRowComponent={TODODetail}
125
+ />
126
+ );
127
+ };
128
+
129
+ export const TableWithSearch = () => {
130
+ const [ searchBy, setSearchBy ] = useState("");
131
+
132
+ const onSearchChange = (value) => {
133
+ setSearchBy(value);
134
+ };
135
+
136
+ const getRequestKeys = useCallback(() => ({searchBy: "title"}));
137
+
138
+ return (<Fragment>
139
+ <Input name="searchBy" onChange={onSearchChange} />
140
+ <Table
141
+ records={TODOS} searchBy={searchBy} getRequestKeys={getRequestKeys}
142
+ columnConfigs={getTodosColumnConfigs()}
143
+ />
144
+ </Fragment>);
145
+ };
146
+
147
+ export const TableWithoutPaginationBar = () => {
148
+
149
+ return (<Fragment>
150
+ <Table
151
+ records={TODOS}
152
+ showPaginateBar={false}
153
+ columnConfigs={getTodosColumnConfigs()}
154
+ />
155
+ </Fragment>);
156
+ };
157
+
158
+ export const ServerSideTable = () => {
159
+ const [ searchBy, setSearchBy ] = useState("");
160
+
161
+ dataLoader.addRequestConfig("getUsers", {
162
+ method: "GET",
163
+ url: "https://reqres.in/api/users",
164
+ });
165
+
166
+ const onSearchChange = (value) => {
167
+ setSearchBy(value);
168
+ };
169
+
170
+ const responseFormatter = (response) => {
171
+ return {
172
+ ...response,
173
+ entries: response.data
174
+ };
175
+ };
176
+
177
+ return (<Fragment>
178
+ <Input name="searchBy" onChange={onSearchChange} />
179
+ <Table
180
+ searchBy={searchBy}
181
+ paginationType="SERVER"
182
+ requestId="getUsers"
183
+ perPageKey="per_page"
184
+ responseFormatter={responseFormatter}
185
+ columnConfigs={getUsersColumnConfigs()}
186
+ />
187
+ </Fragment>);
188
+ };
189
+
190
+ export default {
191
+ title: "Table",
192
+
193
+ parameters: {
194
+ info: {
195
+ propTablesExclude: [ServerSideTable],
196
+ },
197
+ },
198
+ };
@@ -0,0 +1,8 @@
1
+ import Table from "./Table";
2
+ import PaginationComponent from "./PaginationComponent";
3
+
4
+ export {
5
+ PaginationComponent
6
+ };
7
+
8
+ export default Table;
@@ -0,0 +1 @@
1
+ .RCB-table{border-collapse:collapse;width:100%}.RCB-table td{padding:10px}.RCB-th{background-color:#125c7f;color:#FFF;font-weight:normal}.RCB-th.RCB-expand-column{width:50px}.RCB-tr .expand-open:before{content:"▼"}.RCB-tr .expand-close:before{content:"▶"}.RCB-parent-row{cursor:pointer}.RCB-even-tr{background-color:#82bed9}.RCB-odd-tr{background-color:#dcf1fa}.RCB-expanded-row{background-color:#ecf2f4}.RCB-paginate-wrapper{background-color:rgba(148,170,202,0.14);text-align:right;font-size:14px;padding:5px}.RCB-paginate-wrapper .RCB-per-page-count{display:inline-block}.RCB-paginate-wrapper .RCB-form-el-cont{margin:0}.RCB-paginate-wrapper .RCB-inline-modal-btn{background:transparent;padding:0}.RCB-paginate-nav{display:inline-block;border-radius:12px;border:solid 1px #8399ae;background-color:#f6f7f9;vertical-align:middle;margin-left:15px;overflow:hidden}.RCB-page-nav{padding:0 5px;text-decoration:none;color:inherit}.RCB-page-nav:first-child{border-right:solid 1px #8399ae}.RCB-page-nav.disabled{color:#ccc;pointer-events:none;cursor:not-allowed}.RCB-no-data{text-align:center}
@@ -0,0 +1,94 @@
1
+ .RCB {
2
+ &-table {
3
+ border-collapse: collapse;
4
+ width: 100%;
5
+ }
6
+
7
+ &-th {
8
+ &.RCB-expand-column {
9
+ width: 50px;
10
+ }
11
+ }
12
+
13
+ &-th-sortable {
14
+ cursor: pointer;
15
+ }
16
+
17
+ &-th-sort {
18
+ &:after {
19
+ content: "\2B0D"
20
+ }
21
+ }
22
+
23
+ &-th-asc {
24
+ &:after {
25
+ content: "\25B2";
26
+ }
27
+ }
28
+
29
+ &-th-dsc {
30
+ &:after {
31
+ content: "\25BC";
32
+ }
33
+ }
34
+
35
+ &-tr {
36
+
37
+ .expand-open {
38
+ &:before {
39
+ content: "▼"
40
+ }
41
+ }
42
+
43
+ .expand-close {
44
+ &:before {
45
+ content: "▶"
46
+ }
47
+ }
48
+ }
49
+
50
+ &-paginate-wrapper {
51
+ .RCB-per-page-count {
52
+ display: inline-block;
53
+ }
54
+
55
+ .RCB-form-el-cont {
56
+ margin: 0;
57
+ }
58
+
59
+ .RCB-inline-modal-btn {
60
+ background: transparent;
61
+ padding: 0;
62
+ }
63
+ }
64
+
65
+ &-paginate-nav {
66
+ display: inline-block;
67
+ border-radius: 12px;
68
+ border: solid 1px #8399ae;
69
+ background-color: #f6f7f9;
70
+ vertical-align: middle;
71
+ margin-left: 15px;
72
+ overflow: hidden;
73
+ }
74
+
75
+ &-page-nav {
76
+ padding: 0 5px;
77
+ text-decoration: none;
78
+ color: inherit;
79
+
80
+ &:first-child {
81
+ border-right: solid 1px #8399ae;
82
+ }
83
+
84
+ &.disabled {
85
+ color: #ccc;
86
+ pointer-events: none;
87
+ cursor: not-allowed;
88
+ }
89
+ }
90
+
91
+ &-no-data {
92
+ text-align: center;
93
+ }
94
+ }
@@ -0,0 +1,34 @@
1
+ .RCB {
2
+ &-table {
3
+ td {
4
+ padding: 10px;
5
+ }
6
+ }
7
+
8
+ &-th {
9
+ background-color: #2287b4;
10
+ color: #FFF;
11
+ font-weight: normal;
12
+ padding: 10px;
13
+ }
14
+
15
+ &-even-tr {
16
+ background-color: #FFF;
17
+ }
18
+
19
+ &-odd-tr {
20
+ background-color: #dcf1fa;
21
+ }
22
+
23
+ &-expanded-row {
24
+ background-color: #ecf2f4;
25
+ }
26
+
27
+ &-paginate-bar {
28
+ background-color: #a3c9db;
29
+ text-align: right;
30
+ font-size: 14px;
31
+ padding: 5px;
32
+ border-radius: 5px 5px 0 0;
33
+ }
34
+ }
@@ -0,0 +1,99 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+ import List from "../List";
4
+
5
+ const DefaultTabTitleItem = (props) => {
6
+ const { itemData, selected, changeTab, disabled:allDisabled } = props;
7
+ const { id, label, disabled } = itemData;
8
+ const isSelected = id === selected;
9
+ const className = `RCB-tab-title ${isSelected ? "selected" : ""} ${(allDisabled || disabled) ? "RCB-tab-disabled" : ""}`;
10
+
11
+ const triggerTabChange = () => {
12
+ changeTab(id);
13
+ };
14
+
15
+ return (<li className={className} selected={isSelected} onClick={triggerTabChange}>
16
+ {label}
17
+ </li>);
18
+ };
19
+
20
+ DefaultTabTitleItem.propTypes = {
21
+ itemData: PropTypes.shape({
22
+ id: PropTypes.string.isRequired,
23
+ label: PropTypes.any.isRequired,
24
+ disabled: PropTypes.bool
25
+ }).isRequired,
26
+ selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
27
+ changeTab: PropTypes.func.isRequired,
28
+ disabled: PropTypes.bool
29
+ };
30
+
31
+ const TabsComponent = (props) => {
32
+ const { className, items, selectedTab, onTabChange, onTabChanged, appearance, disabled, staticTabContent, TabTitleItem } = props;
33
+ const getSelected = () => disabled ? "" : defaultSelected;
34
+ const defaultSelected = selectedTab || (items[0] ? items[0].id : "");
35
+ const [ selected, setSelected ] = useState(getSelected());
36
+ const appearanceClassName = `RCB-tabs-${appearance.toLowerCase()}`;
37
+
38
+ useEffect(() => {
39
+ setSelected(getSelected());
40
+ }, [disabled, selectedTab]);
41
+
42
+ const changeTab = (id) => {
43
+ const changeTab = onTabChange(id);
44
+
45
+ if (changeTab) {
46
+ setSelected(id);
47
+ if (typeof(onTabChanged) === "function") {
48
+ onTabChanged(id);
49
+ }
50
+ }
51
+ };
52
+
53
+ const selecetdTabData = items.find(obj => obj.id === selected);
54
+ const { bodyComponent } = selecetdTabData || {};
55
+
56
+ return (<div className={`RCB-tabs-container ${appearanceClassName} ${className}`}>
57
+ <List items={items} ListItem={TabTitleItem} selected={selected} disabled={disabled} changeTab={changeTab} className="RCB-tabs-header" />
58
+ <div className="RCB-tab-content">
59
+ {staticTabContent || bodyComponent}
60
+ </div>
61
+ </div>)
62
+ };
63
+
64
+ TabsComponent.propTypes = {
65
+ /* custom tab title component */
66
+ TabTitleItem: PropTypes.any,
67
+ /** Pass any additional classNames to Tabs component */
68
+ className: PropTypes.string,
69
+ /** Array of tab items. Each object in array should contain {id, label, bodyComponent: <Component />, disabled} */
70
+ items: PropTypes.arrayOf(PropTypes.shape({
71
+ id: PropTypes.string.isRequired,
72
+ label: PropTypes.any.isRequired,
73
+ bodyComponent: PropTypes.instanceOf(Object),
74
+ disabled: PropTypes.bool
75
+ })).isRequired,
76
+ /** ID of the tab item to be selected */
77
+ selectedTab: PropTypes.string,
78
+ /** Horizontal or vertical tabs */
79
+ appearance: PropTypes.oneOf(["HORIZONTAL", "VERTICAL"]),
80
+ /** Function called when a tab change has been triggerd by the user,
81
+ * return false if you want to stop the tab change action */
82
+ onTabChange: PropTypes.func,
83
+ /** Function called when a tab change action has been completed */
84
+ onTabChanged: PropTypes.func,
85
+ /** disable all tabs */
86
+ disabled: PropTypes.bool,
87
+ /** if you want to show a static tab content in disabled state (i.e. "disabled=true"), pass it in this prop */
88
+ staticTabContent: PropTypes.any
89
+ };
90
+
91
+ TabsComponent.defaultProps = {
92
+ TabTitleItem: DefaultTabTitleItem,
93
+ className: "",
94
+ appearance: "HORIZONTAL",
95
+ disabled: false,
96
+ onTabChange: () => true
97
+ };
98
+
99
+ export default TabsComponent;
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import TabsComponent from "./TabsComponent";
3
+
4
+ const SetupTab = () => {
5
+ return <div>This is Setup Tab</div>;
6
+ };
7
+
8
+ const ConfigTab = () => {
9
+ return <div>This is Configuration Tab</div>;
10
+ };
11
+
12
+ const InfoTab = () => {
13
+ return <div>This is Info Tab</div>;
14
+ };
15
+
16
+ let items = [
17
+ {
18
+ id: "SETUP",
19
+ label: "Setup",
20
+ disabled: true,
21
+ bodyComponent: <SetupTab />,
22
+ },
23
+ {
24
+ id: "CONFIG",
25
+ label: "Configuration",
26
+ bodyComponent: <ConfigTab />,
27
+ },
28
+ {
29
+ id: "INFO",
30
+ label: "Info",
31
+ bodyComponent: <InfoTab />,
32
+ },
33
+ ];
34
+
35
+ export default {
36
+ title: "TabsComponent",
37
+ };
38
+
39
+ export const SimpleUsage = () => {
40
+ const onTabChanged = () => {};
41
+
42
+ return <TabsComponent items={items} selectedTab="CONFIG" onTabChanged={onTabChanged} />;
43
+ };
44
+
45
+ export const HorizontalTabs = () => {
46
+ const onTabChanged = () => {};
47
+
48
+ return (
49
+ <TabsComponent
50
+ items={items}
51
+ selectedTab="CONFIG"
52
+ onTabChanged={onTabChanged}
53
+ appearance="HORIZONTAL"
54
+ />
55
+ );
56
+ };
57
+
58
+ export const VerticalTabs = () => {
59
+ const onTabChanged = () => {};
60
+
61
+ return (
62
+ <TabsComponent
63
+ items={items}
64
+ selectedTab="CONFIG"
65
+ onTabChanged={onTabChanged}
66
+ appearance="VERTICAL"
67
+ />
68
+ );
69
+ };
@@ -0,0 +1,3 @@
1
+ import TabsComponent from "./TabsComponent";
2
+
3
+ export default TabsComponent;
@@ -0,0 +1 @@
1
+ .RCB-tab-title{list-style-type:none;display:inline-block;padding:10px;cursor:pointer}.RCB-tab-title.selected{background:#FFF;font-weight:bold;border:1px solid #cacaca;border-bottom:0;position:relative;z-index:1;bottom:-1px}.RCB-tab-content{list-style-type:none;border:1px solid #cacaca;padding:10px}.RCB-tab-content.selected{display:block}
@@ -0,0 +1,59 @@
1
+ .RCB {
2
+ &-tabs-container {
3
+ display: flex;
4
+ }
5
+
6
+ &-tab-title {
7
+ list-style-type: none;
8
+ padding: 10px;
9
+ cursor: pointer;
10
+
11
+ &.selected {
12
+ background: #FFF;
13
+ font-weight: bold;
14
+ border: 1px solid #cacaca;
15
+ position: relative;
16
+ z-index: 1;
17
+ }
18
+ }
19
+
20
+ &-tabs-horizontal {
21
+ flex-direction: column;
22
+
23
+ .RCB-tab-title {
24
+ display: inline-block;
25
+
26
+ &.selected {
27
+ border-bottom: 0;
28
+ bottom: -1px;
29
+ }
30
+ }
31
+ }
32
+
33
+ &-tabs-vertical {
34
+ .RCB-tab-title {
35
+ display: block;
36
+
37
+ &.selected {
38
+ border-right: 0;
39
+ right: -1px;
40
+ }
41
+ }
42
+ }
43
+
44
+ &-tab-content {
45
+ list-style-type: none;
46
+ border: 1px solid #cacaca;
47
+ padding: 10px;
48
+
49
+ &.selected {
50
+ display: block;
51
+ }
52
+ }
53
+
54
+ &-tab-disabled {
55
+ pointer-events: none;
56
+ cursor: not-allowed;
57
+ color: #ccc;
58
+ }
59
+ }
File without changes
File without changes
@@ -0,0 +1,87 @@
1
+ import React, { forwardRef,Fragment, useRef, useState,useImperativeHandle,useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+
4
+ /* eslint-disable react/prop-types */
5
+ const DefaultTooltipActivator = () => {
6
+ return (<Fragment>i</Fragment>);
7
+ };
8
+
9
+ let Tooltip = (props, ref) => {
10
+ const {
11
+ TooltipActivator,
12
+ activatorAction,
13
+ direction,
14
+ children,
15
+ className,
16
+ ...restProps
17
+ } = props;
18
+
19
+ const [actionClassName, setActionClassName] = useState("");
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ let dirClassName = "RCB-tooltip-right";
22
+ switch(direction) {
23
+ case "bottom":
24
+ dirClassName = "RCB-tooltip-bottom";
25
+ break;
26
+
27
+ case "left":
28
+ dirClassName = "RCB-tooltip-left";
29
+ break;
30
+
31
+ case "top":
32
+ dirClassName = "RCB-tooltip-top";
33
+ break;
34
+
35
+ default:
36
+ dirClassName = "RCB-tooltip-right";
37
+ break;
38
+ }
39
+
40
+ useImperativeHandle(ref, () => ({
41
+ hideToolTip: () => {
42
+ setIsOpen(false);
43
+ }
44
+ }));
45
+
46
+ const showToolTipClick = (e) => {
47
+ e.stopPropagation();
48
+ setIsOpen(!isOpen);
49
+ setActionClassName("RCB-tooltip-click");
50
+ }
51
+
52
+ const showToolTipHover = () => {
53
+ setActionClassName("RCB-tooltip-hover");
54
+ setIsOpen(true);
55
+ }
56
+
57
+ const hideToolTip = () => {
58
+ setIsOpen(false);
59
+ }
60
+
61
+ const eventProps = (activatorAction === "click") ? { onClick: showToolTipClick } : { onMouseEnter: showToolTipHover, onMouseLeave: hideToolTip };
62
+
63
+ return (<div className={`RCB-tooltip ${className}`}>
64
+ <div className="RCB-tooltip-btn" {...eventProps}>
65
+ <TooltipActivator {...restProps}></TooltipActivator>
66
+ </div>
67
+ {isOpen && <div className={`RCB-tooltip-body ${dirClassName} ${actionClassName}`} >
68
+ {children}
69
+ </div>}
70
+ </div>);
71
+ };
72
+
73
+ Tooltip = forwardRef(Tooltip);
74
+
75
+ Tooltip.propTypes = {
76
+ TooltipActivator: PropTypes.func,
77
+ activatorAction: PropTypes.oneOf(["click", "hover"]),
78
+ direction: PropTypes.oneOf(["right", "bottom","left","top"])
79
+ };
80
+
81
+ Tooltip.defaultProps = {
82
+ TooltipActivator: DefaultTooltipActivator,
83
+ activatorAction: "hover",
84
+ direction: "right"
85
+ };
86
+
87
+ export default Tooltip;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Tooltip from "./Tooltip";
3
+
4
+ const CustomActivator = () => {
5
+ return <span>Hover over me</span>;
6
+ }
7
+
8
+ export const SimpleUsage = () => {
9
+ return (<Tooltip tooltipActivator={<CustomActivator />}>
10
+ <img src="https://cdn1.iconfinder.com/data/icons/hawcons/32/700231-icon-61-warning-512.png" width={20}/>This is a sample tooltip
11
+ </Tooltip>);
12
+ };
13
+
14
+ export default {
15
+ title: "Tooltip",
16
+ };
@@ -0,0 +1,3 @@
1
+ import Tooltip from "./Tooltip";
2
+
3
+ export default Tooltip;