@transferwise/components 0.0.0-experimental-a656242 → 0.0.0-experimental-887f2e6

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 (154) hide show
  1. package/build/avatarLayout/AvatarLayout.js +9 -2
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +9 -2
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/avatarView/AvatarView.js +1 -12
  6. package/build/avatarView/AvatarView.js.map +1 -1
  7. package/build/avatarView/AvatarView.mjs +1 -12
  8. package/build/avatarView/AvatarView.mjs.map +1 -1
  9. package/build/button/Button.js +78 -79
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +79 -80
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/button/Button.resolver.js +78 -0
  14. package/build/button/Button.resolver.js.map +1 -0
  15. package/build/button/Button.resolver.mjs +76 -0
  16. package/build/button/Button.resolver.mjs.map +1 -0
  17. package/build/button/LegacyButton.js +114 -0
  18. package/build/button/LegacyButton.js.map +1 -0
  19. package/build/button/LegacyButton.mjs +112 -0
  20. package/build/button/LegacyButton.mjs.map +1 -0
  21. package/build/circularButton/CircularButton.js +21 -18
  22. package/build/circularButton/CircularButton.js.map +1 -1
  23. package/build/circularButton/CircularButton.mjs +22 -19
  24. package/build/circularButton/CircularButton.mjs.map +1 -1
  25. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  26. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  27. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  28. package/build/definitionList/DefinitionList.js.map +1 -1
  29. package/build/definitionList/DefinitionList.mjs.map +1 -1
  30. package/build/header/Header.js +2 -2
  31. package/build/header/Header.js.map +1 -1
  32. package/build/header/Header.mjs +1 -1
  33. package/build/i18n/de.json +0 -1
  34. package/build/i18n/de.json.js +0 -1
  35. package/build/i18n/de.json.js.map +1 -1
  36. package/build/i18n/de.json.mjs +0 -1
  37. package/build/i18n/de.json.mjs.map +1 -1
  38. package/build/i18n/it.json +0 -1
  39. package/build/i18n/it.json.js +0 -1
  40. package/build/i18n/it.json.js.map +1 -1
  41. package/build/i18n/it.json.mjs +0 -1
  42. package/build/i18n/it.json.mjs.map +1 -1
  43. package/build/i18n/th.json +0 -1
  44. package/build/i18n/th.json.js +0 -1
  45. package/build/i18n/th.json.js.map +1 -1
  46. package/build/i18n/th.json.mjs +0 -1
  47. package/build/i18n/th.json.mjs.map +1 -1
  48. package/build/index.js +2 -2
  49. package/build/index.mjs +1 -1
  50. package/build/link/Link.js +8 -3
  51. package/build/link/Link.js.map +1 -1
  52. package/build/link/Link.mjs +8 -3
  53. package/build/link/Link.mjs.map +1 -1
  54. package/build/main.css +416 -17
  55. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +1 -3
  56. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  57. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +1 -3
  58. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  59. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +1 -4
  60. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  61. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +1 -4
  62. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  63. package/build/select/Select.js +5 -3
  64. package/build/select/Select.js.map +1 -1
  65. package/build/select/Select.mjs +4 -2
  66. package/build/select/Select.mjs.map +1 -1
  67. package/build/styles/avatarLayout/AvatarLayout.css +11 -0
  68. package/build/styles/button/Button.css +240 -16
  69. package/build/styles/button/Button.vars.css +55 -0
  70. package/build/styles/button/LegacyButton.css +23 -0
  71. package/build/styles/circularButton/CircularButton.css +158 -17
  72. package/build/styles/main.css +416 -17
  73. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
  74. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  75. package/build/types/avatarLayout/index.d.ts +1 -0
  76. package/build/types/avatarLayout/index.d.ts.map +1 -1
  77. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  78. package/build/types/button/Button.d.ts +1 -23
  79. package/build/types/button/Button.d.ts.map +1 -1
  80. package/build/types/button/Button.resolver.d.ts +31 -0
  81. package/build/types/button/Button.resolver.d.ts.map +1 -0
  82. package/build/types/button/Button.types.d.ts +67 -0
  83. package/build/types/button/Button.types.d.ts.map +1 -0
  84. package/build/types/button/LegacyButton.d.ts +30 -0
  85. package/build/types/button/LegacyButton.d.ts.map +1 -0
  86. package/build/types/button/index.d.ts +2 -2
  87. package/build/types/button/index.d.ts.map +1 -1
  88. package/build/types/circularButton/CircularButton.d.ts +4 -11
  89. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  90. package/build/types/definitionList/DefinitionList.d.ts +2 -1
  91. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  92. package/build/types/link/Link.d.ts +2 -2
  93. package/build/types/link/Link.d.ts.map +1 -1
  94. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  95. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
  96. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  97. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  98. package/build/types/select/Select.d.ts.map +1 -1
  99. package/build/upload/steps/completeStep/completeStep.js +2 -2
  100. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  101. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  102. package/build/upload/steps/processingStep/processingStep.js +2 -2
  103. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  104. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  105. package/build/uploadInput/UploadInput.js +3 -3
  106. package/build/uploadInput/UploadInput.js.map +1 -1
  107. package/build/uploadInput/UploadInput.mjs +1 -1
  108. package/package.json +3 -3
  109. package/src/avatarLayout/AvatarLayout.css +11 -0
  110. package/src/avatarLayout/AvatarLayout.less +18 -1
  111. package/src/avatarLayout/AvatarLayout.tsx +11 -3
  112. package/src/avatarLayout/index.ts +1 -0
  113. package/src/avatarView/AvatarView.tsx +1 -15
  114. package/src/button/Button.css +240 -16
  115. package/src/button/Button.less +208 -14
  116. package/src/button/Button.resolver.tsx +120 -0
  117. package/src/button/Button.spec.tsx +54 -231
  118. package/src/button/Button.story.tsx +610 -137
  119. package/src/button/Button.tsx +88 -132
  120. package/src/button/Button.types.ts +88 -0
  121. package/src/button/Button.vars.css +55 -0
  122. package/src/button/Button.vars.less +69 -0
  123. package/src/button/LegacyButton.css +23 -0
  124. package/src/button/LegacyButton.less +24 -0
  125. package/src/button/LegacyButton.spec.tsx +146 -0
  126. package/src/button/LegacyButton.story.tsx +224 -0
  127. package/src/button/LegacyButton.tsx +161 -0
  128. package/src/button/index.ts +2 -3
  129. package/src/circularButton/CircularButton.css +158 -17
  130. package/src/circularButton/CircularButton.less +91 -22
  131. package/src/circularButton/CircularButton.story.tsx +24 -45
  132. package/src/circularButton/CircularButton.tsx +25 -38
  133. package/src/circularButton/_button-label-states.less +34 -0
  134. package/src/definitionList/DefinitionList.spec.js +91 -0
  135. package/src/definitionList/DefinitionList.story.tsx +57 -57
  136. package/src/definitionList/DefinitionList.tsx +1 -1
  137. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  138. package/src/i18n/de.json +0 -1
  139. package/src/i18n/it.json +0 -1
  140. package/src/i18n/th.json +0 -1
  141. package/src/iconButton/IconButton.story.tsx +6 -6
  142. package/src/inputs/SelectInput.story.tsx +1 -1
  143. package/src/link/Link.tsx +15 -6
  144. package/src/main.css +416 -17
  145. package/src/main.less +1 -0
  146. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +1 -7
  147. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
  148. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
  149. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +1 -8
  150. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -5
  151. package/src/select/Select.tsx +1 -0
  152. package/src/slidingPanel/SlidingPanel.spec.js +56 -0
  153. package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
  154. package/src/slidingPanel/SlidingPanel.spec.tsx +0 -69
