@transferwise/components 0.0.0-experimental-2b935a9 → 0.0.0-experimental-8eba5d3

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 (51) hide show
  1. package/build/index.js +96 -132
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +94 -130
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/checkbox/Checkbox.d.ts +16 -20
  6. package/build/types/checkbox/Checkbox.d.ts.map +1 -1
  7. package/build/types/checkbox/index.d.ts +2 -2
  8. package/build/types/checkbox/index.d.ts.map +1 -1
  9. package/build/types/decision/Decision.d.ts +1 -1
  10. package/build/types/decision/Decision.d.ts.map +1 -1
  11. package/build/types/definitionList/DefinitionList.d.ts +20 -24
  12. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  13. package/build/types/definitionList/index.d.ts +2 -1
  14. package/build/types/definitionList/index.d.ts.map +1 -1
  15. package/build/types/index.d.ts +2 -0
  16. package/build/types/index.d.ts.map +1 -1
  17. package/build/types/logo/Logo.d.ts +16 -23
  18. package/build/types/logo/Logo.d.ts.map +1 -1
  19. package/build/types/logo/index.d.ts +1 -2
  20. package/build/types/logo/index.d.ts.map +1 -1
  21. package/build/types/tile/Tile.d.ts +37 -17
  22. package/build/types/tile/Tile.d.ts.map +1 -1
  23. package/build/types/tile/index.d.ts +1 -1
  24. package/build/types/tile/index.d.ts.map +1 -1
  25. package/package.json +3 -3
  26. package/src/checkbox/{Checkbox.spec.js → Checkbox.spec.tsx} +5 -5
  27. package/src/checkbox/{Checkbox.js → Checkbox.tsx} +19 -41
  28. package/src/checkbox/index.ts +2 -0
  29. package/src/decision/Decision.tsx +1 -1
  30. package/src/definitionList/{DefinitionList.story.js → DefinitionList.story.tsx} +22 -2
  31. package/src/definitionList/DefinitionList.tsx +95 -0
  32. package/src/definitionList/index.ts +2 -0
  33. package/src/index.ts +2 -0
  34. package/src/logo/Logo.story.tsx +3 -6
  35. package/src/logo/{Logo.js → Logo.tsx} +25 -35
  36. package/src/logo/index.ts +1 -0
  37. package/src/tile/{Tile.tsx → Tile.js} +35 -24
  38. package/src/tile/{Tile.spec.tsx → Tile.spec.js} +1 -1
  39. package/build/types/logo/logoTypes.d.ts +0 -6
  40. package/build/types/logo/logoTypes.d.ts.map +0 -1
  41. package/src/checkbox/index.js +0 -3
  42. package/src/definitionList/DefinitionList.js +0 -100
  43. package/src/definitionList/index.js +0 -1
  44. package/src/logo/index.js +0 -2
  45. package/src/logo/logoTypes.ts +0 -6
  46. /package/src/checkbox/__snapshots__/{Checkbox.spec.js.snap → Checkbox.spec.tsx.snap} +0 -0
  47. /package/src/logo/{Logo.spec.js → Logo.spec.tsx} +0 -0
  48. /package/src/logo/__snapshots__/{Logo.spec.js.snap → Logo.spec.tsx.snap} +0 -0
  49. /package/src/tile/{Tile.story.tsx → Tile.story.js} +0 -0
  50. /package/src/tile/__snapshots__/{Tile.spec.tsx.snap → Tile.spec.js.snap} +0 -0
  51. /package/src/tile/{index.ts → index.js} +0 -0
@@ -1,14 +1,11 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
 
3
- import Logo, { LogoType } from '.';
3
+ import Logo from '.';
4
4
 
