@transferwise/components 0.0.0-experimental-c7e5a27 → 0.0.0-experimental-b35e8bc

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.
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var clsx = require('clsx');
3
4
  var React = require('react');
4
5
  require('../common/theme.js');
5
6
  require('../common/direction.js');
@@ -21,22 +22,24 @@ require('../common/propsValues/scroll.js');
21
22
  require('../common/propsValues/markdownNodeType.js');
22
23
  require('../common/fileType.js');
23
24
  require('@transferwise/icons');
24
- require('clsx');
25
25
  require('react-intl');
26
26
  require('../common/closeButton/CloseButton.messages.js');
27
27
  var jsxRuntime = require('react/jsx-runtime');
28
- var Button_resolver = require('../button/Button.resolver.js');
29
28
 
30
29
  const ActionButton = /*#__PURE__*/React.forwardRef(({
30
+ disabled = false,
31
+ className = undefined,
32
+ onClick,
31
33
  priority = control.Priority.PRIMARY,
32
34
  text,
33
35
  children,
34
36
  ...rest
35
- }, reference) => /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
37
+ }, reference) => /*#__PURE__*/jsxRuntime.jsx("button", {
36
38
  ref: reference,
37
- v2: true,
38
- size: "sm",
39
- priority: priority === 'secondary' ? 'secondary-neutral' : priority,
39
+ type: "button",
40
+ className: clsx.clsx('np-action-btn', 'np-text-body-default-bold', priority === control.Priority.TERTIARY ? 'btn-priority-3' : priority === control.Priority.SECONDARY ? 'btn-priority-2' : 'btn-priority-1', className),
41
+ disabled: disabled,
42
+ onClick: onClick,
40
43
  ...rest,
41
44
  children: children || text
42
45
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"ActionButton.js","sources":["../../src/actionButton/ActionButton.tsx"],"sourcesContent":["import { ButtonHTMLAttributes, forwardRef } from 'react';\n\nimport { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';\nimport Button from '../button';\n\n/**\n * @deprecated use `<Button />` component instead with `ButtonProps`\n */\nexport type ActionButtonProps = {\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;\n /**\n * @deprecated use `children` instead\n */\n text?: string;\n} & ButtonHTMLAttributes<HTMLButtonElement>;\n\n/**\n * @deprecated use `<Button v2 size=\"sm\" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ priority = Priority.PRIMARY, text, children, ...rest }: ActionButtonProps, reference) => (\n <Button\n ref={reference}\n v2\n size=\"sm\"\n priority={priority === 'secondary' ? 'secondary-neutral' : priority}\n {...rest}\n >\n {children || text}\n </Button>\n ),\n);\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","priority","Priority","PRIMARY","text","children","rest","reference","_jsx","Button","ref","v2","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAY,gBAAGC,gBAAU,CAC7B,CAAC;EAAEC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;EAAEC,IAAI;EAAEC,QAAQ;EAAE,GAAGC,IAAAA;AAAI,CAAqB,EAAEC,SAAS,kBACrFC,cAAA,CAACC,eAAM,EAAA;AACLC,EAAAA,GAAG,EAAEH,SAAU;EACfI,EAAE,EAAA,IAAA;AACFC,EAAAA,IAAI,EAAC,IAAI;AACTX,EAAAA,QAAQ,EAAEA,QAAQ,KAAK,WAAW,GAAG,mBAAmB,GAAGA,QAAS;AAAA,EAAA,GAChEK,IAAI;EAAAD,QAAA,EAEPA,QAAQ,IAAID,IAAAA;AAAI,CACX,CACT;;;;"}
1
+ {"version":3,"file":"ActionButton.js","sources":["../../src/actionButton/ActionButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ButtonHTMLAttributes, forwardRef } from 'react';\n\nimport { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';\n\n/**\n * @deprecated use `<Button />` component instead with `ButtonProps`\n */\nexport type ActionButtonProps = {\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;\n /**\n * @deprecated use `children` instead\n */\n text?: string;\n} & ButtonHTMLAttributes<HTMLButtonElement>;\n\n/**\n * @deprecated use `<Button v2 size=\"sm\" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n (\n {\n disabled = false,\n className = undefined,\n onClick,\n priority = Priority.PRIMARY,\n text,\n children,\n ...rest\n }: ActionButtonProps,\n reference,\n ) => (\n <button\n ref={reference}\n type=\"button\"\n className={clsx(\n 'np-action-btn',\n 'np-text-body-default-bold',\n priority === Priority.TERTIARY\n ? 'btn-priority-3'\n : priority === Priority.SECONDARY\n ? 'btn-priority-2'\n : 'btn-priority-1',\n className,\n )}\n disabled={disabled}\n onClick={onClick}\n {...rest}\n >\n {children || text}\n </button>\n ),\n);\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","disabled","className","undefined","onClick","priority","Priority","PRIMARY","text","children","rest","reference","_jsx","ref","type","clsx","TERTIARY","SECONDARY"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAY,gBAAGC,gBAAU,CAC7B,CACE;AACEC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;EACPC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;EAC3BC,IAAI;EACJC,QAAQ;EACR,GAAGC,IAAAA;AACe,CAAA,EACpBC,SAAS,kBAETC,cAAA,CAAA,QAAA,EAAA;AACEC,EAAAA,GAAG,EAAEF,SAAU;AACfG,EAAAA,IAAI,EAAC,QAAQ;EACbZ,SAAS,EAAEa,SAAI,CACb,eAAe,EACf,2BAA2B,EAC3BV,QAAQ,KAAKC,gBAAQ,CAACU,QAAQ,GAC1B,gBAAgB,GAChBX,QAAQ,KAAKC,gBAAQ,CAACW,SAAS,GAC7B,gBAAgB,GAChB,gBAAgB,EACtBf,SAAS,CACT;AACFD,EAAAA,QAAQ,EAAEA,QAAS;AACnBG,EAAAA,OAAO,EAAEA,OAAQ;AAAA,EAAA,GACbM,IAAI;EAAAD,QAAA,EAEPA,QAAQ,IAAID,IAAAA;AAAI,CACX,CACT;;;;"}
@@ -1,3 +1,4 @@
1
+ import { clsx } from 'clsx';
1
2
  import { forwardRef } from 'react';
2
3
  import '../common/theme.mjs';
3
4
  import '../common/direction.mjs';
@@ -19,22 +20,24 @@ import '../common/propsValues/scroll.mjs';
19
20
  import '../common/propsValues/markdownNodeType.mjs';
20
21
  import '../common/fileType.mjs';
21
22
  import '@transferwise/icons';
22
- import 'clsx';
23
23
  import 'react-intl';
24
24
  import '../common/closeButton/CloseButton.messages.mjs';
25
25
  import { jsx } from 'react/jsx-runtime';
26
- import Button from '../button/Button.resolver.mjs';
27
26
 
28
27
  const ActionButton = /*#__PURE__*/forwardRef(({
28
+ disabled = false,
29
+ className = undefined,
30
+ onClick,
29
31
  priority = Priority.PRIMARY,
30
32
  text,
31
33
  children,
32
34
  ...rest
33
- }, reference) => /*#__PURE__*/jsx(Button, {
35
+ }, reference) => /*#__PURE__*/jsx("button", {
34
36
  ref: reference,
35
- v2: true,
36
- size: "sm",
37
- priority: priority === 'secondary' ? 'secondary-neutral' : priority,
37
+ type: "button",
38
+ className: clsx('np-action-btn', 'np-text-body-default-bold', priority === Priority.TERTIARY ? 'btn-priority-3' : priority === Priority.SECONDARY ? 'btn-priority-2' : 'btn-priority-1', className),
39
+ disabled: disabled,
40
+ onClick: onClick,
38
41
  ...rest,
39
42
  children: children || text
40
43
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"ActionButton.mjs","sources":["../../src/actionButton/ActionButton.tsx"],"sourcesContent":["import { ButtonHTMLAttributes, forwardRef } from 'react';\n\nimport { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';\nimport Button from '../button';\n\n/**\n * @deprecated use `<Button />` component instead with `ButtonProps`\n */\nexport type ActionButtonProps = {\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;\n /**\n * @deprecated use `children` instead\n */\n text?: string;\n} & ButtonHTMLAttributes<HTMLButtonElement>;\n\n/**\n * @deprecated use `<Button v2 size=\"sm\" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ priority = Priority.PRIMARY, text, children, ...rest }: ActionButtonProps, reference) => (\n <Button\n ref={reference}\n v2\n size=\"sm\"\n priority={priority === 'secondary' ? 'secondary-neutral' : priority}\n {...rest}\n >\n {children || text}\n </Button>\n ),\n);\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","priority","Priority","PRIMARY","text","children","rest","reference","_jsx","Button","ref","v2","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAY,gBAAGC,UAAU,CAC7B,CAAC;EAAEC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAAEC,IAAI;EAAEC,QAAQ;EAAE,GAAGC,IAAAA;AAAI,CAAqB,EAAEC,SAAS,kBACrFC,GAAA,CAACC,MAAM,EAAA;AACLC,EAAAA,GAAG,EAAEH,SAAU;EACfI,EAAE,EAAA,IAAA;AACFC,EAAAA,IAAI,EAAC,IAAI;AACTX,EAAAA,QAAQ,EAAEA,QAAQ,KAAK,WAAW,GAAG,mBAAmB,GAAGA,QAAS;AAAA,EAAA,GAChEK,IAAI;EAAAD,QAAA,EAEPA,QAAQ,IAAID,IAAAA;AAAI,CACX,CACT;;;;"}
1
+ {"version":3,"file":"ActionButton.mjs","sources":["../../src/actionButton/ActionButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ButtonHTMLAttributes, forwardRef } from 'react';\n\nimport { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';\n\n/**\n * @deprecated use `<Button />` component instead with `ButtonProps`\n */\nexport type ActionButtonProps = {\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary;\n /**\n * @deprecated use `children` instead\n */\n text?: string;\n} & ButtonHTMLAttributes<HTMLButtonElement>;\n\n/**\n * @deprecated use `<Button v2 size=\"sm\" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n (\n {\n disabled = false,\n className = undefined,\n onClick,\n priority = Priority.PRIMARY,\n text,\n children,\n ...rest\n }: ActionButtonProps,\n reference,\n ) => (\n <button\n ref={reference}\n type=\"button\"\n className={clsx(\n 'np-action-btn',\n 'np-text-body-default-bold',\n priority === Priority.TERTIARY\n ? 'btn-priority-3'\n : priority === Priority.SECONDARY\n ? 'btn-priority-2'\n : 'btn-priority-1',\n className,\n )}\n disabled={disabled}\n onClick={onClick}\n {...rest}\n >\n {children || text}\n </button>\n ),\n);\n\nexport default ActionButton;\n"],"names":["ActionButton","forwardRef","disabled","className","undefined","onClick","priority","Priority","PRIMARY","text","children","rest","reference","_jsx","ref","type","clsx","TERTIARY","SECONDARY"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAY,gBAAGC,UAAU,CAC7B,CACE;AACEC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,SAAS,GAAGC,SAAS;EACrBC,OAAO;EACPC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI;EACJC,QAAQ;EACR,GAAGC,IAAAA;AACe,CAAA,EACpBC,SAAS,kBAETC,GAAA,CAAA,QAAA,EAAA;AACEC,EAAAA,GAAG,EAAEF,SAAU;AACfG,EAAAA,IAAI,EAAC,QAAQ;EACbZ,SAAS,EAAEa,IAAI,CACb,eAAe,EACf,2BAA2B,EAC3BV,QAAQ,KAAKC,QAAQ,CAACU,QAAQ,GAC1B,gBAAgB,GAChBX,QAAQ,KAAKC,QAAQ,CAACW,SAAS,GAC7B,gBAAgB,GAChB,gBAAgB,EACtBf,SAAS,CACT;AACFD,EAAAA,QAAQ,EAAEA,QAAS;AACnBG,EAAAA,OAAO,EAAEA,OAAQ;AAAA,EAAA,GACbM,IAAI;EAAAD,QAAA,EAEPA,QAAQ,IAAID,IAAAA;AAAI,CACX,CACT;;;;"}
package/build/main.css CHANGED
@@ -112,6 +112,70 @@
112
112
  color: #5d7079;
113
113
  color: var(--color-content-secondary);
114
114
  }
115
+ .np-action-btn {
116
+ display: inline-flex;
117
+ height: 32px;
118
+ height: var(--size-32);
119
+ padding: 8px 12px;
120
+ padding: var(--size-8) var(--size-12);
121
+ transition: color, background-color 0.15s ease-in-out;
122
+ font-weight: 600;
123
+ font-weight: var(--font-weight-semi-bold);
124
+ font-size: 0.875rem;
125
+ font-size: var(--font-size-14);
126
+ line-height: 1.2;
127
+ line-height: var(--line-height-control);
128
+ border-radius: 10px;
129
+ border-radius: var(--radius-small);
130
+ align-items: center;
131
+ color: var(--color-interactive-control);
132
+ background-color: #00a2dd;
133
+ background-color: var(--color-interactive-accent);
134
+ border-radius: 24px;
135
+ border-radius: var(--radius-large);
136
+ border: none;
137
+ }
138
+ @media (max-width: 320px) {
139
+ .np-action-btn {
140
+ height: 40px;
141
+ height: var(--size-40);
142
+ }
143
+ }
144
+ .np-action-btn.btn-priority-2 {
145
+ background-color: rgba(134,167,189,0.10196);
146
+ background-color: var(--color-background-neutral);
147
+ color: var(--color-interactive-primary);
148
+ }
149
+ .np-action-btn.btn-priority-3 {
150
+ background-color: transparent !important;
151
+ color: var(--color-interactive-primary);
152
+ }
153
+ .np-action-btn:not(:disabled):hover {
154
+ background-color: #008fc9;
155
+ background-color: var(--color-interactive-accent-hover);
156
+ }
157
+ .np-action-btn:not(:disabled):hover.btn-priority-2 {
158
+ background-color: var(--color-background-neutral-hover);
159
+ }
160
+ .np-action-btn:not(:disabled):hover.btn-priority-3 {
161
+ color: var(--color-interactive-primary-hover);
162
+ }
163
+ .np-action-btn:not(:disabled):active {
164
+ box-shadow: none;
165
+ border-color: transparent;
166
+ background-color: #0081ba;
167
+ background-color: var(--color-interactive-accent-active);
168
+ }
169
+ .np-action-btn:not(:disabled):active.btn-priority-2 {
170
+ background-color: var(--color-background-neutral-active);
171
+ }
172
+ .np-action-btn:not(:disabled):active.btn-priority-3 {
173
+ color: var(--color-interactive-primary-active);
174
+ background-color: var(--color-background-screen-active) !important;
175
+ }
176
+ .np-action-btn:not(:disabled):focus {
177
+ box-shadow: none;
178
+ }
115
179
  .wds-alert__liveRegion {
116
180
  display: contents;
117
181
  }
@@ -0,0 +1,64 @@
1
+ .np-action-btn {
2
+ display: inline-flex;
3
+ height: 32px;
4
+ height: var(--size-32);
5
+ padding: 8px 12px;
6
+ padding: var(--size-8) var(--size-12);
7
+ transition: color, background-color 0.15s ease-in-out;
8
+ font-weight: 600;
9
+ font-weight: var(--font-weight-semi-bold);
10
+ font-size: 0.875rem;
11
+ font-size: var(--font-size-14);
12
+ line-height: 1.2;
13
+ line-height: var(--line-height-control);
14
+ border-radius: 10px;
15
+ border-radius: var(--radius-small);
16
+ align-items: center;
17
+ color: var(--color-interactive-control);
18
+ background-color: #00a2dd;
19
+ background-color: var(--color-interactive-accent);
20
+ border-radius: 24px;
21
+ border-radius: var(--radius-large);
22
+ border: none;
23
+ }
24
+ @media (max-width: 320px) {
25
+ .np-action-btn {
26
+ height: 40px;
27
+ height: var(--size-40);
28
+ }
29
+ }
30
+ .np-action-btn.btn-priority-2 {
31
+ background-color: rgba(134,167,189,0.10196);
32
+ background-color: var(--color-background-neutral);
33
+ color: var(--color-interactive-primary);
34
+ }
35
+ .np-action-btn.btn-priority-3 {
36
+ background-color: transparent !important;
37
+ color: var(--color-interactive-primary);
38
+ }
39
+ .np-action-btn:not(:disabled):hover {
40
+ background-color: #008fc9;
41
+ background-color: var(--color-interactive-accent-hover);
42
+ }
43
+ .np-action-btn:not(:disabled):hover.btn-priority-2 {
44
+ background-color: var(--color-background-neutral-hover);
45
+ }
46
+ .np-action-btn:not(:disabled):hover.btn-priority-3 {
47
+ color: var(--color-interactive-primary-hover);
48
+ }
49
+ .np-action-btn:not(:disabled):active {
50
+ box-shadow: none;
51
+ border-color: transparent;
52
+ background-color: #0081ba;
53
+ background-color: var(--color-interactive-accent-active);
54
+ }
55
+ .np-action-btn:not(:disabled):active.btn-priority-2 {
56
+ background-color: var(--color-background-neutral-active);
57
+ }
58
+ .np-action-btn:not(:disabled):active.btn-priority-3 {
59
+ color: var(--color-interactive-primary-active);
60
+ background-color: var(--color-background-screen-active) !important;
61
+ }
62
+ .np-action-btn:not(:disabled):focus {
63
+ box-shadow: none;
64
+ }
@@ -112,6 +112,70 @@
112
112
  color: #5d7079;
113
113
  color: var(--color-content-secondary);
114
114
  }
115
+ .np-action-btn {
116
+ display: inline-flex;
117
+ height: 32px;
118
+ height: var(--size-32);
119
+ padding: 8px 12px;
120
+ padding: var(--size-8) var(--size-12);
121
+ transition: color, background-color 0.15s ease-in-out;
122
+ font-weight: 600;
123
+ font-weight: var(--font-weight-semi-bold);
124
+ font-size: 0.875rem;
125
+ font-size: var(--font-size-14);
126
+ line-height: 1.2;
127
+ line-height: var(--line-height-control);
128
+ border-radius: 10px;
129
+ border-radius: var(--radius-small);
130
+ align-items: center;
131
+ color: var(--color-interactive-control);
132
+ background-color: #00a2dd;
133
+ background-color: var(--color-interactive-accent);
134
+ border-radius: 24px;
135
+ border-radius: var(--radius-large);
136
+ border: none;
137
+ }
138
+ @media (max-width: 320px) {
139
+ .np-action-btn {
140
+ height: 40px;
141
+ height: var(--size-40);
142
+ }
143
+ }
144
+ .np-action-btn.btn-priority-2 {
145
+ background-color: rgba(134,167,189,0.10196);
146
+ background-color: var(--color-background-neutral);
147
+ color: var(--color-interactive-primary);
148
+ }
149
+ .np-action-btn.btn-priority-3 {
150
+ background-color: transparent !important;
151
+ color: var(--color-interactive-primary);
152
+ }
153
+ .np-action-btn:not(:disabled):hover {
154
+ background-color: #008fc9;
155
+ background-color: var(--color-interactive-accent-hover);
156
+ }
157
+ .np-action-btn:not(:disabled):hover.btn-priority-2 {
158
+ background-color: var(--color-background-neutral-hover);
159
+ }
160
+ .np-action-btn:not(:disabled):hover.btn-priority-3 {
161
+ color: var(--color-interactive-primary-hover);
162
+ }
163
+ .np-action-btn:not(:disabled):active {
164
+ box-shadow: none;
165
+ border-color: transparent;
166
+ background-color: #0081ba;
167
+ background-color: var(--color-interactive-accent-active);
168
+ }
169
+ .np-action-btn:not(:disabled):active.btn-priority-2 {
170
+ background-color: var(--color-background-neutral-active);
171
+ }
172
+ .np-action-btn:not(:disabled):active.btn-priority-3 {
173
+ color: var(--color-interactive-primary-active);
174
+ background-color: var(--color-background-screen-active) !important;
175
+ }
176
+ .np-action-btn:not(:disabled):focus {
177
+ box-shadow: none;
178
+ }
115
179
  .wds-alert__liveRegion {
116
180
  display: contents;
117
181
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ActionButton.d.ts","sourceRoot":"","sources":["../../../src/actionButton/ActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAY,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG3F;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAClE;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAE5C;;GAEG;AACH,QAAA,MAAM,YAAY;eAVL,eAAe,GAAG,iBAAiB,GAAG,gBAAgB;IACjE;;OAEG;WACI,MAAM;+FAkBd,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ActionButton.d.ts","sourceRoot":"","sources":["../../../src/actionButton/ActionButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAY,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAClE;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAE5C;;GAEG;AACH,QAAA,MAAM,YAAY;eAVL,eAAe,GAAG,iBAAiB,GAAG,gBAAgB;IACjE;;OAEG;WACI,MAAM;+FAuCd,CAAC;AAEF,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-c7e5a27",
3
+ "version": "0.0.0-experimental-b35e8bc",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -91,13 +91,13 @@
91
91
  "rollup": "^4.18.1",
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
- "@transferwise/less-config": "3.1.0",
95
- "@transferwise/neptune-css": "0.0.0-experimental-c7e5a27",
96
- "@wise/components-theming": "1.6.1"
94
+ "@transferwise/neptune-css": "0.0.0-experimental-b35e8bc",
95
+ "@wise/components-theming": "1.6.1",
96
+ "@transferwise/less-config": "3.1.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
100
- "@transferwise/neptune-css": "0.0.0-experimental-c7e5a27",
100
+ "@transferwise/neptune-css": "0.0.0-experimental-b35e8bc",
101
101
  "@wise/art": "^2.16",
102
102
  "@wise/components-theming": "^1.0.0",
103
103
  "react": ">=18",
@@ -0,0 +1,64 @@
1
+ .np-action-btn {
2
+ display: inline-flex;
3
+ height: 32px;
4
+ height: var(--size-32);
5
+ padding: 8px 12px;
6
+ padding: var(--size-8) var(--size-12);
7
+ transition: color, background-color 0.15s ease-in-out;
8
+ font-weight: 600;
9
+ font-weight: var(--font-weight-semi-bold);
10
+ font-size: 0.875rem;
11
+ font-size: var(--font-size-14);
12
+ line-height: 1.2;
13
+ line-height: var(--line-height-control);
14
+ border-radius: 10px;
15
+ border-radius: var(--radius-small);
16
+ align-items: center;
17
+ color: var(--color-interactive-control);
18
+ background-color: #00a2dd;
19
+ background-color: var(--color-interactive-accent);
20
+ border-radius: 24px;
21
+ border-radius: var(--radius-large);
22
+ border: none;
23
+ }
24
+ @media (max-width: 320px) {
25
+ .np-action-btn {
26
+ height: 40px;
27
+ height: var(--size-40);
28
+ }
29
+ }
30
+ .np-action-btn.btn-priority-2 {
31
+ background-color: rgba(134,167,189,0.10196);
32
+ background-color: var(--color-background-neutral);
33
+ color: var(--color-interactive-primary);
34
+ }
35
+ .np-action-btn.btn-priority-3 {
36
+ background-color: transparent !important;
37
+ color: var(--color-interactive-primary);
38
+ }
39
+ .np-action-btn:not(:disabled):hover {
40
+ background-color: #008fc9;
41
+ background-color: var(--color-interactive-accent-hover);
42
+ }
43
+ .np-action-btn:not(:disabled):hover.btn-priority-2 {
44
+ background-color: var(--color-background-neutral-hover);
45
+ }
46
+ .np-action-btn:not(:disabled):hover.btn-priority-3 {
47
+ color: var(--color-interactive-primary-hover);
48
+ }
49
+ .np-action-btn:not(:disabled):active {
50
+ box-shadow: none;
51
+ border-color: transparent;
52
+ background-color: #0081ba;
53
+ background-color: var(--color-interactive-accent-active);
54
+ }
55
+ .np-action-btn:not(:disabled):active.btn-priority-2 {
56
+ background-color: var(--color-background-neutral-active);
57
+ }
58
+ .np-action-btn:not(:disabled):active.btn-priority-3 {
59
+ color: var(--color-interactive-primary-active);
60
+ background-color: var(--color-background-screen-active) !important;
61
+ }
62
+ .np-action-btn:not(:disabled):focus {
63
+ box-shadow: none;
64
+ }
@@ -0,0 +1,64 @@
1
+ @import (reference) "../../node_modules/@transferwise/neptune-css/src/less/ring.less";
2
+
3
+ .np-action-btn {
4
+ display: inline-flex;
5
+ height: var(--size-32);
6
+ padding: var(--size-8) var(--size-12);
7
+ transition: color, background-color 0.15s ease-in-out;
8
+ font-weight: var(--font-weight-semi-bold);
9
+ font-size: var(--font-size-14);
10
+ line-height: var(--line-height-control);
11
+ border-radius: var(--radius-small);
12
+ align-items: center;
13
+ color: var(--color-interactive-control);
14
+ background-color: var(--color-interactive-accent);
15
+ border-radius: var(--radius-large);
16
+ border: none;
17
+
18
+ @media (--screen-400-zoom) {
19
+ height: var(--size-40);
20
+ }
21
+
22
+ &.btn-priority-2 {
23
+ background-color: var(--color-background-neutral);
24
+ color: var(--color-interactive-primary);
25
+ }
26
+
27
+ &.btn-priority-3 {
28
+ background-color: transparent !important;
29
+ color: var(--color-interactive-primary);
30
+ }
31
+
32
+ &:not(:disabled) {
33
+ &:hover {
34
+ background-color: var(--color-interactive-accent-hover);
35
+
36
+ &.btn-priority-2 {
37
+ background-color: var(--color-background-neutral-hover);
38
+ }
39
+
40
+ &.btn-priority-3 {
41
+ color: var(--color-interactive-primary-hover);
42
+ }
43
+ }
44
+
45
+ &:active {
46
+ box-shadow: none;
47
+ border-color: transparent;
48
+ background-color: var(--color-interactive-accent-active);
49
+
50
+ &.btn-priority-2 {
51
+ background-color: var(--color-background-neutral-active);
52
+ }
53
+
54
+ &.btn-priority-3 {
55
+ color: var(--color-interactive-primary-active);
56
+ background-color: var(--color-background-screen-active) !important;
57
+ }
58
+ }
59
+
60
+ &:focus {
61
+ box-shadow: none;
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,82 @@
1
+ import { render, screen, userEvent } from '../test-utils';
2
+
3
+ import ActionButton from '.';
4
+
5
+ describe('ActionButton', () => {
6
+ const props = {
7
+ children: 'Personal profile',
8
+ onClick: jest.fn(),
9
+ };
10
+
11
+ describe('by default', () => {
12
+ beforeEach(() => {
13
+ render(<ActionButton {...props} />);
14
+ });
15
+
16
+ it('renders the text', () => {
17
+ expect(screen.getByText('Personal profile')).toBeInTheDocument();
18
+ });
19
+
20
+ it('is not disabled', () => {
21
+ expect(screen.getByRole('button')).toBeEnabled();
22
+ });
23
+
24
+ it('renders the button', () => {
25
+ expect(render(<ActionButton {...props} />).container).toMatchSnapshot();
26
+ });
27
+ });
28
+
29
+ describe('button attributes', () => {
30
+ it('disables the button if disabled', () => {
31
+ render(<ActionButton {...props} disabled />);
32
+ expect(screen.getByRole('button')).toBeDisabled();
33
+ });
34
+
35
+ it('passes through custom classes if set', () => {
36
+ render(<ActionButton {...props} className="catsarethebest" />);
37
+ expect(screen.getByRole('button')).toHaveClass('catsarethebest');
38
+ });
39
+ });
40
+
41
+ describe('onClick', () => {
42
+ it('calls onClick when clicked', async () => {
43
+ const onClick = jest.fn();
44
+ render(<ActionButton {...props} onClick={onClick} />);
45
+ await userEvent.click(screen.getByRole('button'));
46
+ expect(onClick).toHaveBeenCalledTimes(1);
47
+ });
48
+
49
+ it('does not call onClick when clicked if disabled', async () => {
50
+ const onClick = jest.fn();
51
+ render(<ActionButton {...props} disabled onClick={onClick} />);
52
+ await userEvent.click(screen.getByRole('button'));
53
+ expect(onClick).toHaveBeenCalledTimes(0);
54
+ });
55
+ });
56
+
57
+ describe('deprecated', () => {
58
+ it('text prop', () => {
59
+ const copy = 'Text prop';
60
+ const onClick = jest.fn();
61
+ render(<ActionButton disabled text={copy} onClick={onClick} />);
62
+ expect(screen.getByText(copy)).toBeInTheDocument();
63
+ });
64
+ });
65
+
66
+ describe('priority', () => {
67
+ it('is rendered for primary', () => {
68
+ render(<ActionButton priority="primary" />);
69
+ expect(screen.getByRole('button')).toHaveClass('btn-priority-1');
70
+ });
71
+
72
+ it('is rendered for secondary', () => {
73
+ render(<ActionButton priority="secondary" />);
74
+ expect(screen.getByRole('button')).toHaveClass('btn-priority-2');
75
+ });
76
+
77
+ it('is backwards compatible if nothing is passed in', () => {
78
+ render(<ActionButton />);
79
+ expect(screen.getByRole('button')).toHaveClass('btn-priority-1');
80
+ });
81
+ });
82
+ });
@@ -1,7 +1,7 @@
1
+ import { clsx } from 'clsx';
1
2
  import { ButtonHTMLAttributes, forwardRef } from 'react';
2
3
 
3
4
  import { Priority, PriorityPrimary, PrioritySecondary, PriorityTertiary } from '../common';
4
- import Button from '../button';
5
5
 
6
6
  /**
7
7
  * @deprecated use `<Button />` component instead with `ButtonProps`
@@ -18,16 +18,37 @@ export type ActionButtonProps = {
18
18
  * @deprecated use `<Button v2 size="sm" priority={'primary' / 'secondary-neutral' / 'tertiary'} .. />` component instead
19
19
  */
20
20
  const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(
21
- ({ priority = Priority.PRIMARY, text, children, ...rest }: ActionButtonProps, reference) => (
22
- <Button
21
+ (
22
+ {
23
+ disabled = false,
24
+ className = undefined,
25
+ onClick,
26
+ priority = Priority.PRIMARY,
27
+ text,
28
+ children,
29
+ ...rest
30
+ }: ActionButtonProps,
31
+ reference,
32
+ ) => (
33
+ <button
23
34
  ref={reference}
24
- v2
25
- size="sm"
26
- priority={priority === 'secondary' ? 'secondary-neutral' : priority}
35
+ type="button"
36
+ className={clsx(
37
+ 'np-action-btn',
38
+ 'np-text-body-default-bold',
39
+ priority === Priority.TERTIARY
40
+ ? 'btn-priority-3'
41
+ : priority === Priority.SECONDARY
42
+ ? 'btn-priority-2'
43
+ : 'btn-priority-1',
44
+ className,
45
+ )}
46
+ disabled={disabled}
47
+ onClick={onClick}
27
48
  {...rest}
28
49
  >
29
50
  {children || text}
30
- </Button>
51
+ </button>
31
52
  ),
32
53
  );
33
54
 
@@ -0,0 +1,12 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ActionButton by default renders the button 1`] = `
4
+ <div>
5
+ <button
6
+ class="np-action-btn np-text-body-default-bold btn-priority-1"
7
+ type="button"
8
+ >
9
+ Personal profile
10
+ </button>
11
+ </div>
12
+ `;
package/src/main.css CHANGED
@@ -112,6 +112,70 @@
112
112
  color: #5d7079;
113
113
  color: var(--color-content-secondary);
114
114
  }
115
+ .np-action-btn {
116
+ display: inline-flex;
117
+ height: 32px;
118
+ height: var(--size-32);
119
+ padding: 8px 12px;
120
+ padding: var(--size-8) var(--size-12);
121
+ transition: color, background-color 0.15s ease-in-out;
122
+ font-weight: 600;
123
+ font-weight: var(--font-weight-semi-bold);
124
+ font-size: 0.875rem;
125
+ font-size: var(--font-size-14);
126
+ line-height: 1.2;
127
+ line-height: var(--line-height-control);
128
+ border-radius: 10px;
129
+ border-radius: var(--radius-small);
130
+ align-items: center;
131
+ color: var(--color-interactive-control);
132
+ background-color: #00a2dd;
133
+ background-color: var(--color-interactive-accent);
134
+ border-radius: 24px;
135
+ border-radius: var(--radius-large);
136
+ border: none;
137
+ }
138
+ @media (max-width: 320px) {
139
+ .np-action-btn {
140
+ height: 40px;
141
+ height: var(--size-40);
142
+ }
143
+ }
144
+ .np-action-btn.btn-priority-2 {
145
+ background-color: rgba(134,167,189,0.10196);
146
+ background-color: var(--color-background-neutral);
147
+ color: var(--color-interactive-primary);
148
+ }
149
+ .np-action-btn.btn-priority-3 {
150
+ background-color: transparent !important;
151
+ color: var(--color-interactive-primary);
152
+ }
153
+ .np-action-btn:not(:disabled):hover {
154
+ background-color: #008fc9;
155
+ background-color: var(--color-interactive-accent-hover);
156
+ }
157
+ .np-action-btn:not(:disabled):hover.btn-priority-2 {
158
+ background-color: var(--color-background-neutral-hover);
159
+ }
160
+ .np-action-btn:not(:disabled):hover.btn-priority-3 {
161
+ color: var(--color-interactive-primary-hover);
162
+ }
163
+ .np-action-btn:not(:disabled):active {
164
+ box-shadow: none;
165
+ border-color: transparent;
166
+ background-color: #0081ba;
167
+ background-color: var(--color-interactive-accent-active);
168
+ }
169
+ .np-action-btn:not(:disabled):active.btn-priority-2 {
170
+ background-color: var(--color-background-neutral-active);
171
+ }
172
+ .np-action-btn:not(:disabled):active.btn-priority-3 {
173
+ color: var(--color-interactive-primary-active);
174
+ background-color: var(--color-background-screen-active) !important;
175
+ }
176
+ .np-action-btn:not(:disabled):focus {
177
+ box-shadow: none;
178
+ }
115
179
  .wds-alert__liveRegion {
116
180
  display: contents;
117
181
  }
package/src/main.less CHANGED
@@ -1,5 +1,6 @@
1
1
  @import "./criticalBanner/CriticalCommsBanner.less";
2
2
  @import "./accordion/Accordion.less";
3
+ @import "./actionButton/ActionButton.less";
3
4
  @import "./alert/Alert.less";
4
5
  @import "./avatar/Avatar.less";
5
6
  @import "./avatarView/AvatarView.less";