@@ -1,36 +1,105 @@
1
+ @import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
2
+ @import "./_button-label-states.less";
3
+
1
4
  .np-circular-btn {
2
5
  display: inline-flex;
3
6
  flex-direction: column;
4
7
  align-items: center;
8
+ text-align: center;
5
9
  cursor: pointer;
10
+ position: relative;
6
11
 
7
- &-primary-default,
8
- &-secondary-default {
9
- .np-circular-btn-label {
10
- color: var(--color-interactive-primary);
11
- &:not(.disabled, :disabled):hover {
12
- color: var(--color-interactive-primary-hover);
13
- }
14
- &:not(.disabled, :disabled):active {
15
- color: var(--color-interactive-primary-active);
16
- }
12
+ .tw-icon {
13
+ position: absolute;
14
+ top: var(--size-16);
15
+ pointer-events: none;
16
+ color: white;
17
+ transition: color 0.15s ease-in-out;
18
+ width: 100%;
19
+ .left(0);
20
+
21
+ @media (--screen-400-zoom) {
22
+ top: var(--size-12);
23
+ }
24
+
25
+ > svg {
26
+ margin: 0 auto;
17
27
  }
18
28
  }
19
29
 
20
- &-primary-negative,
21
- &-secondary-negative {
22
- .np-circular-btn-label {
23
- color: var(--color-sentiment-negative-primary);
24
- &:not(.disabled, :disabled):hover {
25
- color: var(--color-sentiment-negative-primary-hover);
26
- }
27
- &:not(.disabled, :disabled):active {
28
- color: var(--color-sentiment-negative-primary-active);
30
+ .np-theme-personal & {
31
+ /* stylelint-disable-next-line no-duplicate-selectors */
32
+ .tw-icon {
33
+ &,
34
+ &:hover,
35
+ &:active {
36
+ color: var(--color-interactive-control);
29
37
  }
30
38
  }
31
- }
32
39
 
33
- &-disabled {
34
- cursor: not-allowed;
40
+ &.negative .tw-icon,
41
+ &.negative.secondary:not(.disabled, :disabled):hover .tw-icon,
42
+ &.negative.secondary:not(.disabled, :disabled):active .tw-icon {
43
+ // TODO, this will need to be removed when we update our CSS architecture
44
+ color: var(--color-contrast) !important;
45
+ }
46
+
47
+ &.negative.secondary:not(.disabled, :disabled) .tw-icon {
48
+ // TODO, this will need to be removed when we update our CSS architecture
49
+ color: var(--color-sentiment-negative) !important;
50
+ }
35
51
  }
36
52
  }
53
+
54
+ .button-label-states(
55
+ np-circular-btn,
56
+ accent,
57
+ var(--color-interactive-accent),
58
+ var(--color-interactive-accent-hover),
59
+ var(--color-interactive-accent-active)
60
+ );
61
+
62
+ .button-label-states(
63
+ np-circular-btn,
64
+ positive,
65
+ var(--color-interactive-positive),
66
+ var(--color-interactive-positive-hover),
67
+ var(--color-interactive-positive-active)
68
+ );
69
+
70
+ .button-label-states(
71
+ np-circular-btn,
72
+ negative,
73
+ var(--color-interactive-negative),
74
+ var(--color-interactive-negative-hover),
75
+ var(--color-interactive-negative-active)
76
+ );
77
+
78
+ .np-theme-personal {
79
+ .button-label-states(
80
+ np-circular-btn,
81
+ accent,
82
+ var(--color-interactive-primary),
83
+ var(--color-interactive-primary-hover),
84
+ var(--color-interactive-primary-active),
85
+ true
86
+ );
87
+
88
+ .button-label-states(
89
+ np-circular-btn,
90
+ positive,
91
+ var(--color-interactive-primary),
92
+ var(--color-interactive-primary-hover),
93
+ var(--color-interactive-primary-active),
94
+ true
95
+ );
96
+
97
+ .button-label-states(
98
+ np-circular-btn,
99
+ negative,
100
+ var(--color-sentiment-negative),
101
+ var(--color-sentiment-negative-hover),
102
+ var(--color-sentiment-negative-active),
103
+ true
104
+ );
105
+ }
@@ -5,16 +5,14 @@ import { ControlType, Priority } from '../common';
5
5
  import { Meta, StoryObj } from '@storybook/react';
6
6
  import CircularButton from './CircularButton';
7
7
  import { storyConfig } from '../test-utils';
8
- import Title from '../title';
9
- import Body from '../body';
10
8
 
11
9
  export default {
12
10
  component: CircularButton,
13
11
  title: 'Actions/CircularButton',
14
- tags: ['autodocs'],
15
12
  args: {
16
13
  children: 'Button text',
17
- icon: <Icons.Freeze />,
14
+ // Needs to be cast because we're mapping icon names to components
15
+ icon: 'Freeze' as unknown as React.ReactElement,
18
16
  },
19
17
  argTypes: {
20
18
  icon: {
@@ -30,8 +28,8 @@ type Story = StoryObj<typeof CircularButton>;
30
28
 
31
29
  export const Basic: Story = {
32
30
  args: {
33
- priority: 'primary',
34
- type: 'default',
31
+ priority: Priority.PRIMARY,
32
+ type: ControlType.ACCENT,
35
33
  disabled: false,
36
34
  },
37
35
  };
@@ -43,45 +41,26 @@ export const All: Story = {
43
41
  render: (props) => {
44
42
  return (
45
43
  <>
46
- <Title type="title-subsection" className="m-y-2">
47
- Default (Primary and secondary)
48
- </Title>
49
- <Body>
50
- <CircularButton {...props} priority="primary" type="default" />
51
- <CircularButton {...props} priority="secondary" type="default" />
52
- <CircularButton {...props} priority="primary" type="default" disabled />
53
- <CircularButton {...props} priority="secondary" type="default" disabled />
54
- </Body>
55
-
56
- <Title type="title-subsection" className="m-y-2">
57
- Negative (Primary and secondary)
58
- </Title>
59
- <Body>
60
- <CircularButton {...props} priority="primary" type="negative" />
61
- <CircularButton {...props} priority="secondary" type="negative" />
62
- <CircularButton {...props} priority="primary" type="negative" disabled />
63
- <CircularButton {...props} priority="secondary" type="negative" disabled />
64
- </Body>
65
-
66
- <Title type="title-body" className="m-y-2">
67
- Accent (Deprecated)
68
- </Title>
69
- <Body>
70
- <CircularButton {...props} priority="primary" type="accent" />
71
- <CircularButton {...props} priority="secondary" type="accent" />
72
- <CircularButton {...props} priority="primary" type="accent" disabled />
73
- <CircularButton {...props} priority="secondary" type="accent" disabled />
74
- </Body>
75
-
76
- <Title type="title-body" className="m-y-2">
77
- Positive (Deprecated)
78
- </Title>
79
- <Body>
80
- <CircularButton {...props} priority="primary" type="positive" />
81
- <CircularButton {...props} priority="secondary" type="positive" />
82
- <CircularButton {...props} priority="primary" type="positive" disabled />
83
- <CircularButton {...props} priority="secondary" type="positive" disabled />
84
- </Body>
44
+ <div className="m-b-2">
45
+ <div className="title-4 m-b-1">Accent</div>
46
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.ACCENT} />
47
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.ACCENT} />
48
+ </div>
49
+ <div className="m-b-2">
50
+ <div className="title-4 m-b-1">Positive</div>
51
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.POSITIVE} />
52
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.POSITIVE} />
53
+ </div>
54
+ <div className="m-b-2">
55
+ <div className="title-4 m-b-1">Negative</div>
56
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.NEGATIVE} />
57
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.NEGATIVE} />
58
+ </div>
59
+ <div className="m-b-2">
60
+ <div className="title-4 m-b-1">Disabled</div>
61
+ <CircularButton {...props} disabled />
62
+ <CircularButton {...props} priority={Priority.SECONDARY} disabled />
63
+ </div>
85
64
  </>
86
65
  );
87
66
  },
@@ -1,28 +1,20 @@
1
1
  import { clsx } from 'clsx';
2
+ import { cloneElement } from 'react';
2
3
 
3
4
  import Body from '../body/Body';
5
+ import { typeClassMap, priorityClassMap } from '../button/classMap';
4
6
  import { Breakpoint, ControlType, Priority, Typography } from '../common';
5
- import IconButton, { IconButtonProps } from '../iconButton';
7
+ import Circle from '../common/circle';
6
8
  import { useMedia } from '../common/hooks/useMedia';
7
9
 
8
- /**
9
- * @deprecated use `'default'` instead
10
- */
11
- type DeprecatedTypes = `${ControlType.ACCENT | ControlType.POSITIVE}`;
12
-
13
10
  export interface CircularButtonProps {
14
11
  className?: string;
15
12
  children: string;
16
13
  disabled?: boolean;
17
- icon: React.ReactElement<{ size?: unknown }> | React.ReactNode;
18
- onClick?: React.MouseEventHandler<HTMLInputElement> &
19
- React.MouseEventHandler<HTMLButtonElement> &
20
- React.MouseEventHandler<HTMLAnchorElement>;
14
+ icon: React.ReactElement<{ size?: unknown }>;
15
+ onClick?: React.MouseEventHandler<HTMLInputElement>;
21
16
  priority?: `${Priority.PRIMARY | Priority.SECONDARY}`;
22
- /**
23
- * `"accent"` and `"positive"` values are **deprecated**, please use `"default"` instead
24
- */
25
- type?: DeprecatedTypes | 'default' | `${ControlType.NEGATIVE}`;
17
+ type?: `${ControlType.ACCENT | ControlType.POSITIVE | ControlType.NEGATIVE}`;
26
18
  }
27
19
 
28
20
  const CircularButton = ({
@@ -30,35 +22,30 @@ const CircularButton = ({
30
22
  children,
31
23
  disabled,
32
24
  icon,
33
- onClick,
34
25
  priority = Priority.PRIMARY,
35
- type = 'default',
26
+ type = ControlType.ACCENT,
27
+ ...rest
36
28
  }: CircularButtonProps) => {
29
+ const classes = clsx('btn np-btn', 'm-b-1', typeClassMap[type], priorityClassMap[priority]);
30
+
31
+ const iconElement = Number(icon.props.size) !== 24 ? cloneElement(icon, { size: 24 }) : icon;
32
+
37
33
  const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
34
+
38
35
  return (
39
- <label
40
- className={clsx(
41
- 'np-circular-btn',
42
- `np-circular-btn-${priority}-${type}`,
43
- { 'np-circular-btn-disabled': disabled },
44
- className,
45
- )}
46
- >
47
- <IconButton
48
- size={isTinyViewport ? 32 : 56}
49
- priority={priority}
50
- type={['accent', 'positive'].includes(type) ? 'default' : (type as IconButtonProps['type'])}
51
- className={clsx('m-b-1')}
36
+ <label className={clsx('np-circular-btn', priority, type, disabled && 'disabled', className)}>
37
+ <Circle
38
+ as="input"
39
+ // @ts-expect-error it's input[type=button] element
40
+ type="button"
41
+ size={isTinyViewport ? 72 : 56}
42
+ aria-label={children}
43
+ className={classes}
52
44
  disabled={disabled}
53
- onClick={onClick}
54
- >
55
- {icon}
56
- </IconButton>
57
- <Body
58
- as="span"
59
- className={clsx('np-circular-btn-label', { disabled })}
60
- type={Typography.BODY_DEFAULT_BOLD}
61
- >
45
+ {...rest}
46
+ />
47
+ {iconElement}
48
+ <Body as="span" className="np-circular-btn__label" type={Typography.BODY_DEFAULT_BOLD}>
62
49
  {children}
63
50
  </Body>
64
51
  </label>
@@ -0,0 +1,34 @@
1
+ .button-label-states(@prefix, @type, @normal, @hover, @active, @isModernTheme: false) {
2
+ .@{prefix}.@{type} {
3
+ .@{prefix}__label {
4
+ color: @normal;
5
+ }
6
+
7
+ &:not(.disabled, :disabled):hover .@{prefix}__label {
8
+ color: @hover;
9
+ }
10
+
11
+ &:active .@{prefix}__label,
12
+ input[type="button"]:active ~ .@{prefix}__label {
13
+ color: @active;
14
+ }
15
+
16
+ &.secondary {
17
+ .tw-icon {
18
+ color: @normal;
19
+ }
20
+
21
+ &:not(.disabled, :disabled):hover .tw-icon,
22
+ input[type="button"]:active + .tw-icon {
23
+ color: white;
24
+ & when (@isModernTheme = true) {
25
+ color: var(--color-interactive-control);
26
+ }
27
+ }
28
+
29
+ &:active input[type="button"] + .tw-icon when (@isModernTheme = true) {
30
+ color: var(--color-interactive-control);
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,91 @@
1
+ import { shallow, mount } from 'enzyme';
2
+
3
+ import { DefinitionList } from '..';
4
+ import { Layout } from '../common';
5
+
6
+ const {
7
+ VERTICAL_TWO_COLUMN,
8
+ VERTICAL_ONE_COLUMN,
9
+ HORIZONTAL_LEFT_ALIGNED,
10
+ HORIZONTAL_RIGHT_ALIGNED,
11
+ HORIZONTAL_JUSTIFIED,
12
+ } = Layout;
13
+
14
+ describe('DefinitionList', () => {
15
+ const someDefinitions = () => [{ title: 'First', value: 'first value', key: 'first' }, null];
16
+
17
+ const withLayout = (layout) =>
18
+ shallow(<DefinitionList layout={layout} definitions={someDefinitions()} />);
19
+
20
+ const listHasClass = (layout, className) =>
21
+ withLayout(layout).find('dl.tw-definition-list').hasClass(className);
22
+
23
+ const valueHasClass = (layout, className) =>
24
+ withLayout(layout).find('dl.tw-definition-list dd').hasClass(className);
25
+
26
+ it('applies correct flex class', () => {
27
+ const colClass = 'flex-column';
28
+
29
+ expect(listHasClass(VERTICAL_ONE_COLUMN, colClass)).toBe(true);
30
+ expect(listHasClass(VERTICAL_TWO_COLUMN, colClass)).toBe(true);
31
+ expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, colClass)).toBe(true);
32
+ expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, colClass)).toBe(true);
33
+ expect(listHasClass(HORIZONTAL_JUSTIFIED, colClass)).toBe(true);
34
+ });
35
+
36
+ it('applies correct class for vertical two-column layout', () => {
37
+ const colClass = 'tw-definition-list--columns flex-column flex-row--sm';
38
+
39
+ expect(listHasClass(VERTICAL_TWO_COLUMN, colClass)).toBe(true);
40
+ expect(listHasClass(VERTICAL_ONE_COLUMN, colClass)).toBe(false);
41
+ expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, colClass)).toBe(false);
42
+ expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, colClass)).toBe(false);
43
+ expect(listHasClass(HORIZONTAL_JUSTIFIED, colClass)).toBe(false);
44
+ });
45
+
46
+ it('applies correct class for horiztonal layouts', () => {
47
+ const rowClass = 'tw-definition-list--horizontal flex-column';
48
+
49
+ expect(listHasClass(VERTICAL_TWO_COLUMN, rowClass)).toBe(false);
50
+ expect(listHasClass(VERTICAL_ONE_COLUMN, rowClass)).toBe(false);
51
+ expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, rowClass)).toBe(true);
52
+ expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, rowClass)).toBe(true);
53
+ expect(listHasClass(HORIZONTAL_JUSTIFIED, rowClass)).toBe(true);
54
+ });
55
+
56
+ it('applies correct class for alignment', () => {
57
+ expect(valueHasClass(VERTICAL_TWO_COLUMN, 'd-flex justify-content-between')).toBe(true);
58
+ expect(valueHasClass(VERTICAL_ONE_COLUMN, 'd-flex justify-content-between')).toBe(true);
59
+ expect(valueHasClass(HORIZONTAL_LEFT_ALIGNED, 'd-flex justify-content-between')).toBe(true);
60
+ expect(valueHasClass(HORIZONTAL_RIGHT_ALIGNED, 'text-sm-right')).toBe(true);
61
+ expect(valueHasClass(HORIZONTAL_JUSTIFIED, 'text-sm-justify')).toBe(true);
62
+ });
63
+
64
+ it('has muted text class on title and value when muted flag is passed', () => {
65
+ const muted = shallow(<DefinitionList muted definitions={someDefinitions()} />);
66
+ const notMuted = shallow(<DefinitionList definitions={someDefinitions()} />);
67
+
68
+ expect(muted.find('dl.tw-definition-list').hasClass('text-muted')).toBe(true);
69
+ expect(notMuted.find('dl.tw-definition-list').hasClass('text-muted')).toBe(false);
70
+ });
71
+
72
+ it('shows action button when one is passed in', () => {
73
+ const buttonSpy = jest.fn();
74
+
75
+ const definitionList = mount(
76
+ <DefinitionList
77
+ definitions={[
78
+ {
79
+ title: 'Name',
80
+ value: 'Jenkins',
81
+ key: '1',
82
+ action: { label: 'A button', onClick: buttonSpy },
83
+ },
84
+ ]}
85
+ />,
86
+ );
87
+
88
+ definitionList.find('button').simulate('click');
89
+ expect(buttonSpy).toHaveBeenCalledTimes(1);
90
+ });
91
+ });
@@ -1,29 +1,19 @@
1
1
  import { action } from '@storybook/addon-actions';
