@dnanpm/styleguide 1.7.0 → 1.9.0

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 (125) hide show
  1. package/build/cjs/components/Accordion/Accordion.d.ts +38 -0
  2. package/build/cjs/components/Accordion/Accordion.js +35 -0
  3. package/build/cjs/components/Accordion/AccordionItem.d.ts +45 -0
  4. package/build/cjs/components/Accordion/AccordionItem.js +100 -0
  5. package/build/cjs/components/Accordion/index.d.ts +2 -0
  6. package/build/cjs/components/AmountSelector/AmountSelector.d.ts +66 -0
  7. package/build/cjs/components/AmountSelector/AmountSelector.js +84 -0
  8. package/build/cjs/components/Card/Card.js +1 -2
  9. package/build/cjs/components/Card/CardRow.js +0 -1
  10. package/build/cjs/components/Checkbox/Checkbox.d.ts +1 -0
  11. package/build/cjs/components/Checkbox/Checkbox.js +7 -2
  12. package/build/cjs/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
  13. package/build/cjs/components/Footer/{index.js → Footer.js} +3 -2
  14. package/build/cjs/components/Footer/context/FooterContext.d.ts +1 -1
  15. package/build/{es/components/Helper/index.d.ts → cjs/components/Helper/Helper.d.ts} +1 -1
  16. package/build/cjs/components/Helper/{index.js → Helper.js} +0 -0
  17. package/build/cjs/components/Icon/Icons.d.ts +1 -0
  18. package/build/cjs/components/Icon/Icons.js +3 -0
  19. package/build/cjs/components/Image/{index.d.ts → Image.d.ts} +0 -0
  20. package/build/cjs/components/Image/{index.js → Image.js} +0 -0
  21. package/build/cjs/components/Input/Input.js +4 -4
  22. package/build/cjs/components/LabelText/LabelText.d.ts +2 -2
  23. package/build/cjs/components/LabelText/LabelText.js +1 -1
  24. package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
  25. package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
  26. package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
  27. package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
  28. package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +6 -6
  29. package/build/cjs/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
  30. package/build/cjs/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
  31. package/build/cjs/components/Notification/Notification.d.ts +40 -17
  32. package/build/cjs/components/Notification/Notification.js +28 -48
  33. package/build/cjs/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
  34. package/build/cjs/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
  35. package/build/cjs/components/PixelLoader/PixelLoader.d.ts +1 -1
  36. package/build/cjs/components/PixelLoader/PixelLoader.js +1 -1
  37. package/build/cjs/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
  38. package/build/cjs/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
  39. package/build/cjs/components/RadioButton/RadioButton.d.ts +1 -1
  40. package/build/cjs/components/RadioButton/RadioButton.js +1 -1
  41. package/build/{es/components/ReadMore/index.d.ts → cjs/components/ReadMore/ReadMore.d.ts} +1 -1
  42. package/build/cjs/components/ReadMore/{index.js → ReadMore.js} +1 -1
  43. package/build/cjs/components/Ribbon/Ribbon.d.ts +57 -0
  44. package/build/cjs/components/Ribbon/Ribbon.js +80 -0
  45. package/build/cjs/components/Search/Search.d.ts +44 -5
  46. package/build/cjs/components/Search/Search.js +3 -3
  47. package/build/cjs/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
  48. package/build/cjs/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
  49. package/build/cjs/components/Selectbox/Selectbox.d.ts +8 -4
  50. package/build/cjs/components/Selectbox/Selectbox.js +8 -8
  51. package/build/cjs/components/Textarea/Textarea.d.ts +25 -0
  52. package/build/cjs/components/Textarea/Textarea.js +83 -0
  53. package/build/{es/components/Tooltip/index.d.ts → cjs/components/Tooltip/Tooltip.d.ts} +2 -1
  54. package/build/cjs/components/Tooltip/{index.js → Tooltip.js} +0 -1
  55. package/build/cjs/components/index.d.ts +14 -10
  56. package/build/cjs/hooks/useDebounceFunc.d.ts +1 -0
  57. package/build/cjs/hooks/useDebounceFunc.js +19 -0
  58. package/build/cjs/hooks/useDocHeight.d.ts +1 -0
  59. package/build/cjs/hooks/useDocHeight.js +25 -0
  60. package/build/cjs/hooks/useElementDimensions.d.ts +5 -0
  61. package/build/cjs/hooks/useElementDimensions.js +37 -0
  62. package/build/cjs/index.js +28 -18
  63. package/build/es/components/Accordion/Accordion.d.ts +38 -0
  64. package/build/es/components/Accordion/Accordion.js +27 -0
  65. package/build/es/components/Accordion/AccordionItem.d.ts +45 -0
  66. package/build/es/components/Accordion/AccordionItem.js +91 -0
  67. package/build/es/components/Accordion/index.d.ts +2 -0
  68. package/build/es/components/AmountSelector/AmountSelector.d.ts +66 -0
  69. package/build/es/components/AmountSelector/AmountSelector.js +76 -0
  70. package/build/es/components/Card/Card.js +1 -2
  71. package/build/es/components/Card/CardRow.js +0 -1
  72. package/build/es/components/Checkbox/Checkbox.d.ts +1 -0
  73. package/build/es/components/Checkbox/Checkbox.js +7 -2
  74. package/build/es/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
  75. package/build/es/components/Footer/{index.js → Footer.js} +3 -2
  76. package/build/es/components/Footer/context/FooterContext.d.ts +1 -1
  77. package/build/{cjs/components/Helper/index.d.ts → es/components/Helper/Helper.d.ts} +1 -1
  78. package/build/es/components/Helper/{index.js → Helper.js} +0 -0
  79. package/build/es/components/Icon/Icons.d.ts +1 -0
  80. package/build/es/components/Icon/Icons.js +3 -1
  81. package/build/es/components/Image/{index.d.ts → Image.d.ts} +0 -0
  82. package/build/es/components/Image/{index.js → Image.js} +0 -0
  83. package/build/es/components/Input/Input.js +4 -4
  84. package/build/es/components/LabelText/LabelText.d.ts +2 -2
  85. package/build/es/components/LabelText/LabelText.js +1 -1
  86. package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
  87. package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
  88. package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
  89. package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
  90. package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +5 -5
  91. package/build/es/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
  92. package/build/es/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
  93. package/build/es/components/Notification/Notification.d.ts +40 -17
  94. package/build/es/components/Notification/Notification.js +28 -48
  95. package/build/es/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
  96. package/build/es/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
  97. package/build/es/components/PixelLoader/PixelLoader.d.ts +1 -1
  98. package/build/es/components/PixelLoader/PixelLoader.js +1 -1
  99. package/build/es/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
  100. package/build/es/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
  101. package/build/es/components/RadioButton/RadioButton.d.ts +1 -1
  102. package/build/es/components/RadioButton/RadioButton.js +1 -1
  103. package/build/{cjs/components/ReadMore/index.d.ts → es/components/ReadMore/ReadMore.d.ts} +1 -1
  104. package/build/es/components/ReadMore/{index.js → ReadMore.js} +1 -1
  105. package/build/es/components/Ribbon/Ribbon.d.ts +57 -0
  106. package/build/es/components/Ribbon/Ribbon.js +71 -0
  107. package/build/es/components/Search/Search.d.ts +44 -5
  108. package/build/es/components/Search/Search.js +3 -3
  109. package/build/es/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
  110. package/build/es/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
  111. package/build/es/components/Selectbox/Selectbox.d.ts +8 -4
  112. package/build/es/components/Selectbox/Selectbox.js +8 -8
  113. package/build/es/components/Textarea/Textarea.d.ts +25 -0
  114. package/build/es/components/Textarea/Textarea.js +75 -0
  115. package/build/{cjs/components/Tooltip/index.d.ts → es/components/Tooltip/Tooltip.d.ts} +2 -1
  116. package/build/es/components/Tooltip/{index.js → Tooltip.js} +0 -1
  117. package/build/es/components/index.d.ts +14 -10
  118. package/build/es/hooks/useDebounceFunc.d.ts +1 -0
  119. package/build/es/hooks/useDebounceFunc.js +15 -0
  120. package/build/es/hooks/useDocHeight.d.ts +1 -0
  121. package/build/es/hooks/useDocHeight.js +21 -0
  122. package/build/es/hooks/useElementDimensions.d.ts +5 -0
  123. package/build/es/hooks/useElementDimensions.js +33 -0
  124. package/build/es/index.js +14 -9
  125. package/package.json +1 -1
