akeneo-design-system 0.1.227 → 0.1.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/lib/components/Avatar/Avatar.d.ts +1 -8
  2. package/lib/components/Avatar/Avatar.js +1 -1
  3. package/lib/components/Avatar/Avatar.js.map +1 -1
  4. package/lib/components/Avatar/Avatars.d.ts +2 -1
  5. package/lib/components/Avatar/Avatars.js +19 -3
  6. package/lib/components/Avatar/Avatars.js.map +1 -1
  7. package/lib/components/Avatar/types.d.ts +11 -0
  8. package/lib/components/Avatar/types.js +3 -0
  9. package/lib/components/Avatar/types.js.map +1 -0
  10. package/lib/components/Dropdown/Dropdown.d.ts +1 -0
  11. package/lib/components/Dropdown/Item/Item.js +1 -1
  12. package/lib/components/Dropdown/Item/Item.js.map +1 -1
  13. package/lib/components/Dropdown/Surtitle/Surtitle.d.ts +1 -0
  14. package/lib/components/Input/MultiSelectInput/ChipInput.d.ts +1 -0
  15. package/lib/components/Input/MultiSelectInput/ChipInput.js +9 -7
  16. package/lib/components/Input/MultiSelectInput/ChipInput.js.map +1 -1
  17. package/lib/components/Input/MultiSelectInput/MultiSelectInput.d.ts +2 -1
  18. package/lib/components/Input/MultiSelectInput/MultiSelectInput.js +4 -4
  19. package/lib/components/Input/MultiSelectInput/MultiSelectInput.js.map +1 -1
  20. package/lib/components/KeyFigure/KeyFigure.js +1 -1
  21. package/lib/components/KeyFigure/KeyFigure.js.map +1 -1
  22. package/lib/components/Navigation/SubNavigationPanel/SubNavigationPanel.d.ts +2 -0
  23. package/lib/components/Navigation/SubNavigationPanel/SubNavigationPanel.js +28 -40
  24. package/lib/components/Navigation/SubNavigationPanel/SubNavigationPanel.js.map +1 -1
  25. package/lib/components/ProgressBar/ProgressBar.js +3 -3
  26. package/lib/components/ProgressBar/ProgressBar.js.map +1 -1
  27. package/lib/components/Tooltip/Tooltip.d.ts +4 -1
  28. package/lib/components/Tooltip/Tooltip.js +3 -1
  29. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-inputs-multi-select-input-locked-values-correctly-1-snap.png +0 -0
  32. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-navigation-sub-navigation-panel-content-with-collapse-component-correctly-1-snap.png +0 -0
  33. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-navigation-sub-navigation-panel-content-without-padding-correctly-1-snap.png +0 -0
  34. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-navigation-sub-navigation-panel-scrollable-content-correctly-1-snap.png +0 -0
  35. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-progress-bar-width-correctly-1-snap.png +0 -0
  36. package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-tooltip-with-title-correctly-1-snap.png +0 -0
  37. package/src/components/Avatar/Avatar.stories.mdx +1 -1
  38. package/src/components/Avatar/Avatar.tsx +2 -32
  39. package/src/components/Avatar/Avatars.tsx +27 -5
  40. package/src/components/Avatar/Avatars.unit.tsx +22 -2
  41. package/src/components/Avatar/types.ts +34 -0
  42. package/src/components/Dropdown/Item/Item.tsx +1 -0
  43. package/src/components/Dropdown/Surtitle/Surtitle.tsx +1 -1
  44. package/src/components/Input/MultiSelectInput/ChipInput.tsx +14 -4
  45. package/src/components/Input/MultiSelectInput/MultiSelectInput.stories.mdx +24 -0
  46. package/src/components/Input/MultiSelectInput/MultiSelectInput.tsx +7 -0
  47. package/src/components/Input/MultiSelectInput/MultiSelectInput.unit.tsx +20 -0
  48. package/src/components/KeyFigure/KeyFigure.stories.mdx +5 -1
  49. package/src/components/KeyFigure/KeyFigure.tsx +2 -0
  50. package/src/components/Navigation/SubNavigationPanel/SubNavigationPanel.stories.mdx +97 -25
  51. package/src/components/Navigation/SubNavigationPanel/SubNavigationPanel.tsx +58 -66
  52. package/src/components/Navigation/SubNavigationPanel/SubNavigationPanel.unit.tsx +3 -3
  53. package/src/components/ProgressBar/ProgressBar.tsx +1 -17
  54. package/src/components/Tooltip/Tooltip.stories.mdx +15 -0
  55. package/src/components/Tooltip/Tooltip.tsx +9 -1