2
+ import { select, text, boolean } from '@storybook/addon-knobs';
2
3
 
3
4
  import { Layout } from '../common';
4
5
 
5
- import DefinitionList, { type DefinitionListLayout } from './DefinitionList';
6
- import { lorem10 } from '../test-utils';
7
- import Section from '../section';
8
- import Header from '../header';
6
+ import DefinitionList from './DefinitionList';
9
7
 
10
8
  export default {
11
9
  component: DefinitionList,
12
10
  title: 'Typography/DefinitionList',
13
11
  };
14
12
 
15
- const layouts: DefinitionListLayout[] = [
16
- Layout.VERTICAL_TWO_COLUMN,
17
- Layout.VERTICAL_ONE_COLUMN,
18
- Layout.HORIZONTAL_JUSTIFIED,
19
- Layout.HORIZONTAL_LEFT_ALIGNED,
20
- Layout.HORIZONTAL_RIGHT_ALIGNED,
21
- ];
22
-
23
13
  const definitions = [
24
14
  {
25
- title: 'Definition List title',
26
- value: 'Definition List value',
15
+ title: text('title', 'Editable title'),
16
+ value: text('value', 'Editable value'),
27
17
  key: 'first',
28
18
  },
29
19
  {
@@ -33,57 +23,67 @@ const definitions = [
33
23
  },
34
24
  {
35
25
  title: 'Long strings will wrap',
36
- value: lorem10,
26
+ value: 'And values with long words will eventuallybreakontothenextline',
37
27
  key: 'third',
38
28
  },
39
29
  ];
40
30
 
41
31
  export const Basic = () => {
42
- return layouts.map((layout) => (
43
- <Section key={layout}>
44
- <Header title={`Instace of: ${layout}`} />
45
- <DefinitionList layout={layout} definitions={definitions} />
46
- </Section>
47
- ));
32
+ const muted = boolean('muted', false);
33
+ const layout = select(
34
+ 'layout',
35
+ [
36
+ Layout.VERTICAL_TWO_COLUMN,
37
+ Layout.VERTICAL_ONE_COLUMN,
38
+ Layout.HORIZONTAL_JUSTIFIED,
39
+ Layout.HORIZONTAL_LEFT_ALIGNED,
40
+ Layout.HORIZONTAL_RIGHT_ALIGNED,
41
+ ],
42
+ Layout.HORIZONTAL_LEFT_ALIGNED,
43
+ );
44
+
45
+ return <DefinitionList layout={layout} muted={muted} definitions={definitions} />;
48
46
  };
49
47
 
50
48
  export const WithActionButtons = () => {
51
- return (
52
- <>
53
- {layouts.map((layout) => (
54
- <Section key={layout}>
55
- <Header title={`Instace of: ${layout}`} />
56
- <DefinitionList
57
- key={layout}
58
- layout={layout}
59
- definitions={[
60
- ...definitions,
61
- {
62
- title: 'Action buttons are useful',
63
- value: lorem10,
64
- key: 'fourth',
65
- action: {
66
- label: 'Epic button',
67
- onClick: action(lorem10),
68
- },
69
- },
70
- {
71
- title: 'tiny',
72
- value: 'tiny',
73
- key: 'fifth',
74
- action: {
75
- label: 'Epic button',
76
- onClick: action(lorem10),
77
- },
78
- },
79
- ]}
80
- />
81
- </Section>
82
- ))}
83
- </>
49
+ const muted = boolean('muted', false);
50
+ const layout = select(
51
+ 'layout',
52
+ [
53
+ Layout.VERTICAL_TWO_COLUMN,
54
+ Layout.VERTICAL_ONE_COLUMN,
55
+ Layout.HORIZONTAL_JUSTIFIED,
56
+ Layout.HORIZONTAL_LEFT_ALIGNED,
57
+ Layout.HORIZONTAL_RIGHT_ALIGNED,
58
+ ],
59
+ Layout.HORIZONTAL_LEFT_ALIGNED,
84
60
  );
85
- };
86
61
 
87
- export const Muted = () => {
88
- return <DefinitionList muted definitions={definitions} />;
62
+ return (
63
+ <DefinitionList
64
+ layout={layout}
65
+ muted={muted}
66
+ definitions={[
67
+ ...definitions,
68
+ {
69
+ title: 'Action buttons are useful',
70
+ value: 'You can do all kinds of neat things with actions buttons!',
71
+ key: 'fourth',
72
+ action: {
73
+ label: 'Epic button',
74
+ onClick: action('Probably the best action event you have ever seen, in the world!'),
75
+ },
76
+ },
77
+ {
78
+ title: 'tiny',
79
+ value: 'tiny',
80
+ key: 'fifth',
81
+ action: {
82
+ label: 'Epic button',
83
+ onClick: action('Hello from the Tiny Button :)'),
84
+ },
85
+ },
86
+ ]}
87
+ />
88
+ );
89
89
  };
@@ -13,7 +13,7 @@ export interface DefinitionListDefinition {
13
13
  key: string;
14
14
  }
15
15
 
16
- export type DefinitionListLayout =
16
+ type DefinitionListLayout =
17
17
  `${Layout.VERTICAL_TWO_COLUMN | Layout.VERTICAL_ONE_COLUMN | Layout.HORIZONTAL_JUSTIFIED | Layout.HORIZONTAL_LEFT_ALIGNED | Layout.HORIZONTAL_RIGHT_ALIGNED}`;
18
18
 
19
19
  export interface DefinitionListProps {
@@ -12,7 +12,7 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
12
12
  aria-disabled="false"
13
13
  aria-label="back to previous step"
14
14
  aria-live="off"
15
- class="wds-Button np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
15
+ class="np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
16
16
  style="--circle-size: 40px; --circle-icon-size: 20px; --circle-font-size: 18px;"
17
17
  type="button"
18
18
  >
package/src/i18n/de.json CHANGED
@@ -54,7 +54,6 @@
54
54
  "neptune.UploadButton.allFileTypes": "Alle Dateiformate",
55
55
  "neptune.UploadButton.dropFiles": "Datei zum Hochladen in dieses Feld ziehen",
56
56
  "neptune.UploadButton.instructions": "{fileTypes}, kleiner als {size} MB",
57
- "neptune.UploadButton.maximumFiles": "Maximal {maxFiles} Dateien.",
58
57
  "neptune.UploadButton.uploadFile": "Datei hochladen",
59
58
  "neptune.UploadButton.uploadFiles": "Dateien hochladen",
60
59
  "neptune.UploadInput.deleteModalBody": "Wenn du diese Datei entfernst, wird sie aus unserem System gelöscht werden.",
package/src/i18n/it.json CHANGED
@@ -54,7 +54,6 @@
54
54
  "neptune.UploadButton.allFileTypes": "Tutti i tipi di file",
55
55
  "neptune.UploadButton.dropFiles": "Rilascia file per iniziare a caricare",
56
56
  "neptune.UploadButton.instructions": "{fileTypes}, minore di {size}MB",
57
- "neptune.UploadButton.maximumFiles": "Max {maxFiles} file.",
58
57
  "neptune.UploadButton.uploadFile": "Carica un file",
59
58
  "neptune.UploadButton.uploadFiles": "Carica i file",
60
59
  "neptune.UploadInput.deleteModalBody": "Rimuovere questo file lo cancellerà dal nostro sistema.",
package/src/i18n/th.json CHANGED
@@ -54,7 +54,6 @@
54
54
  "neptune.UploadButton.allFileTypes": "ไฟล์ทุกประเภท",
55
55
  "neptune.UploadButton.dropFiles": "วางไฟล์เพื่อเริ่มการอัปโหลด",
56
56
  "neptune.UploadButton.instructions": "{fileTypes} น้อยกว่า {size} MB",
57
- "neptune.UploadButton.maximumFiles": "สูงสุด {maxFiles} ไฟล์",
58
57
  "neptune.UploadButton.uploadFile": "อัปโหลดไฟล์",
59
58
  "neptune.UploadButton.uploadFiles": "อัปโหลดไฟล์",
60
59
  "neptune.UploadInput.deleteModalBody": "การลบไฟล์นี้จะลบออกจากระบบของเรา",