@@ -6,6 +6,7 @@ import colors from '../../../themes/themeComponents/colors.js';
6
6
  import { mobileNavMaxHeight, ribbonHeight, desktopNavMaxHeight } from '../../../themes/themeComponents/navigation.js';
7
7
  import { media } from '../../../utils/styledUtils.js';
8
8
  import NavContext from '../context/NavContext.js';
9
+ import { useDocHeight } from '../../../hooks/useDocHeight.js';
9
10
 
10
11
  const Selector = styled.div `
11
12
  color: ${p => (p.showDropdown ? p.activeColor : p.color)};
@@ -19,7 +20,7 @@ const Tooltip = styled.div `
19
20
  background-color: ${p => p.theme.color.white};
20
21
  min-height: 3rem;
21
22
  overflow-y: ${({ overflowY }) => (overflowY ? 'auto' : 'none')};
22
- max-height: calc(100vh - ${mobileNavMaxHeight});
23
+ max-height: calc(var(--vh100, 100vh) - ${mobileNavMaxHeight});
23
24
  width: 100%;
24
25
  position: absolute;
25
26
  right: 0;
@@ -34,11 +35,11 @@ const Tooltip = styled.div `
34
35
  right: ${p => (p.fullWidthDesktop ? 0 : p.tooltipRight)};
35
36
  }
36
37
  ${media.md `
