orcs-design-system 3.3.7 → 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
- export const Container = styled.div.withConfig({
4
- displayName: "FloatingPanelsstyles__Container",
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;width:300px;max-height:", ";", ""], _ref => {
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 PanelWrapper = styled.div.withConfig({
24
- displayName: "FloatingPanelsstyles__PanelWrapper",
24
+ export const PanelContainer = styled.div.withConfig({
25
+ displayName: "FloatingPanelsstyles__PanelContainer",
25
26
  componentId: "sc-1by914f-1"
26
- })(["background:white;border:", ";border-radius:8px;border-radius:0 0 8px 8px;box-shadow:", ";overflow-y:", ";padding:", ";margin-top:46px;max-height:", ";transition:max-height 0.3s ease-in-out;"], _ref5 => {
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
- isExpanded,
29
- theme
29
+ containerHeight
30
30
  } = _ref5;
31
- return isExpanded ? `1px solid ${theme.colors.greyLighter}` : "1px solid white";
32
- }, _ref6 => {
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 ? "0 1px 3px rgba(0, 0, 0, 0.1)" : "none";
37
- }, _ref7 => {
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-2"
56
- })(["font-family:", ";box-shadow:0 0 4px rgba(0,0,0,0.1);color:", ";width:100%;margin-left:-13px;margin-top:-46px;border-radius:", ";appearance:none;background-color:white;display:flex;align-items:center;justify-content:space-between;padding:12px 12px 12px 12px;height:46px;position:absolute;width:300px;border-bottom:", ";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"), _ref10 => {
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-3"
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
- })(["background-color:", ";width:22px;height:22px;border-radius:50%;display:flex;align-items:center;justify-content:center;"], themeGet("colors.primary"));
80
- export const ChevronWrapper = styled(IconWrapper).withConfig({
81
- displayName: "FloatingPanelsstyles__ChevronWrapper",
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
- })(["transition:background-color 0.3s ease-in-out;background-color:", ";"], _ref12 => {
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
- isHovered
86
- } = _ref12;
87
- return isHovered ? themeGet("colors.greyLighter") : "white";
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-7"
92
- })(["padding-top:12px;display:", ";height:", ";opacity:", ";"], _ref13 => {
69
+ componentId: "sc-1by914f-8"
70
+ })(["padding:", ";width:inerhit;display:", ";height:", ";opacity:", ";"], themeGet("space.s"), _ref8 => {
93
71
  let {
94
72
  isExpanded
95
- } = _ref13;
73
+ } = _ref8;
96
74
  return isExpanded ? "block" : "none";
97
- }, _ref14 => {
75
+ }, _ref9 => {
98
76
  let {
99
77
  isExpanded
100
- } = _ref14;
78
+ } = _ref9;
101
79
  return isExpanded ? "100%" : "0";
102
- }, _ref15 => {
80
+ }, _ref10 => {
103
81
  let {
104
82
  isExpanded
105
- } = _ref15;
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 { PanelWrapper, PanelHeader, HeaderContent, Title, IconWrapper, ChevronWrapper, PanelContent } from "./FloatingPanels.styles";
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
- defaultExpanded = false
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: () => setIsExpanded(!isExpanded),
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(IconWrapper, {
29
- children: /*#__PURE__*/_jsx(Icon, {
30
- size: "xs",
31
- color: "white",
32
- icon: ["far", iconName]
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(ChevronWrapper, {
38
- isHovered: isHovered,
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", arrowIcon],
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
- export default Panel;
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 { Container } from "./FloatingPanels.styles";
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
- return /*#__PURE__*/_jsx(Container, {
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: panels.map(panel => /*#__PURE__*/_jsx(Panel, {
19
- ...panel,
20
- containerHeight: containerHeight
21
- }, panel?.id))
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 = {
@@ -13,7 +13,7 @@ export default {
13
13
  component: Header,
14
14
  decorators: [storyFn => /*#__PURE__*/_jsx(Box, {
15
15
  height: "350px",
16
- bg: "greyLightest",
16
+ bg: "white",
17
17
  p: "r",
18
18
  children: storyFn()
19
19
  })]
@@ -61,6 +61,7 @@ const UserMenuContent = () => {
61
61
  export const defaultHeader = () => /*#__PURE__*/_jsx(Header, {
62
62
  appName: "Powercorp directory",
63
63
  logo: dummyLogo,
64
+ showLogoSeparator: true,
64
65
  userName: "Michael Jenkins (michael.jenkins@powercorp.com)",
65
66
  avatarSource: "https://api.dicebear.com/7.x/personas/svg?seed=mike",
66
67
  avatarAlt: "Avatar for Michael",
@@ -7,7 +7,7 @@ import UserMenu from "./UserMenu";
7
7
  /**
8
8
  * Header component for top of app.
9
9
  **/
10
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  const Header = _ref => {
12
12
  let {
13
13
  appName,
@@ -19,19 +19,14 @@ const Header = _ref => {
19
19
  dataTestId,
20
20
  currentWorkspace,
21
21
  logo,
22
- userMenuContent
22
+ userMenuContent,
23
+ showLogoSeparator = false
23
24
  } = _ref;
24
25
  return /*#__PURE__*/_jsxs(Bar, {
25
26
  dataTestId: dataTestId,
26
27
  children: [/*#__PURE__*/_jsxs(AppName, {
27
- children: [logo && /*#__PURE__*/_jsxs(_Fragment, {
28
- children: [/*#__PURE__*/_jsx(Flex, {
29
- alignItems: "center",
30
- justifyContent: "center",
31
- children: logo
32
- }), /*#__PURE__*/_jsx(Separator, {
33
- display: ["none", "none", "none", "block"]
34
- })]
28
+ children: [logo, showLogoSeparator && /*#__PURE__*/_jsx(Separator, {
29
+ display: ["none", "none", "none", "block"]
35
30
  }), /*#__PURE__*/_jsxs(Flex, {
36
31
  flexDirection: "column",
37
32
  children: [appName && /*#__PURE__*/_jsx(FlexItem, {
@@ -81,7 +76,9 @@ Header.propTypes = {
81
76
  /** Allows for use of the `data-testid` attribute for testing. */
82
77
  dataTestId: PropTypes.string,
83
78
  /** Allows you to pass in child components to user dropdown menu */
84
- userMenuContent: PropTypes.node
79
+ userMenuContent: PropTypes.node,
80
+ /** use this to apply separator if logo and appName or currentWorkspace exists */
81
+ showLogoSeparator: PropTypes.bool
85
82
  };
86
83
 
87
84
  /** @component */
@@ -90,6 +87,17 @@ Header.__docgenInfo = {
90
87
  "methods": [],
91
88
  "displayName": "Header",
92
89
  "props": {
90
+ "showLogoSeparator": {
91
+ "defaultValue": {
92
+ "value": "false",
93
+ "computed": false
94
+ },
95
+ "description": "use this to apply separator if logo and appName or currentWorkspace exists",
96
+ "type": {
97
+ "name": "bool"
98
+ },
99
+ "required": false
100
+ },
93
101
  "logo": {
94
102
  "description": "Logo for app. Preferably an svg logo",
95
103
  "type": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orcs-design-system",
3
- "version": "3.3.7",
3
+ "version": "3.3.9",
4
4
  "engines": {
5
5
  "node": "20.12.2"
6
6
  },
@@ -99,7 +99,7 @@
99
99
  "@storybook/mdx1-csf": "^1.0.0",
100
100
  "@storybook/preset-create-react-app": "^8.3.3",
101
101
  "@storybook/react": "^8.1.7",
102
- "@storybook/react-webpack5": "^8.2.9",
102
+ "@storybook/react-webpack5": "^8.3.7",
103
103
  "@storybook/storybook-deployer": "2.8.16",
104
104
  "@storybook/theming": "^8.1.7",
105
105
  "@testing-library/jest-dom": "^5.11.6",
@@ -131,6 +131,7 @@
131
131
  "nodemon": "^3.1.0",
132
132
  "npm-run-all": "^4.1.5",
133
133
  "playroom": "^0.32.1",
134
+ "postcss": "8.5.2",
134
135
  "prettier": "^2.2.1",
135
136
  "react": "^18.3.1",
136
137
  "react-docgen": "^7.0.3",
@@ -149,7 +150,7 @@
149
150
  "jest": "$jest",
150
151
  "nth-check": "2.1.0",
151
152
  "parse-url": "8.1.0",
152
- "postcss": "^8.4.31",
153
+ "postcss": "8.5.2",
153
154
  "react-scripts": "5.0.1",
154
155
  "remark-parse": "10.0.2",
155
156
  "react": "^18.3.1",
@@ -158,7 +159,7 @@
158
159
  "webpack-dev-middleware": "6.1.2",
159
160
  "ws": "8.17.1",
160
161
  "express": {
161
- "path-to-regexp": "0.1.10"
162
+ "path-to-regexp": "0.1.12"
162
163
  },
163
164
  "send": "0.19.0",
164
165
  "redux": "4.2.1",