@dnanpm/styleguide 3.9.2 → 3.9.3

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.
@@ -17,6 +17,12 @@ interface Props {
17
17
  * @default 1.2 In Mobile view
18
18
  */
19
19
  visibleItems?: number;
20
+ /**
21
+ * Allows to display a slide counter
22
+ *
23
+ * @default false
24
+ */
25
+ hasCounter?: boolean;
20
26
  /**
21
27
  * Allows to define carousel title
22
28
  */
@@ -134,6 +134,12 @@ const FooterButton = styled.default.div `
134
134
  grid-column: footerButton;
135
135
  text-align: right;
136
136
  `;
137
+ const Counter = styled.default.span `
138
+ margin-top: 0.5rem;
139
+ font-size: ${theme.default.fontSize.s};
140
+ font-weight: ${theme.default.fontWeight.medium};
141
+ margin-right: 1rem;
142
+ `;
137
143
  /** @visibleName Carousel */
138
144
  const Carousel = (_a) => {
139
145
  var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
@@ -298,6 +304,10 @@ const Carousel = (_a) => {
298
304
  React__default.default.createElement(Header, { "data-testid": dataTestId && `${dataTestId}-header` },
299
305
  props.title && React__default.default.createElement(Title, null, props.title),
300
306
  React__default.default.createElement(Navigation, null,
307
+ props.hasCounter && (React__default.default.createElement(Counter, null,
308
+ slideScreensCount === 0 ? 0 : currentIndex + 1,
309
+ "/",
310
+ slideScreensCount)),
301
311
  React__default.default.createElement(ButtonArrow.default, { direction: "left", "aria-label": "Previous", onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0 }),
302
312
  React__default.default.createElement(ButtonArrow.default, { direction: "right", "aria-label": "Next", onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= React.Children.count(props.children) }))),
303
313
  React__default.default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
@@ -12,8 +12,6 @@ var common = require('../../utils/common.js');
12
12
  var styledUtils = require('../../utils/styledUtils.js');
13
13
  var Box = require('../Box/Box.js');
14
14
  var ButtonClose = require('../ButtonClose/ButtonClose.js');
15
- var Floater = require('../Floater/Floater.js');
16
- var Icon = require('../Icon/Icon.js');
17
15
 
18
16
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
19
17
 
@@ -52,10 +50,10 @@ const StyledReactModal = styled.default(ReactModal__default.default) `
52
50
  position: fixed;
53
51
  top: 0;
54
52
  ${({ side }) => (side === 'left' ? 'left: 0' : 'right: 0')};
55
- width: 100vw;
53
+ width: ${({ size }) => sizeMap[size]};
56
54
  height: 100dvh;
57
- max-width: 100vw;
58
55
  max-height: 100%;
56
+ max-width: calc(100vw - ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)});
59
57
  transform: translateX(${({ side }) => side === 'left' && '-'}100%);
60
58
  animation: ${slideIn} ${({ size }) => animationMap[size][0]}s forwards;
61
59
 
@@ -63,9 +61,10 @@ const StyledReactModal = styled.default(ReactModal__default.default) `
63
61
  animation: ${({ side }) => slideOut(side)} ${({ size }) => animationMap[size][1]}s forwards;
64
62
  }
65
63
 
66
- ${({ size }) => styledUtils.media.sm `
67
- width: ${sizeMap[size]};
68
- `};
64
+ @media (max-width: ${sizeMap.small}) {
65
+ max-width: 100vw;
66
+ width: 100vw;
67
+ }
69
68
  `;
70
69
  const StyledReactModalOverlay = styled.default.div `
71
70
  display: flex;
@@ -113,13 +112,16 @@ const StyledReactModalContent = styled.default.div `
113
112
  const StyledBox = styled.default(Box.default) `
114
113
  display: flex;
115
114
  flex-direction: column;
116
- justify-content: space-between;
117
115
  border-radius: 0;
118
116
  height: 100%;
119
- overflow-y: auto;
120
117
  position: relative;
121
- padding: 0;
122
- border: 0 none;
118
+ border: 0;
119
+ `;
120
+ const ContentContainer = styled.default.div `
121
+ flex: 1 1 auto;
122
+ overflow: auto;
123
+ display: flex;
124
+ flex-direction: column;
123
125
  `;
124
126
  const Header = styled.default.div `
125
127
  display: flex;
@@ -139,6 +141,7 @@ const Header = styled.default.div `
139
141
  `;
140
142
  const Title = styled.default.h2 `
141
143
  font-size: ${({ size }) => (size === 'small' ? theme.default.fontSize.h2S : theme.default.fontSize.h2M)};
144
+ line-height: ${({ size }) => (size === 'small' ? theme.default.lineHeight.h2S : theme.default.lineHeight.h2M)};
142
145
  color: ${({ variant }) => variant === 'light' ? theme.default.color.default.black : theme.default.color.default.white};
143
146
  `;
144
147
  const Subtitle = styled.default.p `
@@ -147,7 +150,7 @@ const Subtitle = styled.default.p `
147
150
  `;
148
151
  const CloseButton = styled.default(ButtonClose.default) `
149
152
  margin: 0;
150
- padding: 0.625rem;
153
+ padding: 0.5rem;
151
154
  border-radius: 0 0 0 ${theme.default.radius.default};
152
155
  background-color: ${({ variant }) => variant === 'light'
153
156
  ? theme.default.color.background.sand.E01
@@ -163,7 +166,6 @@ const Footer = styled.default.div `
163
166
  width: 100%;
164
167
  border-top: 1px solid ${theme.default.color.line.L04};
165
168
  background-color: ${theme.default.color.background.white.default};
166
-
167
169
  ${common.default({ elevation: 'high', shadow: '1 0 0 0' })};
168
170
  `;
169
171
  const ModalOverlay = ({ ref, onClick, onMouseDown, className }, contentElement) => (React__default.default.createElement(StyledReactModalOverlay, { ref: ref, onClick: onClick, onMouseDown: onMouseDown, className: className }, contentElement));
@@ -176,18 +178,17 @@ const Drawer = (_a) => {
176
178
  ReactModal__default.default.setAppElement(appElement);
177
179
  return (React__default.default.createElement(React__default.default.Fragment, null,
178
180
  React__default.default.createElement(StyledReactModal, { id: props.id, isOpen: props.isOpen, overlayElement: ModalOverlay, contentElement: ModalContent, onRequestClose: props.onRequestClose, portalClassName: props.className, contentLabel: props.contentLabel, shouldCloseOnEsc: isClosable, shouldCloseOnOverlayClick: isClosable, closeTimeoutMS: 300, size: size, side: side },
179
- React__default.default.createElement(StyledBox, { elevation: "extraHigh", margin: props.margin, "data-testid": dataTestId },
180
- React__default.default.createElement("div", null,
181
- React__default.default.createElement(Floater.default, null, closeButton && isClosable && (React__default.default.createElement(CloseButton, { onClick: props.onRequestClose, "aria-label": props.closeLabel, "data-testid": dataTestId && `${dataTestId}-close-button`, variant: variant },
182
- React__default.default.createElement(Icon.default, { icon: icons.Close, color: variant === 'light'
183
- ? theme.default.color.default.plum
184
- : theme.default.color.default.white })))),
181
+ React__default.default.createElement(StyledBox, { "data-testid": dataTestId, elevation: "extraHigh", margin: props.margin, padding: "0" },
182
+ React__default.default.createElement(ContentContainer, null,
185
183
  React__default.default.createElement(Header, { variant: variant, "data-testid": dataTestId && `${dataTestId}-header` },
186
184
  React__default.default.createElement(Title, { size: size, variant: variant }, props.title),
187
185
  props.subtitle && (React__default.default.createElement(Subtitle, { size: size, variant: variant }, props.subtitle))),
186
+ closeButton && isClosable && (React__default.default.createElement(CloseButton, { onClick: props.onRequestClose, "aria-label": props.closeLabel, "data-testid": dataTestId && `${dataTestId}-close-button`, variant: variant },
187
+ React__default.default.createElement(icons.Close, { color: variant === 'light'
188
+ ? theme.default.color.default.plum
189
+ : theme.default.color.default.white }))),
188
190
  React__default.default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content`, padding: padding }, props.children)),
189
- props.footer && (React__default.default.createElement(Floater.default, { position: "bottom" },
190
- React__default.default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` }, props.footer))))),
191
+ props.footer && (React__default.default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` }, props.footer)))),
191
192
  React__default.default.createElement(GlobalStyle, null)));
192
193
  };
193
194
 
@@ -17,6 +17,12 @@ interface Props {
17
17
  * @default 1.2 In Mobile view
18
18
  */
19
19
  visibleItems?: number;
20
+ /**
21
+ * Allows to display a slide counter
22
+ *
23
+ * @default false
24
+ */
25
+ hasCounter?: boolean;
20
26
  /**
21
27
  * Allows to define carousel title
22
28
  */
@@ -126,6 +126,12 @@ const FooterButton = styled.div `
126
126
  grid-column: footerButton;
127
127
  text-align: right;
128
128
  `;
129
+ const Counter = styled.span `
130
+ margin-top: 0.5rem;
131
+ font-size: ${theme.fontSize.s};
132
+ font-weight: ${theme.fontWeight.medium};
133
+ margin-right: 1rem;
134
+ `;
129
135
  /** @visibleName Carousel */
130
136
  const Carousel = (_a) => {
131
137
  var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
@@ -290,6 +296,10 @@ const Carousel = (_a) => {
290
296
  React__default.createElement(Header, { "data-testid": dataTestId && `${dataTestId}-header` },
291
297
  props.title && React__default.createElement(Title, null, props.title),
292
298
  React__default.createElement(Navigation, null,
299
+ props.hasCounter && (React__default.createElement(Counter, null,
300
+ slideScreensCount === 0 ? 0 : currentIndex + 1,
301
+ "/",
302
+ slideScreensCount)),
293
303
  React__default.createElement(ButtonArrow, { direction: "left", "aria-label": "Previous", onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0 }),
294
304
  React__default.createElement(ButtonArrow, { direction: "right", "aria-label": "Next", onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= Children.count(props.children) }))),
295
305
  React__default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
@@ -5,11 +5,9 @@ import ReactModal from 'react-modal';
5
5
  import styled, { createGlobalStyle, keyframes } from '../../themes/styled.js';
6
6
  import theme from '../../themes/theme.js';
7
7
  import getElevationShadow from '../../utils/common.js';
8
- import { media } from '../../utils/styledUtils.js';
8
+ import { getMultipliedSize } from '../../utils/styledUtils.js';
9
9
  import Box from '../Box/Box.js';
10
10
  import ButtonClose from '../ButtonClose/ButtonClose.js';
11
- import Floater from '../Floater/Floater.js';
12
- import Icon from '../Icon/Icon.js';
13
11
 
14
12
  const sizeMap = {
15
13
  small: '375px',
@@ -43,10 +41,10 @@ const StyledReactModal = styled(ReactModal) `
43
41
  position: fixed;
44
42
  top: 0;
45
43
  ${({ side }) => (side === 'left' ? 'left: 0' : 'right: 0')};
46
- width: 100vw;
44
+ width: ${({ size }) => sizeMap[size]};
47
45
  height: 100dvh;
48
- max-width: 100vw;
49
46
  max-height: 100%;
47
+ max-width: calc(100vw - ${getMultipliedSize(theme.base.baseWidth, 4)});
50
48
  transform: translateX(${({ side }) => side === 'left' && '-'}100%);
51
49
  animation: ${slideIn} ${({ size }) => animationMap[size][0]}s forwards;
52
50
 
@@ -54,9 +52,10 @@ const StyledReactModal = styled(ReactModal) `
54
52
  animation: ${({ side }) => slideOut(side)} ${({ size }) => animationMap[size][1]}s forwards;
55
53
  }
56
54
 
57
- ${({ size }) => media.sm `
58
- width: ${sizeMap[size]};
59
- `};
55
+ @media (max-width: ${sizeMap.small}) {
56
+ max-width: 100vw;
57
+ width: 100vw;
58
+ }
60
59
  `;
61
60
  const StyledReactModalOverlay = styled.div `
62
61
  display: flex;
@@ -104,13 +103,16 @@ const StyledReactModalContent = styled.div `
104
103
  const StyledBox = styled(Box) `
105
104
  display: flex;
106
105
  flex-direction: column;
107
- justify-content: space-between;
108
106
  border-radius: 0;
109
107
  height: 100%;
110
- overflow-y: auto;
111
108
  position: relative;
112
- padding: 0;
113
- border: 0 none;
109
+ border: 0;
110
+ `;
111
+ const ContentContainer = styled.div `
112
+ flex: 1 1 auto;
113
+ overflow: auto;
114
+ display: flex;
115
+ flex-direction: column;
114
116
  `;
115
117
  const Header = styled.div `
116
118
  display: flex;
@@ -130,6 +132,7 @@ const Header = styled.div `
130
132
  `;
131
133
  const Title = styled.h2 `
132
134
  font-size: ${({ size }) => (size === 'small' ? theme.fontSize.h2S : theme.fontSize.h2M)};
135
+ line-height: ${({ size }) => (size === 'small' ? theme.lineHeight.h2S : theme.lineHeight.h2M)};
133
136
  color: ${({ variant }) => variant === 'light' ? theme.color.default.black : theme.color.default.white};
134
137
  `;
135
138
  const Subtitle = styled.p `
@@ -138,7 +141,7 @@ const Subtitle = styled.p `
138
141
  `;
139
142
  const CloseButton = styled(ButtonClose) `
140
143
  margin: 0;
141
- padding: 0.625rem;
144
+ padding: 0.5rem;
142
145
  border-radius: 0 0 0 ${theme.radius.default};
143
146
  background-color: ${({ variant }) => variant === 'light'
144
147
  ? theme.color.background.sand.E01
@@ -154,7 +157,6 @@ const Footer = styled.div `
154
157
  width: 100%;
155
158
  border-top: 1px solid ${theme.color.line.L04};
156
159
  background-color: ${theme.color.background.white.default};
157
-
158
160
  ${getElevationShadow({ elevation: 'high', shadow: '1 0 0 0' })};
159
161
  `;
160
162
  const ModalOverlay = ({ ref, onClick, onMouseDown, className }, contentElement) => (React__default.createElement(StyledReactModalOverlay, { ref: ref, onClick: onClick, onMouseDown: onMouseDown, className: className }, contentElement));
@@ -167,18 +169,17 @@ const Drawer = (_a) => {
167
169
  ReactModal.setAppElement(appElement);
168
170
  return (React__default.createElement(React__default.Fragment, null,
169
171
  React__default.createElement(StyledReactModal, { id: props.id, isOpen: props.isOpen, overlayElement: ModalOverlay, contentElement: ModalContent, onRequestClose: props.onRequestClose, portalClassName: props.className, contentLabel: props.contentLabel, shouldCloseOnEsc: isClosable, shouldCloseOnOverlayClick: isClosable, closeTimeoutMS: 300, size: size, side: side },
170
- React__default.createElement(StyledBox, { elevation: "extraHigh", margin: props.margin, "data-testid": dataTestId },
171
- React__default.createElement("div", null,
172
- React__default.createElement(Floater, null, closeButton && isClosable && (React__default.createElement(CloseButton, { onClick: props.onRequestClose, "aria-label": props.closeLabel, "data-testid": dataTestId && `${dataTestId}-close-button`, variant: variant },
173
- React__default.createElement(Icon, { icon: Close, color: variant === 'light'
174
- ? theme.color.default.plum
175
- : theme.color.default.white })))),
172
+ React__default.createElement(StyledBox, { "data-testid": dataTestId, elevation: "extraHigh", margin: props.margin, padding: "0" },
173
+ React__default.createElement(ContentContainer, null,
176
174
  React__default.createElement(Header, { variant: variant, "data-testid": dataTestId && `${dataTestId}-header` },
177
175
  React__default.createElement(Title, { size: size, variant: variant }, props.title),
178
176
  props.subtitle && (React__default.createElement(Subtitle, { size: size, variant: variant }, props.subtitle))),
177
+ closeButton && isClosable && (React__default.createElement(CloseButton, { onClick: props.onRequestClose, "aria-label": props.closeLabel, "data-testid": dataTestId && `${dataTestId}-close-button`, variant: variant },
178
+ React__default.createElement(Close, { color: variant === 'light'
179
+ ? theme.color.default.plum
180
+ : theme.color.default.white }))),
179
181
  React__default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content`, padding: padding }, props.children)),
180
- props.footer && (React__default.createElement(Floater, { position: "bottom" },
181
- React__default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` }, props.footer))))),
182
+ props.footer && (React__default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` }, props.footer)))),
182
183
  React__default.createElement(GlobalStyle, null)));
183
184
  };
184
185
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dnanpm/styleguide",
3
3
  "sideEffects": false,
4
- "version": "v3.9.2",
4
+ "version": "v3.9.3",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/es/index.js",
7
7
  "jsnext:main": "build/es/index.js",