37
- max-height: calc(100vh - (${mobileNavMaxHeight} + ${ribbonHeight}));
38
+ max-height: calc(var(--vh100, 100vh) - (${mobileNavMaxHeight} + ${ribbonHeight}));
38
39
  top: calc(${mobileNavMaxHeight} + ${ribbonHeight});
39
40
  `};
40
41
  @media (min-width: ${p => p.collapseSize + 1}px) {
41
- max-height: calc(100vh - (${desktopNavMaxHeight} + ${ribbonHeight}));
42
+ max-height: calc(var(--vh100, 100vh) - (${desktopNavMaxHeight} + ${ribbonHeight}));
42
43
  top: calc(${desktopNavMaxHeight} + ${ribbonHeight});
43
44
  }
44
45
  `;
@@ -59,7 +60,7 @@ const TailShadowNav = styled.div `
59
60
  top: calc(${mobileNavMaxHeight} + ${ribbonHeight});
60
61
  `};
61
62
  @media (min-width: ${p => p.collapseSize + 1}px) {
62
- max-height: calc(100vh - ${desktopNavMaxHeight});
63
+ max-height: calc(var(--vh100, 100vh) - ${desktopNavMaxHeight});
63
64
  top: calc(${desktopNavMaxHeight} + ${ribbonHeight});
64
65
  }
65
66
  `;
@@ -80,13 +81,14 @@ const TailNav = styled.div `
80
81
  top: calc(${mobileNavMaxHeight} + ${ribbonHeight});
81
82
  `};
82
83
  @media (min-width: ${p => p.collapseSize + 1}px) {
83
- max-height: calc(100vh - ${desktopNavMaxHeight});
84
+ max-height: calc(var(--vh100, 100vh) - ${desktopNavMaxHeight});
84
85
  top: calc(${desktopNavMaxHeight} + ${ribbonHeight});
85
86
  }
86
87
  `;