@@ -1,54 +1,42 @@
1
- import React, {ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes} from 'react';
2
- import styled, {css} from 'styled-components';
1
+ import React, {ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, useLayoutEffect} from 'react';
2
+ import styled from 'styled-components';
3
3
  import {PanelCloseIcon, PanelOpenIcon} from '../../../icons';
4
4
  import {AkeneoThemedProps, getColor} from '../../../theme';
5
5
 
6
- const collapsableStyles = css<{isOpen: boolean} & AkeneoThemedProps>`
7
- opacity: ${({isOpen}) => (isOpen ? 1 : 0)};
8
- transition: opacity 0.3s;
9
- transition-delay: 0.3s;
10
-
11
- position: relative;
12
- z-index: 1;
13
- ${({isOpen}) =>
14
- !isOpen &&
15
- css`
16
- position: absolute;
17
- z-index: 0;
18
- `}
19
- `;
20
- const Panel = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
6
+ const Container = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
7
+ background-color: ${getColor('grey', 20)};
8
+ border-right: 1px solid ${getColor('grey', 80)};
9
+ box-sizing: border-box;
21
10
  display: flex;
22
11
  flex-direction: column;
23
- height: calc(100% - 54px);
24
- width: 100%;
25
- position: absolute;
26
- overflow-y: ${({isOpen}) => (isOpen ? 'auto' : 'hidden')};
27
- overflow-x: hidden;
12
+ height: 100%;
13
+ transition: width 0.3s linear;
14
+ width: ${({isOpen}) => (isOpen ? '280px' : '40px')};
28
15
  `;
29
16
 
30
- const PanelContent = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
31
- box-sizing: border-box;
17
+ const Content = styled.div<{isOpen: boolean; noPadding: boolean}>`
18
+ display: flex;
19
+ flex-direction: column;
32
20
  flex-grow: 1;
33
- width: 100%;
34
- padding: ${({isOpen}) => (isOpen ? '30px' : '10px 5px')};
35
- ${collapsableStyles}
21
+ overflow-x: hidden;
22
+ overflow-y: auto;
23
+ opacity: ${({isOpen}) => (isOpen ? '1' : '0')};
24
+ transition: ${({isOpen}) => (isOpen ? 'opacity 300ms linear 300ms' : 'none')};
25
+ padding: ${({noPadding}) => (noPadding ? '0' : '30px')};
36
26
  `;
37
27
 
38
- const ToggleButton = styled.button<{isOpen: boolean} & AkeneoThemedProps>`
28
+ const ToggleButton = styled.button<AkeneoThemedProps>`
39
29
  align-items: center;
40
30
  background: none;
41
31
  border: none;
42
32
  border-top: 1px solid ${getColor('grey', 80)};
33
+ box-sizing: border-box;
43
34
  cursor: pointer;
35
+ display: flex;
36
+ flex: 0 0 auto;
44
37
  height: 54px;
45
- margin: ${({isOpen}) => (isOpen ? '0 20px' : '0')};
46
- padding: ${({isOpen}) => (isOpen ? '0' : '0 12.5px')};
47
- transition: margin 0.3s ease-in-out, padding 0.3s ease-in-out;
48
- text-align: left;
49
- position: absolute;
50
- bottom: 0;
51
- width: ${({isOpen}) => (isOpen ? '240px' : '40px')};
38
+ padding: 0;
39
+ padding-left: 12.5px;
52
40
 
53
41
  svg {
54
42
  color: ${getColor('grey', 100)};
@@ -56,30 +44,10 @@ const ToggleButton = styled.button<{isOpen: boolean} & AkeneoThemedProps>`
56
44
  }
57
45
  `;
58
46
 
59
- const Container = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
60
- width: ${({isOpen}) => (isOpen ? '280px' : '40px')};
61
- transition: width 0.3s linear;
62
- position: relative;
63
- order: -10;
64
- background-color: ${getColor('grey', 20)};
65
- border-right: 1px solid ${getColor('grey', 80)};
66
- flex-shrink: 0;
67
- height: 100%;
68
- z-index: 802;
69
- overflow: hidden;
70
- `;
71
-
72
- const Collapsed = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
73
- flex-grow: 1;
47
+ const Collapsed = styled.div`
74
48
  padding: 10px 5px;
75
- ${collapsableStyles}
76
49
  `;
