orcs-design-system 3.3.8 → 3.3.9
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import { themeGet } from "@styled-system/theme-get";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const panelWidth = "300px";
|
|
4
|
+
export const ComponentContainer = styled.div.withConfig({
|
|
5
|
+
displayName: "FloatingPanelsstyles__ComponentContainer",
|
|
5
6
|
componentId: "sc-1by914f-0"
|
|
6
|
-
})(["z-index:2;position:absolute;display:flex;flex-direction:column;gap:8px;
|
|
7
|
+
})(["z-index:2;position:absolute;display:flex;flex-direction:column;align-items:flex-end;gap:8px;max-height:", ";", ""], _ref => {
|
|
7
8
|
let {
|
|
8
9
|
containerHeight
|
|
9
10
|
} = _ref;
|
|
@@ -20,88 +21,65 @@ export const Container = styled.div.withConfig({
|
|
|
20
21
|
return `${key}: ${typeof value === "number" ? `${value}px` : value};`;
|
|
21
22
|
}).join("\n");
|
|
22
23
|
});
|
|
23
|
-
export const
|
|
24
|
-
displayName: "
|
|
24
|
+
export const PanelContainer = styled.div.withConfig({
|
|
25
|
+
displayName: "FloatingPanelsstyles__PanelContainer",
|
|
25
26
|
componentId: "sc-1by914f-1"
|
|
26
|
-
})(["
|
|
27
|
+
})(["display:flex;flex-direction:column;align-items:flex-end;box-shadow:0 1px 3px rgba(0,0,0,0.1);gap:8px;border-radius:calc(", " + 1px);overflow:hidden;background:transparent;width:", ";max-height:", ";"], themeGet("radii.2"), panelWidth, _ref5 => {
|
|
27
28
|
let {
|
|
28
|
-
|
|
29
|
-
theme
|
|
29
|
+
containerHeight
|
|
30
30
|
} = _ref5;
|
|
31
|
-
return
|
|
32
|
-
}
|
|
31
|
+
return containerHeight ? `${containerHeight}px` : "100%";
|
|
32
|
+
});
|
|
33
|
+
export const PanelWrapper = styled.div.withConfig({
|
|
34
|
+
displayName: "FloatingPanelsstyles__PanelWrapper",
|
|
35
|
+
componentId: "sc-1by914f-2"
|
|
36
|
+
})(["display:", ";background:white;width:", ";border:1px solid ", ";border-radius:8px;border-radius:0 0 8px 8px;overflow-y:auto;padding:\"0 12px 12px 12px\";margin-top:37px;transition:max-height 0.3s ease-in-out;"], _ref6 => {
|
|
33
37
|
let {
|
|
34
38
|
isExpanded
|
|
35
39
|
} = _ref6;
|
|
36
|
-
return isExpanded ? "
|
|
37
|
-
},
|
|
38
|
-
let {
|
|
39
|
-
isExpanded
|
|
40
|
-
} = _ref7;
|
|
41
|
-
return isExpanded ? "auto" : "hidden";
|
|
42
|
-
}, _ref8 => {
|
|
43
|
-
let {
|
|
44
|
-
isExpanded
|
|
45
|
-
} = _ref8;
|
|
46
|
-
return isExpanded ? "0 12px 12px 12px" : "0 12px";
|
|
47
|
-
}, _ref9 => {
|
|
48
|
-
let {
|
|
49
|
-
isExpanded
|
|
50
|
-
} = _ref9;
|
|
51
|
-
return isExpanded ? "none" : "0";
|
|
52
|
-
});
|
|
40
|
+
return isExpanded ? "block" : "none";
|
|
41
|
+
}, panelWidth, themeGet("colors.greyLighter"));
|
|
53
42
|
export const PanelHeader = styled.button.withConfig({
|
|
54
43
|
displayName: "FloatingPanelsstyles__PanelHeader",
|
|
55
|
-
componentId: "sc-1by914f-
|
|
56
|
-
})(["font-family:", ";
|
|
57
|
-
let {
|
|
58
|
-
isExpanded
|
|
59
|
-
} = _ref10;
|
|
60
|
-
return isExpanded ? "8px 8px 0 0" : "8px";
|
|
61
|
-
}, _ref11 => {
|
|
62
|
-
let {
|
|
63
|
-
isExpanded,
|
|
64
|
-
theme
|
|
65
|
-
} = _ref11;
|
|
66
|
-
return isExpanded ? `1px solid ${theme.colors.greyLighter}` : "none";
|
|
67
|
-
}, themeGet("colors.greyLighter"));
|
|
44
|
+
componentId: "sc-1by914f-3"
|
|
45
|
+
})(["font-family:", ";color:", ";margin-left:-1px;margin-top:-37px;border-radius:8px 8px 0 0;appearance:none;background-color:white;display:flex;align-items:center;justify-content:space-between;padding:", ";height:37px;position:absolute;width:", ";border:solid 1px ", ";z-index:1;cursor:pointer;user-select:none;transition:padding 0.3s ease-in-out;&:focus{outline:none;}"], themeGet("fonts.main"), themeGet("colors.greyDarkest"), themeGet("space.s"), panelWidth, themeGet("colors.greyLighter"));
|
|
68
46
|
export const HeaderContent = styled.div.withConfig({
|
|
69
47
|
displayName: "FloatingPanelsstyles__HeaderContent",
|
|
70
|
-
componentId: "sc-1by914f-
|
|
48
|
+
componentId: "sc-1by914f-4"
|
|
71
49
|
})(["display:flex;align-items:center;gap:12px;"]);
|
|
72
50
|
export const Title = styled.span.withConfig({
|
|
73
51
|
displayName: "FloatingPanelsstyles__Title",
|
|
74
|
-
componentId: "sc-1by914f-4"
|
|
75
|
-
})(["font-size:14px;font-weight:500;"]);
|
|
76
|
-
export const IconWrapper = styled.div.withConfig({
|
|
77
|
-
displayName: "FloatingPanelsstyles__IconWrapper",
|
|
78
52
|
componentId: "sc-1by914f-5"
|
|
79
|
-
})(["
|
|
80
|
-
export const
|
|
81
|
-
displayName: "
|
|
53
|
+
})(["font-size:14px;font-weight:500;"]);
|
|
54
|
+
export const PanelBar = styled.div.withConfig({
|
|
55
|
+
displayName: "FloatingPanelsstyles__PanelBar",
|
|
82
56
|
componentId: "sc-1by914f-6"
|
|
83
|
-
})(["
|
|
57
|
+
})(["display:flex;background:white;border:1px solid ", ";border-radius:", ";padding:2px;gap:2px;height:fit-content;box-shadow:0 0 1px 2px rgba(255,255,255,1);"], themeGet("colors.greyLighter"), themeGet("radii.2"));
|
|
58
|
+
export const IconButton = styled.button.withConfig({
|
|
59
|
+
displayName: "FloatingPanelsstyles__IconButton",
|
|
60
|
+
componentId: "sc-1by914f-7"
|
|
61
|
+
})(["font-family:", ";appearance:none;background-color:", ";border:none;width:36px;cursor:pointer;height:36px;display:flex;border-radius:", ";align-items:center;justify-content:center;transition:", ";&:hover{background-color:", ";}"], themeGet("fonts.main"), _ref7 => {
|
|
84
62
|
let {
|
|
85
|
-
|
|
86
|
-
} =
|
|
87
|
-
return
|
|
88
|
-
});
|
|
63
|
+
isExpanded
|
|
64
|
+
} = _ref7;
|
|
65
|
+
return isExpanded ? themeGet("colors.primaryLightest") : themeGet("colors.white");
|
|
66
|
+
}, themeGet("radii.2"), themeGet("transition.transitionDefault"), themeGet("colors.primaryLightest"));
|
|
89
67
|
export const PanelContent = styled.div.withConfig({
|
|
90
68
|
displayName: "FloatingPanelsstyles__PanelContent",
|
|
91
|
-
componentId: "sc-1by914f-
|
|
92
|
-
})(["padding
|
|
69
|
+
componentId: "sc-1by914f-8"
|
|
70
|
+
})(["padding:", ";width:inerhit;display:", ";height:", ";opacity:", ";"], themeGet("space.s"), _ref8 => {
|
|
93
71
|
let {
|
|
94
72
|
isExpanded
|
|
95
|
-
} =
|
|
73
|
+
} = _ref8;
|
|
96
74
|
return isExpanded ? "block" : "none";
|
|
97
|
-
},
|
|
75
|
+
}, _ref9 => {
|
|
98
76
|
let {
|
|
99
77
|
isExpanded
|
|
100
|
-
} =
|
|
78
|
+
} = _ref9;
|
|
101
79
|
return isExpanded ? "100%" : "0";
|
|
102
|
-
},
|
|
80
|
+
}, _ref10 => {
|
|
103
81
|
let {
|
|
104
82
|
isExpanded
|
|
105
|
-
} =
|
|
83
|
+
} = _ref10;
|
|
106
84
|
return isExpanded ? "1" : "0";
|
|
107
85
|
});
|
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import Icon from "../Icon";
|
|
4
|
-
import
|
|
4
|
+
import Popover from "../Popover";
|
|
5
|
+
import { PanelWrapper, PanelHeader, HeaderContent, Title, IconButton, PanelContent } from "./FloatingPanels.styles";
|
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
const Panel = _ref => {
|
|
7
|
+
export const Panel = _ref => {
|
|
7
8
|
let {
|
|
8
9
|
iconName,
|
|
9
10
|
title,
|
|
10
11
|
containerHeight,
|
|
11
12
|
content,
|
|
12
|
-
|
|
13
|
+
isExpanded,
|
|
14
|
+
toggleExpanded
|
|
13
15
|
} = _ref;
|
|
14
|
-
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
15
|
-
const arrowIcon = isExpanded ? "chevron-up" : "chevron-down";
|
|
16
16
|
const [isHovered, setIsHovered] = useState(false);
|
|
17
17
|
return /*#__PURE__*/_jsxs(PanelWrapper, {
|
|
18
18
|
containerHeight: containerHeight,
|
|
19
19
|
isExpanded: isExpanded,
|
|
20
20
|
children: [/*#__PURE__*/_jsxs(PanelHeader, {
|
|
21
|
-
onClick:
|
|
22
|
-
isExpanded: isExpanded,
|
|
21
|
+
onClick: toggleExpanded,
|
|
23
22
|
onMouseEnter: () => setIsHovered(true),
|
|
24
23
|
onMouseLeave: () => setIsHovered(false),
|
|
25
24
|
onFocus: () => setIsHovered(true),
|
|
26
25
|
onBlur: () => setIsHovered(false),
|
|
27
26
|
children: [/*#__PURE__*/_jsxs(HeaderContent, {
|
|
28
|
-
children: [/*#__PURE__*/_jsx(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
}), /*#__PURE__*/_jsx(Title, {
|
|
27
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
28
|
+
size: "s",
|
|
29
|
+
color: "greyDarker",
|
|
30
|
+
icon: ["far", iconName]
|
|
31
|
+
}), isExpanded && /*#__PURE__*/_jsx(Title, {
|
|
35
32
|
children: title
|
|
36
33
|
})]
|
|
37
|
-
}), /*#__PURE__*/_jsx(
|
|
38
|
-
|
|
34
|
+
}), isExpanded && /*#__PURE__*/_jsx(Popover, {
|
|
35
|
+
direction: "left",
|
|
36
|
+
text: "Close panel",
|
|
37
|
+
width: "fit-content",
|
|
39
38
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
40
39
|
size: "sm",
|
|
41
|
-
icon: ["fas",
|
|
42
|
-
color: "greyDarker"
|
|
40
|
+
icon: ["fas", "times"],
|
|
41
|
+
color: isHovered ? "primary" : "greyDarker"
|
|
43
42
|
})
|
|
44
43
|
})]
|
|
45
44
|
}), /*#__PURE__*/_jsx(PanelContent, {
|
|
@@ -54,11 +53,40 @@ Panel.propTypes = {
|
|
|
54
53
|
content: PropTypes.node.isRequired,
|
|
55
54
|
defaultExpanded: PropTypes.bool,
|
|
56
55
|
containerHeight: PropTypes.number,
|
|
57
|
-
isExpanded: PropTypes.bool.isRequired
|
|
56
|
+
isExpanded: PropTypes.bool.isRequired,
|
|
57
|
+
toggleExpanded: PropTypes.func.isRequired
|
|
58
58
|
};
|
|
59
59
|
Panel.defaultProps = {
|
|
60
60
|
defaultExpanded: false
|
|
61
61
|
};
|
|
62
|
+
export const PanelBarIcon = _ref2 => {
|
|
63
|
+
let {
|
|
64
|
+
iconName,
|
|
65
|
+
title,
|
|
66
|
+
toggleExpanded,
|
|
67
|
+
isExpanded
|
|
68
|
+
} = _ref2;
|
|
69
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
70
|
+
direction: "top",
|
|
71
|
+
text: title,
|
|
72
|
+
width: "fit-content",
|
|
73
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
74
|
+
onClick: toggleExpanded,
|
|
75
|
+
isExpanded: isExpanded,
|
|
76
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
77
|
+
size: "s",
|
|
78
|
+
color: "greyDarker",
|
|
79
|
+
icon: ["far", iconName]
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
PanelBarIcon.propTypes = {
|
|
85
|
+
iconName: PropTypes.string.isRequired,
|
|
86
|
+
title: PropTypes.string.isRequired,
|
|
87
|
+
toggleExpanded: PropTypes.func.isRequired,
|
|
88
|
+
isExpanded: PropTypes.bool.isRequired
|
|
89
|
+
};
|
|
62
90
|
Panel.__docgenInfo = {
|
|
63
91
|
"description": "",
|
|
64
92
|
"methods": [],
|
|
@@ -109,7 +137,48 @@ Panel.__docgenInfo = {
|
|
|
109
137
|
"name": "bool"
|
|
110
138
|
},
|
|
111
139
|
"required": true
|
|
140
|
+
},
|
|
141
|
+
"toggleExpanded": {
|
|
142
|
+
"description": "",
|
|
143
|
+
"type": {
|
|
144
|
+
"name": "func"
|
|
145
|
+
},
|
|
146
|
+
"required": true
|
|
112
147
|
}
|
|
113
148
|
}
|
|
114
149
|
};
|
|
115
|
-
|
|
150
|
+
PanelBarIcon.__docgenInfo = {
|
|
151
|
+
"description": "",
|
|
152
|
+
"methods": [],
|
|
153
|
+
"displayName": "PanelBarIcon",
|
|
154
|
+
"props": {
|
|
155
|
+
"iconName": {
|
|
156
|
+
"description": "",
|
|
157
|
+
"type": {
|
|
158
|
+
"name": "string"
|
|
159
|
+
},
|
|
160
|
+
"required": true
|
|
161
|
+
},
|
|
162
|
+
"title": {
|
|
163
|
+
"description": "",
|
|
164
|
+
"type": {
|
|
165
|
+
"name": "string"
|
|
166
|
+
},
|
|
167
|
+
"required": true
|
|
168
|
+
},
|
|
169
|
+
"toggleExpanded": {
|
|
170
|
+
"description": "",
|
|
171
|
+
"type": {
|
|
172
|
+
"name": "func"
|
|
173
|
+
},
|
|
174
|
+
"required": true
|
|
175
|
+
},
|
|
176
|
+
"isExpanded": {
|
|
177
|
+
"description": "",
|
|
178
|
+
"type": {
|
|
179
|
+
"name": "bool"
|
|
180
|
+
},
|
|
181
|
+
"required": true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import Panel from "./Panel";
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { ComponentContainer, PanelContainer, PanelBar } from "./FloatingPanels.styles";
|
|
3
|
+
import { Panel, PanelBarIcon } from "./Panel";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
6
|
const FloatingPanels = _ref => {
|
|
7
7
|
let {
|
|
8
8
|
panels,
|
|
@@ -12,13 +12,37 @@ const FloatingPanels = _ref => {
|
|
|
12
12
|
top: 20
|
|
13
13
|
}
|
|
14
14
|
} = _ref;
|
|
15
|
-
|
|
15
|
+
const [expandedPanelId, setExpandedPanelId] = useState(null);
|
|
16
|
+
|
|
17
|
+
// Set the default expanded panel on component mount
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const defaultExpandedPanel = panels.find(panel => panel.defaultExpanded);
|
|
20
|
+
if (defaultExpandedPanel) {
|
|
21
|
+
setExpandedPanelId(defaultExpandedPanel.id);
|
|
22
|
+
}
|
|
23
|
+
}, [panels]);
|
|
24
|
+
const togglePanel = panelId => {
|
|
25
|
+
setExpandedPanelId(expandedPanelId === panelId ? null : panelId);
|
|
26
|
+
};
|
|
27
|
+
return /*#__PURE__*/_jsxs(ComponentContainer, {
|
|
16
28
|
containerHeight: containerHeight,
|
|
17
29
|
position: position,
|
|
18
|
-
children:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
children: [/*#__PURE__*/_jsx(PanelBar, {
|
|
31
|
+
children: panels.map(panel => /*#__PURE__*/_jsx(PanelBarIcon, {
|
|
32
|
+
iconName: panel.iconName,
|
|
33
|
+
title: panel.title,
|
|
34
|
+
isExpanded: expandedPanelId === panel.id,
|
|
35
|
+
toggleExpanded: () => togglePanel(panel.id)
|
|
36
|
+
}, panel?.id))
|
|
37
|
+
}), /*#__PURE__*/_jsx(PanelContainer, {
|
|
38
|
+
containerHeight: containerHeight,
|
|
39
|
+
children: panels.map(panel => /*#__PURE__*/_jsx(Panel, {
|
|
40
|
+
...panel,
|
|
41
|
+
containerHeight: containerHeight,
|
|
42
|
+
isExpanded: expandedPanelId === panel.id,
|
|
43
|
+
toggleExpanded: () => togglePanel(panel.id)
|
|
44
|
+
}, panel?.id))
|
|
45
|
+
})]
|
|
22
46
|
});
|
|
23
47
|
};
|
|
24
48
|
FloatingPanels.propTypes = {
|