87
88
  const MainNavTooltipMenu = ({ className, activeColor = colors.hotPink, color = colors.text, children, zIndex = '1', tooltipRight = '-1rem', contentWidth = '20rem', contentComponent: ContentComponent, closeWhenTagClicked = [], overflowY = true, globalStateString, fullWidthDesktop = false, fullWidthBreakpoint = breakpoints.xs, }) => {
88
89
  const { isMobileMenu, tooltipItems, setTooltipItems, collapseSize, resetMenuEvents, showMinicart, showLoginTooltip, } = React.useContext(NavContext);
89
90
  const ref = useRef(null);
91
+ useDocHeight();
90
92
  React.useEffect(() => {
91
93
  setTooltipItems({
92
94
  minicart: showMinicart,
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
- import NavContext from '../context/NavContext.js';
3
- import MainNavTooltipMenu from './MainNavTooltipMenu.js';
4
- import { TooltipWrapper } from './MainNavTooltipMenuExportedStyles.js';
5
- import { NotificationBadge } from '../../NotificationBadge/index.js';
6
2
  import styled from '../../../themes/styled.js';
3
+ import breakpoints from '../../../themes/themeComponents/breakpoints.js';
7
4
  import colors from '../../../themes/themeComponents/colors.js';
8
5
  import Icon from '../../Icon/Icon.js';
9
- import breakpoints from '../../../themes/themeComponents/breakpoints.js';
6
+ import { NotificationBadge } from '../../NotificationBadge/NotificationBadge.js';
7
+ import NavContext from '../context/NavContext.js';
8
+ import MainNavTooltipMenu from './MainNavTooltipMenu.js';
9
+ import { TooltipWrapper } from './MainNavTooltipMenuExportedStyles.js';
10
10
 
11
11
  const MinicartAmount = styled(NotificationBadge) `
12
12
  right: auto;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { RibbonDataProps } from './ChildComponents/Ribbon';
3
3
  import { GlobalNavItems } from './types/globalNavProps';
4
- /** @visibleName Main navigation */
5
4
  export interface MainNavigationProps {
6
5
  /** Allows to pass a custom className */
7
6
  className?: string;
@@ -113,6 +113,7 @@ const initiateScrollToHeader = (componentRef) => {
113
113
  window.scrollTo({ top: componentRef.current.offsetTop, left: 0 });
114
114
  }
115
115
  };
116
+ /** @visibleName Main Navigation */
116
117
  const MainNavigation = ({
117
118
  // TODO: Define types for MainNavigation component (https://jira.dna.fi/browse/STYLE-233)
118
119
  items = {}, language = 'fi', zIndex = 1030, languageSelector = false, isMobileMenu = false, search = true, searchText = 'Haku', searchComponent = false, minicart = true, minicartText = 'Ostoskori', minicartComponent = false, minicartAmount = 0, showMinicart = false, showLoginTooltip = false, login = true, loginText = 'Kirjaudu', loginComponent = false, isLoggedIn = false, collapseSize = 767, nextJSLinkComponent = false, ribbon = true, ribbonData, className, currentUrl = false, notificationText = '', }) => {
@@ -326,6 +327,6 @@ items = {}, language = 'fi', zIndex = 1030, languageSelector = false, isMobileMe
326
327
  /** @component */
327
328
  // TODO: Remove ts-ignore after https://jira.dna.fi/browse/STYLE-232 is done
328
329
  // @ts-ignore
329
- var index = withSizes(mapSizesToProps)(MainNavigation);
330
+ var MainNavigation$1 = withSizes(mapSizesToProps)(MainNavigation);
330
331
 
331
- export default index;
332
+ export default MainNavigation$1;
@@ -1,38 +1,61 @@
1
1
  import React from 'react';
2
- export interface NotificationProps {
3
- /** Allows to pass a custom className */
4
- className?: string;
5
- /** Dictates what the norification will say */
2
+ declare type NotificationType = 'info' | 'success' | 'warning' | 'error';
3
+ interface Props {
4
+ /**
5
+ * Depending on the passed type, the background color is determined
6
+ *
7
+ * @default 'info'
8
+ * @param {NotificationType} info Uses #007d91 color code as background color
9
+ * @param {NotificationType} success Uses #e80c0c color code as background color
10
+ * @param {NotificationType} warning Uses #00b201 color code as background color
11
+ * @param {NotificationType} error Uses #ff7800 color code as background color
12
+ */
13
+ type?: NotificationType;
14
+ /**
15
+ * @deprecated Use `type` property instead
16
+ */
17
+ color?: NotificationType | 'pinkday';
18
+ /**
19
+ * Content of the ribbon
20
+ */
6
21
  children?: React.ReactNode;
7
22
  /**
23
+ * Allows to show or hide appropriate notification icon
24
+ *
8
25
  * @default false
9
26
  */
10
- /** Show icon */
11
- showIcon: boolean;
27
+ showIcon?: boolean;
12
28
  /**
29
+ * Allows to show and hide close button
30
+ *
13
31
  * @default false
14
32
  */
15
- /** Show close button */
16
- closeButton: boolean;
17
- /** onClick handler for close button */
18
- onClickCloseButton?: (event: React.MouseEvent<HTMLElement>) => void;
19
- /** Is the notification dismissed */
33
+ closeButton?: boolean;
20
34
  /**
35
+ * On close button click callback
36
+ */
37
+ onClickCloseButton?: (e: React.MouseEvent<HTMLElement>) => void;
38
+ /**
39
+ * Allows to dismiss the ribbon programmatically
40
+ *
21
41
  * @default false
22
42
  */
23
43
  dismissed?: boolean;
24
- /** Dictates what is the type and color of the notification */
25
44
  /**
26
- * @default 'info'
27
- */
28
- color: 'info' | 'success' | 'warning' | 'error' | 'pinkday';
29
- /** Align text center
45
+ * Allows to center text of the ribbon
30
46
  *
31
47
  * @default false
32
48
  */
33
49
  centered?: boolean;
50
+ /**
51
+ * Allows to pass a custom className
52
+ */
53
+ className?: string;
54
+ /**
55
+ * Allows to pass testid string for testing purposes
56
+ */
34
57
  'data-testid'?: string;
35
58
  }
36
- declare const Notification: (props: NotificationProps) => JSX.Element | null;
59
+ declare const Notification: ({ type, color, "data-testid": dataTestId, ...props }: Props) => JSX.Element;
37
60
  /** @component */
38
61
  export default Notification;
@@ -1,67 +1,47 @@
1
1
  import React from 'react';
2
- import { media, getMultipliedSize, getDividedSize } from '../../utils/styledUtils.js';
3
2
  import styled__default from 'styled-components';
3
+ import theme from '../../themes/theme.js';
4
+ import { getMultipliedSize, media } from '../../utils/styledUtils.js';
4
5
  import Icon from '../Icon/Icon.js';
6
+ import Ribbon from '../Ribbon/Ribbon.js';
5
7
 
6
- const iconAreaWidth = 4;
7
- const smallPadding = '0.55rem';
8
- const basePadding = '0.75rem';
9
- const NotificationStyle = styled__default.div `
10
- color: ${({ color, theme }) => (color === 'pinkday' ? theme.color.text : theme.color.white)};
11
- background: ${props => props.theme.color[props.color]};
8
+ const StyledRibbon = styled__default(Ribbon) `
9
+ ${({ showIcon, closeButton }) => showIcon &&
10
+ closeButton &&
11
+ `
12
+ a:last-of-type {
13
+ ${getMultipliedSize(theme.base.baseWidth, 1.2)}
14
+ }
15
+ `}
16
+ `;
17
+ const NotificationWrapper = styled__default.div `
12
18
  display: flex;
13
19
  align-items: center;
14
- overflow: hidden;
15
- padding: ${basePadding} 0.9375rem;
16
- position: relative;
17
- opacity: 0.95;
18
- transition: all 0.3s;
19
- ${({ centered }) => (centered ? 'text-align:center;' : '')}
20
- a {
21
- color: ${({ color, theme }) => color === 'pinkday' ? theme.color.text : theme.color.white};
22
- text-decoration: underline;
23
- }
24
20
  `;
25
- const IconArea = styled__default.div `
21
+ const IconWrapper = styled__default.div `
26
22
  display: none;
27
23
  align-items: center;
28
- width: ${iconAreaWidth}rem;
24
+ width: ${getMultipliedSize(theme.base.baseWidth, 6.4)};
29
25
  overflow: hidden;
26
+
30
27
  ${() => media.xs `
31
28
  display: flex;
32
29
  `}
33
30
  `;
34
- const TextArea = styled__default.div `
31
+ const ContentWrapper = styled__default.div `
35
32
  flex: 1;
36
- font-weight: ${props => props.theme.fontWeight.book};
37
- overflow: hidden;
38
- font-size: ${props => props.theme.fontSize.defaultFontSize};
39
- line-height: 1.5;
40
- position: relative;
41
- word-wrap: break-word;
42
- margin-right: ${props => props && props.closeButton ? getMultipliedSize(props.theme.base.baseWidth, 3) : 0};
43
- `;
44
- const CloseButton = styled__default.a `
45
- position: absolute;
46
- top: ${props => (props && props.showIcon ? basePadding : smallPadding)};
47
- ${() => media.xs `
48
- top: ${basePadding};
49
- `}
50
- right: ${basePadding};
51
- margin: ${props => getDividedSize(props.theme.base.baseWidth, 2)};
52
- cursor: pointer;
53
33
  `;
54
- const Notification = (props) => {
55
- const { children, showIcon, color, dismissed, onClickCloseButton, closeButton, centered, className, 'data-testid': dataTestId, } = props;
56
- if (dismissed) {
57
- return null;
58
- }
59
- return (React.createElement(NotificationStyle, { className: className, color: color, showIcon: showIcon, onClick: onClickCloseButton, closeButton: closeButton, "data-testid": dataTestId, centered: centered },
60
- showIcon ? (React.createElement(IconArea, null,
61
- React.createElement(Icon, { name: color === 'success' ? 'hlCheck' : color, size: "2rem", color: "currentColor" }))) : null,
62
- React.createElement(TextArea, { closeButton: closeButton }, children),
63
- closeButton ? (React.createElement(CloseButton, { showIcon: showIcon, onClick: onClickCloseButton },
64
- React.createElement(Icon, { name: "x", size: "0.75rem", color: "currentColor" }))) : null));
34
+ const Notification = ({ type = 'info', color, 'data-testid': dataTestId, ...props }) => {
35
+ // Property color is deprecated
36
+ // TODO: Remove this line after https://jira.dna.fi/browse/STYLE-292 is done
37
+ type = (color || type);
38
+ return (React.createElement(StyledRibbon, { color: type, closeButton: props.closeButton, onClick: props.onClickCloseButton, dismissed: props.dismissed, centered: props.centered, className: props.className, "data-testid": dataTestId },
39
+ React.createElement(NotificationWrapper, null,
40
+ props.showIcon && (React.createElement(IconWrapper, null,
41
+ React.createElement(Icon, { name: type === 'success'
42
+ ? 'hlCheck'
43
+ : `hl${type.charAt(0).toUpperCase() + type.slice(1)}`, size: "2rem", color: "currentColor" }))),
44
+ React.createElement(ContentWrapper, null, props.children))));
65
45
  };
66
46
 
67
47
  export default Notification;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import LoaderProps from './types/LoaderProps';
3
- /** @visibleName Pixel loader */
3
+ /** @visibleName Pixel Loader */
4
4
  export declare const PixelLoader: ({ className, color, "data-testid": dataTestId }: LoaderProps) => JSX.Element;
5
5
  /** @component */
6
6
  export default PixelLoader;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { LoaderWrapper, Pixel } from './PixelLoaderStyles.js';
3
3
 
4
- /** @visibleName Pixel loader */
4
+ /** @visibleName Pixel Loader */
5
5
  const PixelLoader = ({ className, color, 'data-testid': dataTestId }) => (React.createElement(LoaderWrapper, { className: className, "data-testid": dataTestId },
6
6
  React.createElement(Pixel, { color: color, delay: "-0.27" }),
7
7
  React.createElement(Pixel, { color: color, delay: "-0.18" }),
@@ -19,6 +19,6 @@ export interface StepperProps {
19
19
  /** Dictates current status of the flow */
20
20
  currentStatus?: string;
21
21
  }
22
- /** @visibleName Progress indicator */
23
- declare const ProgressIndicator: React.SFC<StepperProps>;
22
+ /** @visibleName Progress Indicator */
23
+ declare const ProgressIndicator: React.FunctionComponent<StepperProps>;
24
24
  export default ProgressIndicator;
@@ -157,7 +157,7 @@ const ProgressItem = styled.li `
157
157
  color: ${({ theme, isActive, isCompleted }) => isActive || isCompleted ? theme.color.text : theme.color.gray40};
158
158
  }
159
159
  `;
160
- /** @visibleName Progress indicator */
160
+ /** @visibleName Progress Indicator */
161
161
  const ProgressIndicator = props => {
162
162
  const { steps, small = false, onStepChange, activeSlideIndex = 0, currentStatus, className, } = props;
163
163
  return (createElement(Progress, { className: className, activeSlideIndex: activeSlideIndex, currentStatus: currentStatus, small: small, steps: steps }, steps.map(({ title, cursorType }, index) => {
@@ -27,7 +27,7 @@ export interface RadioProps {
27
27
  value?: string | number;
28
28
  'data-testid'?: string;
29
29
  }
30
- /** @visibleName Radio button */
30
+ /** @visibleName Radio Button */
31
31
  declare const RadioButton: React.FunctionComponent<RadioProps>;
32
32
  /** @component */
33
33
  export default RadioButton;
@@ -60,7 +60,7 @@ const Label = styled('label') `
60
60
  content: '●';
61
61
  }
62
62
  `;
63
- /** @visibleName Radio button */
63
+ /** @visibleName Radio Button */
64
64
  const RadioButton = ({ id, name, checked, onChange, label, disabled, className, value, 'data-testid': dataTestId, }) => {
65
65
  return (React.createElement(Wrapper, { className: className, "data-testid": dataTestId },
66
66
  React.createElement(Input, { id: id, type: "radio", name: name, checked: checked, "aria-checked": checked, value: value, disabled: disabled, onChange: onChange, tabIndex: -1, "data-testid": dataTestId && `${dataTestId}-input` }),
@@ -13,6 +13,6 @@ interface ReadMoreProps {
13
13
  /** Init in expanded state and immediately close on client for better SEO */
14
14
  seoInitExpanded?: boolean;
15
15
  }
16
- /** @visibleName Read more */
16
+ /** @visibleName Read More */
17
17
  declare const ReadMore: React.FunctionComponent<ReadMoreProps>;
18
18
  export default ReadMore;
@@ -41,7 +41,7 @@ const Toggle = styled.div `
41
41
  }
42
42
  }
43
43
  `;
44
- /** @visibleName Read more */
44
+ /** @visibleName Read More */
45
45
  const ReadMore = ({ children, showMoreText, showLessText, className, onClick = () => ({}), seoInitExpanded, }) => {
46
46
  const [expanded, setExpanded] = useState(seoInitExpanded === true || false);
47
47
  useEffect(() => {
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import theme from '../../themes/theme';
3
+ declare type TextColor = 'text' | 'white' | 'black';
4
+ interface Props {
5
+ /**
6
+ * Depending on the passed value, background color and text color are determined
7
+ *
8
+ * @default 'info'
9
+ */
10
+ color?: keyof typeof theme.color;
11
+ /**
12
+ * When defined, the text colors in color map are ignored and passed value is used instead
13
+ *
14
+ * @default 'white'
15
+ * @param {TextColor} text Uses #121212 color code as text color
16
+ * @param {TextColor} white Uses #ffffff color code as text color
17
+ * @param {TextColor} black Uses #000000 color code as text color
18
+ */
19
+ textColor?: TextColor;
20
+ /**
21
+ * Content of the ribbon
22
+ */
23
+ children?: React.ReactNode;
24
+ /**
25
+ * Allows to show and hide close button
26
+ *
27
+ * @default false
28
+ */
29
+ closeButton?: boolean;
30
+ /**
31
+ * On close button click callback
32
+ */
33
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
34
+ /**
35
+ * Allows to dismiss the ribbon programmatically
36
+ *
37
+ * @default false
38
+ */
39
+ dismissed?: boolean;
40
+ /**
41
+ * Allows to center text of the ribbon
42
+ *
43
+ * @default false
44
+ */
45
+ centered?: boolean;
46
+ /**
47
+ * Allows to pass a custom className
48
+ */
49
+ className?: string;
50
+ /**
51
+ * Allows to pass testid string for testing purposes
52
+ */
53
+ 'data-testid'?: string;
54
+ }
55
+ declare const Ribbon: ({ color, "data-testid": dataTestId, ...props }: Props) => JSX.Element | null;
56
+ /** @component */
57
+ export default Ribbon;
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import styled__default from 'styled-components';
3
+ import theme from '../../themes/theme.js';
4
+ import { getMultipliedSize, getDividedSize, media } from '../../utils/styledUtils.js';
5
+ import Icon from '../Icon/Icon.js';
6
+
7
+ const getColorScheme = ({ color, textColor }) => {
8
+ const map = {
9
+ text: ['pinkday', 'white', 'pink2', 'grayBg', 'gray15', 'gray10', 'gray5'],
10
+ black: ['grayWhite'],
11
+ };
12
+ textColor =
13
+ textColor ||
14
+ Object.keys(map).find(key => map[key].includes(color)) ||
15
+ 'white';
16
+ return `
17
+ color: ${theme.color[textColor]};
18
+ background: ${theme.color[color]};
19
+
20
+ a {
21
+ color: ${theme.color[textColor]};
22
+ };
23
+ }`;
24
+ };
25
+ const RibbonWrapper = styled__default.div `
26
+ ${({ color, textColor }) => getColorScheme({ color, textColor })}
27
+ display: flex;
28
+ align-items: center;
29
+ overflow: hidden;
30
+ padding: ${getMultipliedSize(theme.base.baseWidth, 1.2)}
31
+ ${getMultipliedSize(theme.base.baseWidth, 1.5)};
32
+ position: relative;
33
+ opacity: 0.95;
34
+ transition: all 0.3s;
35
+ text-align: ${({ centered }) => (centered ? 'center' : 'left')};
36
+ a {
37
+ text-decoration: underline;
38
+ }
39
+ `;
40
+ const ContentWrapper = styled__default.div `
41
+ flex: 1;
42
+ font-weight: ${theme.fontWeight.book};
43
+ overflow: hidden;
44
+ font-size: ${theme.fontSize.defaultFontSize};
45
+ line-height: 1.5;
46
+ position: relative;
47
+ word-wrap: break-word;
48
+ margin-right: ${({ closeButton }) => closeButton ? getMultipliedSize(theme.base.baseWidth, 3) : 0};
49
+ `;
50
+ const CloseButton = styled__default.a `
51
+ position: absolute;
52
+ top: ${getMultipliedSize(theme.base.baseWidth, 0.88)};
53
+ right: ${getMultipliedSize(theme.base.baseWidth, 1.2)};
54
+ margin: ${getDividedSize(theme.base.baseWidth, 2)};
55
+ cursor: pointer;
56
+
57
+ ${() => media.xs `
58
+ top: ${getMultipliedSize(theme.base.baseWidth, 1.2)};
59
+ `}
60
+ `;
61
+ const Ribbon = ({ color = 'info', 'data-testid': dataTestId, ...props }) => {
62
+ if (props.dismissed) {
63
+ return null;
64
+ }
65
+ return (React.createElement(RibbonWrapper, { className: props.className, color: color, textColor: props.textColor, "data-testid": dataTestId, centered: props.centered },
66
+ React.createElement(ContentWrapper, { closeButton: props.closeButton }, props.children),
67
+ props.closeButton ? (React.createElement(CloseButton, { onClick: props.onClick },
68
+ React.createElement(Icon, { name: "x", size: "0.75rem", color: "currentColor" }))) : null));
69
+ };
70
+
71
+ export default Ribbon;
@@ -1,15 +1,54 @@
1
1
  import React from 'react';
2
2
  export interface SearchProps {
3
- /** Allows to pass a custom className */
4
- className?: string;
3
+ /**
4
+ * The input element's name
5
+ * Submitted with the form as part of a name/value pair
6
+ */
5
7
  name: string;
6
- onChange?: (...args: any[]) => any;
7
- onClick?: (...args: any[]) => any;
8
+ /**
9
+ * The input element unique identifier
10
+ * Must be unique in the whole document
11
+ */
8
12
  id?: string;
13
+ /**
14
+ * The input element's value
15
+ * When specified, it represents the initial value
16
+ */
9
17
  value?: string;
18
+ /**
19
+ * Provides a brief information as to what kind of value is expected in the field
20
+ */
10
21
  placeholder?: string;
11
- iconSize?: string;
22
+ /**
23
+ * If defined, input element will automatically have focus when the page has finished loading
24
+ * In cases when more than one element in the document has the autofocus attribute defined,
25
+ * only first one receives focus
26
+ */
27
+ autoFocus?: boolean;
28
+ /**
29
+ * Icon from Icons component shown next to input element
30
+ *
31
+ * @default 'hlMagnifyingGlass'
32
+ */
12
33
  iconName?: string;
34
+ /**
35
+ * Size of the icon shown next to input element
36
+ *
37
+ * @default '1.6em'
38
+ */
39
+ iconSize?: string;
40
+ /**
41
+ * Allows to pass a custom className
42
+ */
43
+ className?: string;
44
+ /**
45
+ * On input element change callback
46
+ */
47
+ onChange?: (...args: any[]) => any;
48
+ /**
49
+ * On icon element click callback
50
+ */
51
+ onClick?: (...args: any[]) => any;
13
52
  }
14
53
  declare const Search: React.FunctionComponent<SearchProps>;
15
54
  /** @component */
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import styled from '../../themes/styled.js';
3
- import Icon from '../Icon/Icon.js';
4
3
  import colors from '../../themes/themeComponents/colors.js';
4
+ import Icon from '../Icon/Icon.js';
5
5
 
6
6
  const Container = styled.div `
7
7
  display: flex;
@@ -35,7 +35,7 @@ const Input = styled.input `
35
35
  display: none;
36
36
  }
37
37
  `;
38
- const Search = ({ id, className, name, onChange, onClick, value = '', placeholder, iconSize = '1.6em', iconName = 'hlMagnifyingGlass', ...props }) => {
38
+ const Search = ({ value = '', iconName = 'hlMagnifyingGlass', iconSize = '1.6em', className, onChange, onClick, ...props }) => {
39
39
  const [text, setText] = useState(value);
40
40
  const handleChange = (e) => {
41
41
  setText(e.target.value);
@@ -50,7 +50,7 @@ const Search = ({ id, className, name, onChange, onClick, value = '', placeholde
50
50
  }
51
51
  };
52
52
  return (React.createElement(Container, { className: className },
53
- React.createElement(Input, Object.assign({ type: "search", name: name, value: text, placeholder: placeholder, onChange: handleChange }, props)),
53
+ React.createElement(Input, Object.assign({ type: "search", value: text, onChange: handleChange }, props)),
54
54
  React.createElement(Icon, { name: text.length ? 'hlX' : iconName, size: iconSize, color: colors.hotPink, onClick: onIconClick })));
55
55
  };
56
56
 
@@ -23,6 +23,7 @@ interface SecondaryNavigationProps {
23
23
  /** Highlighted ids */
24
24
  highlightIds?: string[];
25
25
  }
26
+ /** @visibleName Secondary Navigation */
26
27
  declare const SecondaryNavigation: ({ currentUrl, data, lang, nextJSSecondaryNavLink: NextJSSecondaryNavLink, collapseSize, "data-testid": dataTestId, "max-width": componentMaxWidth, className, matchFullUrl, mobileOnly, highlightIds, }: SecondaryNavigationProps) => JSX.Element;
27
28
  /** @component */
28
29
  export default SecondaryNavigation;
@@ -1,9 +1,9 @@
1
1
  import React, { useState, useRef } from 'react';
2
+ import useOutsideClick from '../../hooks/useOutsideClick.js';
2
3
  import styled from '../../themes/styled.js';
3
4
  import theme from '../../themes/theme.js';
4
- import Icon from '../Icon/Icon.js';
5
- import useOutsideClick from '../../hooks/useOutsideClick.js';
6
5
  import { media } from '../../utils/styledUtils.js';
6
+ import Icon from '../Icon/Icon.js';
7
7
 
8
8
  const SecondaryNavigationWrapper = styled.nav `
9
9
  line-height: 1.2rem;
@@ -149,6 +149,7 @@ const IconWrapper = styled.span `
149
149
  }
150
150
  `;
151
151
  const isMenuItemLinkAbsolute = (menuItemLink) => menuItemLink.includes('http');
152
+ /** @visibleName Secondary Navigation */
152
153
  const SecondaryNavigation = ({ currentUrl = '', data, lang = 'fi', nextJSSecondaryNavLink: NextJSSecondaryNavLink = false, collapseSize = 767, 'data-testid': dataTestId, 'max-width': componentMaxWidth, className, matchFullUrl = true, mobileOnly = false, highlightIds = [], }) => {
153
154
  const [isSecondaryNavOpen, setIsSecondaryNavOpen] = useState(false);
154
155
  const toggleNav = () => {
@@ -9,22 +9,26 @@ interface DropDownIndicator {
9
9
  iconSize?: string;
10
10
  }
11
11
  interface Props {
12
+ options: ReactSelectProps['options'];
13
+ onChange: (selectedItem: SelectboxItem) => void;
12
14
  /** Allows to pass a custom className */
13
15
  className?: string;
16
+ 'data-testid'?: string;
14
17
  label?: string;
18
+ inputId?: ReactSelectProps['inputId'];
15
19
  placeholder?: ReactSelectProps['placeholder'];
16
- onChange: (selectedItem: SelectboxItem) => void;
17
- options: ReactSelectProps['options'];
20
+ onInputChange?: ReactSelectProps['onInputChange'];
18
21
  value?: ReactSelectProps['value'];
19
- 'data-testid'?: string;
20
22
  dropDownIndicator?: DropDownIndicator;
21
23
  noOptionsText?: string;
22
24
  isSearchable?: boolean;
25
+ isClearable?: boolean;
26
+ isMulti?: boolean;
23
27
  isLoading?: boolean;
24
28
  isDisabled?: boolean;
25
29
  isRequired?: boolean;
26
30
  error?: boolean;
27
31
  errorMessage?: string;
28
32
  }
29
- declare const SelectBox: ({ className, label, onChange, options, value, dropDownIndicator, placeholder, "data-testid": dataTestId, isSearchable, noOptionsText, isLoading, isDisabled, isRequired, error, errorMessage, }: Props) => JSX.Element;
33
+ declare const SelectBox: ({ dropDownIndicator, "data-testid": dataTestId, isSearchable, isClearable, isMulti, noOptionsText, isLoading, isDisabled, isRequired, error, ...props }: Props) => JSX.Element;
30
34
  export default SelectBox;