77
50
 
78
- Collapsed.displayName = 'Collapsed';
79
- Collapsed.defaultProps = {
80
- isOpen: false,
81
- };
82
-
83
51
  type SubNavigationPanelProps = {
84
52
  /**
85
53
  * The content of the panel.
@@ -110,12 +78,18 @@ type SubNavigationPanelProps = {
110
78
  * Opening title to display for the ToggleButton
111
79
  */
112
80
  openTitle?: string;
81
+
82
+ /**
83
+ * Whether or not the panel should have padding.
84
+ */
85
+ noPadding?: boolean;
113
86
  };
114
87
 
115
88
  type SubNavigationPanelCompoundType = ForwardRefExoticComponent<
116
89
  PropsWithoutRef<SubNavigationPanelProps> & RefAttributes<HTMLDivElement>
117
90
  > & {
118
91
  Collapsed?: any;
92
+ Section?: any;
119
93
  };
120
94
 
121
95
  /**
@@ -123,25 +97,40 @@ type SubNavigationPanelCompoundType = ForwardRefExoticComponent<
123
97
  */
124
98
  const SubNavigationPanel: SubNavigationPanelCompoundType = React.forwardRef<HTMLDivElement, SubNavigationPanelProps>(
125
99
  (
126
- {children, isOpen: isOpen = true, open, close, closeTitle = '', openTitle = '', ...rest}: SubNavigationPanelProps,
100
+ {
101
+ children,
102
+ isOpen = true,
103
+ open,
104
+ close,
105
+ closeTitle = '',
106
+ openTitle = '',
107
+ noPadding = false,
108
+ ...rest
109
+ }: SubNavigationPanelProps,
127
110
  forwardedRef: React.Ref<HTMLDivElement>
128
111
  ) => {
129
- const contentChildren: ReactNode[] = [];
130
- let collapsedContent: ReactNode | null = null;
112
+ const collapsedElements: React.ReactNode[] = [];
113
+ const contentElements: React.ReactNode[] = [];
114
+
131
115
  React.Children.forEach(children, child => {
132
116
  if (React.isValidElement(child) && child.type === Collapsed) {
133
- collapsedContent = React.cloneElement(child, {isOpen: !isOpen});
134
- return;
117
+ collapsedElements.push(child);
118
+ } else {
119
+ contentElements.push(child);
135
120
  }
136
- contentChildren.push(child);
137
121
  });
138
122
 
123
+ const [isOpenTransition, setIsOpenTransition] = React.useState<boolean>(isOpen);
124
+ useLayoutEffect(() => {
125
+ setIsOpenTransition(isOpen);
126
+ }, [isOpen]);
127
+
139
128
  return (
140
129
  <Container ref={forwardedRef} isOpen={isOpen} {...rest}>
141
- <Panel isOpen={isOpen}>
142
- {collapsedContent}
143
- <PanelContent isOpen={isOpen}>{isOpen && contentChildren}</PanelContent>
144
- </Panel>
130
+ {!isOpen && collapsedElements}
131
+ <Content isOpen={isOpenTransition} noPadding={noPadding}>
132
+ {isOpen && contentElements}
133
+ </Content>
145
134
  <ToggleButton
146
135
  isOpen={isOpen}
147
136
  onClick={() => (isOpen ? close() : open())}
@@ -155,6 +144,9 @@ const SubNavigationPanel: SubNavigationPanelCompoundType = React.forwardRef<HTML
155
144
  }
156
145
  );
157
146
 
147
+ SubNavigationPanel.displayName = 'SubNavigationPanel';
148
+ Collapsed.displayName = 'SubNavigationPanel.Collapsed';
149
+
158
150
  SubNavigationPanel.Collapsed = Collapsed;
159
151
 
160
152
  export {SubNavigationPanel};
@@ -76,7 +76,7 @@ test('it shows collapsed content', () => {
76
76
  );
77
77
 
78
78
  expect(queryByText('SubNavigationPanel content')).not.toBeInTheDocument();
79
- expect(getByText('Collapsed content')).toBeVisible();
79
+ expect(getByText('Collapsed content')).toBeInTheDocument();
80
80
  });