5
5
  export default {
6
6
  component: Logo,
7
7
  title: 'Content/Logo',
8
- render: (args) => {
9
- const type = args.type as LogoType;
10
- const inverse = args.inverse as boolean;
11
-
8
+ render: ({ inverse, type }) => {
12
9
  return (
13
10
  <div className={`${inverse ? 'bg--dark' : ''} p-a-3`}>
14
11
  <Logo type={type} inverse={inverse} />
@@ -22,7 +19,7 @@ type Story = StoryObj<typeof Logo>;
22
19
 
23
20
  export const Basic: Story = {
24
21
  args: {
25
- type: LogoType.WISE,
22
+ type: 'WISE',
26
23
  inverse: false,
27
24
  },
28
25
  };
@@ -1,7 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import PropTypes from 'prop-types';
3
2
 
4
- import { LogoType } from './logoTypes';
5
3
  import { ReactComponent as LogoFlagInverse } from './svg/flag-inverse.svg';
6
4
  import { ReactComponent as LogoFlagPlatformInverse } from './svg/flag-platform-white.svg';
7
5
  import { ReactComponent as LogoFlagPlatform } from './svg/flag-platform.svg';
@@ -24,44 +22,36 @@ const svgPaths = {
24
22
  WISE_FLAG_PLATFORM_INVERSE: LogoFlagPlatformInverse,
25
23
  };
26
24
 
27
- const Logo = ({ className, inverse, type }) => {
25
+ export enum LogoType {
26
+ WISE = 'WISE',
27
+ WISE_BUSINESS = 'WISE_BUSINESS',
28
+ WISE_PLATFORM = 'WISE_PLATFORM',
29
+ }
30
+
31
+ export interface LogoProps {
32
+ /** Extra classes applied to Logo */
33
+ className?: string;
34
+ /** If true, will use dark colours for dark on light theme */
35
+ inverse?: boolean;
36
+ /** What type of logo to display */
37
+ type?: `${LogoType}`;
38
+ }
39
+
40
+ const labelByType = {
41
+ WISE: 'Wise',
42
+ WISE_BUSINESS: 'Wise Business',
43
+ WISE_PLATFORM: 'Wise Platform',
44
+ } satisfies Record<`${LogoType}`, string>;
45
+
46
+ export default function Logo({ className, inverse, type = 'WISE' }: LogoProps) {
28
47
  const LogoSm =
29
- svgPaths[
30
- `WISE_FLAG${type === LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`
31
- ];
48
+ svgPaths[`WISE_FLAG${type === 'WISE_PLATFORM' ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
32
49
  const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
33
50
 
34
51
  return (
35
- <span
36
- aria-label={
37
- type === LogoType.WISE
38
- ? 'Wise'
39
- : 'Wise Business' | (type === LogoType.WISE_PLATFORM)
40
- ? 'Wise Platform'
41
- : 'Wise Business'
42
- }
43
- role="img"
44
- className={classNames(className, 'np-logo')}
45
- >
52
+ <span aria-label={labelByType[type]} role="img" className={classNames(className, 'np-logo')}>
46
53
  <LogoSm className="np-logo-svg np-logo-svg--size-sm" />
47
54
  <LogoMd className="np-logo-svg np-logo-svg--size-md" />
48
55
  </span>
49
56
  );
50
- };
51
-
52
- Logo.propTypes = {
53
- /** Extra classes applied to Logo */
54
- className: PropTypes.string,
55
- /** If true, will use dark colours for dark on light theme */
56
- inverse: PropTypes.bool,
57
- /** What type of logo to display */
58
- type: PropTypes.oneOf(['WISE', 'WISE_BUSINESS', 'WISE_PLATFORM']),
59
- };
60
-
61
- Logo.defaultProps = {
62
- className: undefined,
63
- inverse: false,
64
- type: LogoType.WISE,
65
- };
66
-
67
- export default Logo;
57
+ }
@@ -0,0 +1 @@
1
+ export { default, LogoType } from './Logo';
@@ -1,26 +1,11 @@
1
1
  import classNames from 'classnames';
2
+ import PropTypes from 'prop-types';
2
3
 
3
4
  import Body from '../body';
4
5
  import { Size, Typography } from '../common';
5
6
  import Title from '../title';
6
7
 
7
- export interface TileProps {
8
- /** Classes to apply to the Tile container */
9
- className?: string;
10
- description?: React.ReactNode;
11
- disabled?: boolean;
12
- href?: string;
13
- target?: React.HTMLAttributeAnchorTarget;
14
- /** Accepts only Avatar and images */
15
- media: React.ReactNode;
16
- /** Function called onClick or onKeyDown */
17
- onClick?: (event?: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
18
- /** The size applied to Tile */
19
- size?: `${Size.SMALL | Size.MEDIUM}`;
20
- title: React.ReactNode;
21
- }
22
-
23
- export default function Tile({
8
+ export const Tile = ({
24
9
  className,
25
10
  description,
26
11
  disabled,
@@ -28,10 +13,10 @@ export default function Tile({
28
13
  target,
29
14
  media,
30
15
  onClick,
31
- size = 'md',
16
+ size,
32
17
  title,
33
- }: TileProps) {
34
- const isSmall = size === 'sm';
18
+ }) => {
19
+ const isSmall = size === Size.SMALL;
35
20
  const Element = href ? 'a' : 'button';
36
21
 
37
22
  return (
@@ -51,13 +36,13 @@ export default function Tile({
51
36
  )}
52
37
  href={href}
53
38
  target={target}
54
- onClick={disabled ? undefined : onClick}
39
+ onClick={disabled ? null : onClick}
55
40
  onKeyDown={
56
41
  disabled
57
- ? undefined
42
+ ? null
58
43
  : ({ key }) => {
59
44
  if (key === 'Enter' || key === ' ') {
60
- onClick?.();
45
+ onClick();
61
46
  }
62
47
  }
63
48
  }
@@ -73,4 +58,30 @@ export default function Tile({
73
58
  ) : null}
74
59
  </Element>
75
60
  );
76
- }
61
+ };
62
+
63
+ Tile.propTypes = {
64
+ /** Classes to apply to the Tile container */
65
+ className: PropTypes.string,
66
+ description: PropTypes.node,
67
+ disabled: PropTypes.bool,
68
+ href: PropTypes.string,
69
+ target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
70
+ /** Accepts only Avatar and images */
71
+ media: PropTypes.node.isRequired,
72
+ /** Function called onClick or onKeyDown */
73
+ onClick: PropTypes.func,
74
+ /** The size applied to Tile */
75
+ size: PropTypes.oneOf(['sm', 'md']),
76
+ title: PropTypes.node.isRequired,
77
+ };
78
+
79
+ Tile.defaultProps = {
80
+ className: '',
81
+ description: null,
82
+ disabled: false,
83
+ size: Size.MEDIUM,
84
+ target: undefined,
85
+ };
86
+
87
+ export default Tile;
@@ -9,7 +9,7 @@ describe(Tile, () => {
9
9
  description: 'Receive money from friends and family like a local',
10
10
  href: '#href',
11
11
  media: <svg data-testid="illustration" />,
12
- onClick,
12
+ onClick: () => onClick(),
13
13
  title: 'Receive money',
14
14
  };
15
15
 
@@ -1,6 +0,0 @@
1
- export declare enum LogoType {
2
- WISE = "WISE",
3
- WISE_BUSINESS = "WISE_BUSINESS",
4
- WISE_PLATFORM = "WISE_PLATFORM"
5
- }
6
- //# sourceMappingURL=logoTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logoTypes.d.ts","sourceRoot":"","sources":["../../../src/logo/logoTypes.ts"],"names":[],"mappings":"AACA,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;CAChC"}
@@ -1,3 +0,0 @@
1
- import Checkbox from './Checkbox';
2
-
3
- export default Checkbox;
@@ -1,100 +0,0 @@
1
- import classNames from 'classnames';
2
- import PropTypes from 'prop-types';
3
-
4
- import ActionButton from '../actionButton';
5
- import { Layout } from '../common';
6
-
7
- const isLayoutHorizontal = (layout) =>
8
- [
9
- Layout.HORIZONTAL_LEFT_ALIGNED,
10
- Layout.HORIZONTAL_RIGHT_ALIGNED,
11
- Layout.HORIZONTAL_JUSTIFIED,
12
- ].includes(layout);
13
-
14
- const getAlignmentClasses = (layout, action) => {
15
- let classes = ['d-flex'];
16
-
17
- if (action) {
18
- if (isLayoutHorizontal(layout)) {
19
- classes.push('align-items-center');
20
- } else {
21
- classes.push('align-items-start');
22
- }
23
- }
24
-
25
- if (layout === Layout.HORIZONTAL_RIGHT_ALIGNED) {
26
- classes.push('text-sm-right tw-definition-list--right-aligned-desktop');
27
- } else {
28
- classes.push('justify-content-between');
29
- }
30
-
31
- if (layout === Layout.HORIZONTAL_JUSTIFIED) {
32
- classes.push('text-sm-justify');
33
- }
34
-
35
- return classes;
36
- };
37
-
38
- const DefinitionList = ({ definitions, layout, muted }) => (
39
- <dl
40
- className={classNames('tw-definition-list d-flex ', {
41
- 'text-muted': muted,
42
- 'flex-column': layout === Layout.VERTICAL_ONE_COLUMN,
43
- 'tw-definition-list--columns flex-column flex-row--sm': layout === Layout.VERTICAL_TWO_COLUMN,
44
- 'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout),
45
- })}
46
- >
47
- {definitions
48
- .filter((definition) => definition)
49
- .map(({ action, title, value, key }) => (
50
- <div key={key} className="tw-definition-list__item">
51
- <dt>{title}</dt>
52
- <dd className={classNames(...getAlignmentClasses(layout, action))}>
53
- <div>{value}</div>
54
- {action ? (
55
- <div
56
- className={classNames(
57
- isLayoutHorizontal(layout) ? 'p-l-2' : 'p-x-2',
58
- 'tw-definition-list__action',
59
- )}
60
- >
61
- <ActionButton className="tw-definition-list__button" onClick={action.onClick}>
62
- {action.label}
63
- </ActionButton>
64
- </div>
65
- ) : null}
66
- </dd>
67
- </div>
68
- ))}
69
- </dl>
70
- );
71
-
72
- DefinitionList.propTypes = {
73
- definitions: PropTypes.arrayOf(
74
- PropTypes.shape({
75
- action: PropTypes.shape({
76
- label: PropTypes.string.isRequired,
77
- onClick: PropTypes.func,
78
- }),
79
- title: PropTypes.node.isRequired,
80
- value: PropTypes.node.isRequired,
81
- key: PropTypes.string.isRequired,
82
- }),
83
- ),
84
- layout: PropTypes.oneOf([
85
- 'VERTICAL_TWO_COLUMN',
86
- 'VERTICAL_ONE_COLUMN',
87
- 'HORIZONTAL_JUSTIFIED',
88
- 'HORIZONTAL_LEFT_ALIGNED',
89
- 'HORIZONTAL_RIGHT_ALIGNED',
90
- ]),
91
- muted: PropTypes.bool,
92
- };
93
-
94
- DefinitionList.defaultProps = {
95
- definitions: [],
96
- layout: Layout.VERTICAL_TWO_COLUMN,
97
- muted: false,
98
- };
99
-
100
- export default DefinitionList;
@@ -1 +0,0 @@
1
- export { default } from './DefinitionList';
package/src/logo/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { LogoType } from './logoTypes';
2
- export { default } from './Logo';
@@ -1,6 +0,0 @@
1
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export enum LogoType {
3
- WISE = 'WISE',
4
- WISE_BUSINESS = 'WISE_BUSINESS',
5
- WISE_PLATFORM = 'WISE_PLATFORM',
6
- }
File without changes
File without changes
File without changes