81
81
 
82
82
  test('it hides collapsed content', () => {
@@ -89,6 +89,6 @@ test('it hides collapsed content', () => {
89
89
  </SubNavigationPanel>
90
90
  );
91
91
 
92
- expect(queryByText('SubNavigationPanel content')).toBeInTheDocument();
93
- expect(getByText('Collapsed content')).not.toBeVisible();
92
+ expect(getByText('SubNavigationPanel content')).toBeInTheDocument();
93
+ expect(queryByText('Collapsed content')).not.toBeInTheDocument();
94
94
  });
@@ -14,11 +14,8 @@ const progressBarAnimation = keyframes`
14
14
 
15
15
  const Header = styled.div`
16
16
  display: flex;
17
- align-items: stretch;
18
- flex-direction: row;
19
17
  font-size: ${getFontSize('default')};
20
- flex-flow: row wrap;
21
- margin-bottom: -4px;
18
+ justify-content: space-between;
22
19
  `;
23
20
 
24
21
  const Title = styled.div`
@@ -27,24 +24,11 @@ const Title = styled.div`
27
24
  white-space: nowrap;
28
25
  overflow: hidden;
29
26
  text-overflow: ellipsis;
30
- max-width: 100%;
31
- flex-grow: 1;
32
- margin-bottom: 4px;
33
-
34
- /* When header div is greater than 300px the flex-basic is negative, progress label is on same line */
35
- /* When header div is lower than 300px the flex-basic is positive, progress label is move to new line */
36
- flex-basis: calc((301px - 100%) * 999);
37
27
  `;
38
28
 
39
29
  const ProgressLabel = styled.div`
40
30
  color: ${getColor('grey', 120)};
41
- flex-grow: 0;
42
- flex-basis: auto;
43
- flex-shrink: 1;
44
- margin-bottom: 4px;
45
31
  white-space: nowrap;
46
- overflow: hidden;
47
- text-overflow: ellipsis;
48
32
  `;
49
33
 
50
34
  const ProgressBarBackground = styled.div<{size: ProgressBarSize} & AkeneoThemedProps>`
@@ -43,3 +43,18 @@ It's a complementary information that will help the user better understand what
43
43
  </Canvas>
44
44
 
45
45
  <ArgsTable story="Standard" />
46
+
47
+ ## With a title
48
+
49
+ <Canvas>
50
+ <Story name="With title">
51
+ {args => {
52
+ return (
53
+ <Tooltip>
54
+ <Tooltip.Title>My wonderful title</Tooltip.Title>
55
+ The rest of the amazing content
56
+ </Tooltip>
57
+ );
58
+ }}
59
+ </Story>
60
+ </Canvas>
@@ -40,6 +40,12 @@ const TooltipContent = styled.div<{direction: Direction; width: number; top: num
40
40
  opacity: ${({top, left}) => (-1 === top && -1 === left ? 0 : 1)};
41
41
  `;
42
42
 
43
+ const TooltipTitle = styled.div`
44
+ color: ${getColor('blue', 120)};
45
+ font-weight: 700;
46
+ margin-bottom: 5px;
47
+ `;
48
+
43
49
  const computePosition = (
44
50
  direction: Direction,
45
51
  parentRef?: RefObject<HTMLDivElement>,
@@ -104,7 +110,7 @@ export type TooltipProps = Override<
104
110
  }
105
111
  >;
106
112
 
107
- const Tooltip: React.FC<TooltipProps> = ({direction = 'top', iconSize = 24, width = 200, children, ...rest}) => {
113
+ const Tooltip = ({direction = 'top', iconSize = 24, width = 200, children, ...rest}: TooltipProps) => {
108
114
  const [isVisible, showTooltip, hideTooltip] = useBooleanState(false);
109
115
  const portalNode = document.createElement('div');
110
116
  portalNode.setAttribute('id', 'tooltip-root');
@@ -148,4 +154,6 @@ const Tooltip: React.FC<TooltipProps> = ({direction = 'top', iconSize = 24, widt
148
154
  );
149
155
  };
150
156
 
157
+ Tooltip.Title = TooltipTitle;
158
+
151
159
  export {Tooltip};