@transferwise/components 0.0.0-experimental-c575215 → 0.0.0-experimental-818845e
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.
- package/build/button/Button.js +6 -8
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +7 -9
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +5 -16
- package/build/button/Button.resolver.js.map +1 -1
- package/build/button/Button.resolver.mjs +5 -16
- package/build/button/Button.resolver.mjs.map +1 -1
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/main.css +7 -27
- package/build/styles/button/Button.css +7 -27
- package/build/styles/button/Button.vars.css +7 -15
- package/build/styles/main.css +7 -27
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +4 -4
- package/build/types/button/Button.resolver.d.ts.map +1 -1
- package/build/types/button/Button.types.d.ts +8 -16
- package/build/types/button/Button.types.d.ts.map +1 -1
- package/build/types/button/LegacyButton.d.ts +1 -1
- package/package.json +5 -5
- package/src/button/Button.css +7 -27
- package/src/button/Button.less +4 -5
- package/src/button/Button.resolver.tsx +8 -15
- package/src/button/Button.spec.tsx +3 -3
- package/src/button/Button.story.tsx +131 -13
- package/src/button/Button.tsx +7 -5
- package/src/button/Button.types.ts +9 -18
- package/src/button/Button.vars.css +7 -15
- package/src/button/Button.vars.less +8 -16
- package/src/button/LegacyButton.story.tsx +1 -1
- package/src/button/LegacyButton.tsx +1 -1
- package/src/main.css +7 -27
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
.wds-Button {
|
|
2
2
|
--Button-background: var(--color-interactive-accent);
|
|
3
3
|
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
4
4
|
--Button-background-active: var(--color-interactive-accent-active);
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
14
14
|
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
15
15
|
--Button-avatar-border-color: var(--color-border-neutral);
|
|
16
|
-
--Button-transition-duration: 150ms;
|
|
17
|
-
--Button-transition-easing: ease-in-out;
|
|
18
16
|
--Button-secondary-background: var(--color-interactive-neutral);
|
|
19
17
|
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
20
18
|
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
@@ -31,29 +29,23 @@
|
|
|
31
29
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
32
30
|
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
33
31
|
--Button-primary-negative-color: var(--color-contrast);
|
|
34
|
-
--Button-primary-
|
|
32
|
+
--Button-primary-negative-avatar-border-color: rgba(255,255,255,0.2);
|
|
35
33
|
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
36
34
|
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
37
35
|
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
38
36
|
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
39
|
-
--Button-secondary-
|
|
37
|
+
--Button-secondary-negative-avatar-border-color: rgba(168,32,13,0.12157);
|
|
40
38
|
}
|
|
41
39
|
.np-theme-personal--dark .wds-Button {
|
|
42
|
-
--Button-primary-
|
|
40
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
43
41
|
}
|
|
44
42
|
.np-theme-personal--forest-green .wds-Button {
|
|
45
|
-
--
|
|
46
|
-
--
|
|
47
|
-
--color-interactive-neutral-active: rgba(236,255,224,0.2);
|
|
48
|
-
--color-sentiment-negative-secondary: rgba(255,196,194,0.2);
|
|
49
|
-
--color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
|
|
50
|
-
--color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
|
|
51
|
-
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
52
|
-
--Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
43
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
44
|
+
--Button-secondary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
53
45
|
}
|
|
54
46
|
.np-theme-personal--bright-green .wds-Button {
|
|
55
47
|
--color-contrast: #FFFFFF;
|
|
56
48
|
--Button-secondary-color: var(--color-interactive-control);
|
|
57
49
|
--Button-secondary-negative-color: var(--color-contrast);
|
|
58
|
-
--Button-secondary-
|
|
50
|
+
--Button-secondary-negative-avatar-border-color: var(--Button-primary-negative-avatar-border-color);
|
|
59
51
|
}
|
package/build/styles/main.css
CHANGED
|
@@ -716,7 +716,7 @@ div.critical-comms .critical-comms-body {
|
|
|
716
716
|
.np-btn.disabled[class] {
|
|
717
717
|
pointer-events: auto;
|
|
718
718
|
}
|
|
719
|
-
|
|
719
|
+
.wds-Button {
|
|
720
720
|
--Button-background: var(--color-interactive-accent);
|
|
721
721
|
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
722
722
|
--Button-background-active: var(--color-interactive-accent-active);
|
|
@@ -731,8 +731,6 @@ div.critical-comms .critical-comms-body {
|
|
|
731
731
|
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
732
732
|
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
733
733
|
--Button-avatar-border-color: var(--color-border-neutral);
|
|
734
|
-
--Button-transition-duration: 150ms;
|
|
735
|
-
--Button-transition-easing: ease-in-out;
|
|
736
734
|
--Button-secondary-background: var(--color-interactive-neutral);
|
|
737
735
|
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
738
736
|
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
@@ -749,31 +747,25 @@ div.critical-comms .critical-comms-body {
|
|
|
749
747
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
750
748
|
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
751
749
|
--Button-primary-negative-color: var(--color-contrast);
|
|
752
|
-
--Button-primary-
|
|
750
|
+
--Button-primary-negative-avatar-border-color: rgba(255,255,255,0.2);
|
|
753
751
|
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
754
752
|
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
755
753
|
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
756
754
|
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
757
|
-
--Button-secondary-
|
|
755
|
+
--Button-secondary-negative-avatar-border-color: rgba(168,32,13,0.12157);
|
|
758
756
|
}
|
|
759
757
|
.np-theme-personal--dark .wds-Button {
|
|
760
|
-
--Button-primary-
|
|
758
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
761
759
|
}
|
|
762
760
|
.np-theme-personal--forest-green .wds-Button {
|
|
763
|
-
--
|
|
764
|
-
--
|
|
765
|
-
--color-interactive-neutral-active: rgba(236,255,224,0.2);
|
|
766
|
-
--color-sentiment-negative-secondary: rgba(255,196,194,0.2);
|
|
767
|
-
--color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
|
|
768
|
-
--color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
|
|
769
|
-
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
770
|
-
--Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
761
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
762
|
+
--Button-secondary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
771
763
|
}
|
|
772
764
|
.np-theme-personal--bright-green .wds-Button {
|
|
773
765
|
--color-contrast: #FFFFFF;
|
|
774
766
|
--Button-secondary-color: var(--color-interactive-control);
|
|
775
767
|
--Button-secondary-negative-color: var(--color-contrast);
|
|
776
|
-
--Button-secondary-
|
|
768
|
+
--Button-secondary-negative-avatar-border-color: var(--Button-primary-negative-avatar-border-color);
|
|
777
769
|
}
|
|
778
770
|
/* Button Styles */
|
|
779
771
|
.wds-Button {
|
|
@@ -783,13 +775,9 @@ div.critical-comms .critical-comms-body {
|
|
|
783
775
|
align-items: center;
|
|
784
776
|
justify-content: center;
|
|
785
777
|
vertical-align: middle;
|
|
786
|
-
font-weight: 600;
|
|
787
778
|
font-weight: var(--Button-font-weight);
|
|
788
|
-
font-size: 1rem;
|
|
789
779
|
font-size: var(--Button-font-size);
|
|
790
|
-
letter-spacing: -0.011em;
|
|
791
780
|
letter-spacing: var(--Button-letter-spacing);
|
|
792
|
-
line-height: 24px;
|
|
793
781
|
line-height: var(--Button-line-height);
|
|
794
782
|
text-align: center;
|
|
795
783
|
-webkit-text-decoration: none;
|
|
@@ -799,30 +787,23 @@ div.critical-comms .critical-comms-body {
|
|
|
799
787
|
-webkit-appearance: none;
|
|
800
788
|
-moz-appearance: none;
|
|
801
789
|
appearance: none;
|
|
802
|
-
background-color: #00a2dd;
|
|
803
790
|
background-color: var(--Button-background);
|
|
804
791
|
border: none;
|
|
805
|
-
border-radius: 9999px;
|
|
806
792
|
border-radius: var(--Button-border-radius);
|
|
807
793
|
color: var(--Button-color);
|
|
808
794
|
cursor: pointer;
|
|
809
|
-
padding: 8px 12px;
|
|
810
795
|
padding: var(--Button-padding);
|
|
811
|
-
transition: color, background-color 150ms ease-in-out;
|
|
812
|
-
transition: color, background-color var(--Button-transition-duration) var(--Button-transition-easing);
|
|
813
796
|
}
|
|
814
797
|
.wds-Button:focus {
|
|
815
798
|
-webkit-text-decoration: none;
|
|
816
799
|
text-decoration: none;
|
|
817
800
|
}
|
|
818
801
|
.wds-Button:hover {
|
|
819
|
-
background-color: #008fc9;
|
|
820
802
|
background-color: var(--Button-background-hover);
|
|
821
803
|
-webkit-text-decoration: none;
|
|
822
804
|
text-decoration: none;
|
|
823
805
|
}
|
|
824
806
|
.wds-Button:active {
|
|
825
|
-
background-color: #0081ba;
|
|
826
807
|
background-color: var(--Button-background-active);
|
|
827
808
|
-webkit-text-decoration: none;
|
|
828
809
|
text-decoration: none;
|
|
@@ -837,7 +818,6 @@ div.critical-comms .critical-comms-body {
|
|
|
837
818
|
.wds-Button:disabled:hover,
|
|
838
819
|
.wds-Button.wds-Button--disabled:active,
|
|
839
820
|
.wds-Button:disabled:active {
|
|
840
|
-
background-color: #00a2dd;
|
|
841
821
|
background-color: var(--Button-background);
|
|
842
822
|
}
|
|
843
823
|
.wds-Button--secondary {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AAQA,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AAQA,QAAA,MAAM,MAAM,yOAoGX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -11,21 +11,21 @@ export type ButtonProps = (Omit<LegacyButtonProps, 'ref'> & CommonButtonProps &
|
|
|
11
11
|
priority?: LegacyButtonProps['priority'];
|
|
12
12
|
type?: LegacyButtonType;
|
|
13
13
|
htmlType?: string;
|
|
14
|
-
|
|
14
|
+
useNewButton?: false;
|
|
15
15
|
}) | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> & CommonButtonProps & {
|
|
16
16
|
priority?: NewButtonProps['priority'];
|
|
17
17
|
type?: NewButtonType;
|
|
18
|
-
|
|
18
|
+
useNewButton: true;
|
|
19
19
|
});
|
|
20
20
|
declare const Button: import("react").ForwardRefExoticComponent<(Omit<Omit<LegacyButtonProps, "ref"> & CommonButtonProps & {
|
|
21
21
|
priority?: LegacyButtonProps["priority"];
|
|
22
22
|
type?: LegacyButtonType;
|
|
23
23
|
htmlType?: string;
|
|
24
|
-
|
|
24
|
+
useNewButton?: false;
|
|
25
25
|
}, "ref"> | Omit<Omit<Omit<NewButtonProps, "type">, "ref"> & CommonButtonProps & {
|
|
26
26
|
priority?: NewButtonProps["priority"];
|
|
27
27
|
type?: NewButtonType;
|
|
28
|
-
|
|
28
|
+
useNewButton: true;
|
|
29
29
|
}, "ref">) & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
30
30
|
export default Button;
|
|
31
31
|
//# sourceMappingURL=Button.resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.resolver.d.ts","sourceRoot":"","sources":["../../../src/button/Button.resolver.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG/D,KAAK,gBAAgB,GACjB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,KAAK,GACL,WAAW,GACX,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEd,KAAK,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAElF,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAC7B,iBAAiB,GAAG;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"Button.resolver.d.ts","sourceRoot":"","sources":["../../../src/button/Button.resolver.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,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1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import type { PrimitiveButtonProps, PrimitiveAnchorProps, PrimitiveButtonElementRef, PrimitiveAnchorElementRef } from '../primitives';
|
|
3
3
|
import type { SingleAvatarType } from '../avatarLayout';
|
|
4
|
-
export type
|
|
4
|
+
export type ButtonApperance = 'default' | 'negative';
|
|
5
5
|
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
6
6
|
export type ButtonType = 'button' | 'submit' | 'reset';
|
|
7
7
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
@@ -10,15 +10,12 @@ export type ButtonRefType = PrimitiveButtonElementRef | PrimitiveAnchorElementRe
|
|
|
10
10
|
* Common properties for the Button component.
|
|
11
11
|
*/
|
|
12
12
|
export interface CommonButtonProps {
|
|
13
|
-
/**
|
|
14
|
-
* If set, toggles the new Button API
|
|
15
|
-
* @default false
|
|
16
|
-
* */
|
|
17
|
-
v2?: boolean;
|
|
18
13
|
/** The HTML element to render */
|
|
19
14
|
as?: 'button' | 'a' | null;
|
|
20
15
|
/** Additional class name(s) to apply to the button */
|
|
21
16
|
className?: string;
|
|
17
|
+
/** Content to be displayed inside the button */
|
|
18
|
+
children?: ReactNode;
|
|
22
19
|
/** Whether the button is disabled */
|
|
23
20
|
disabled?: boolean;
|
|
24
21
|
href?: string;
|
|
@@ -26,21 +23,18 @@ export interface CommonButtonProps {
|
|
|
26
23
|
loading?: boolean;
|
|
27
24
|
/** Whether the button should take up the full width of its container */
|
|
28
25
|
block?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Size of the button
|
|
31
|
-
* @default lg
|
|
32
|
-
* */
|
|
26
|
+
/** Size of the button */
|
|
33
27
|
size?: ButtonSize;
|
|
34
28
|
/**
|
|
35
29
|
* Priority of the button
|
|
36
|
-
* @default
|
|
30
|
+
* @default 'primary'
|
|
37
31
|
*/
|
|
38
32
|
priority?: ButtonPriority;
|
|
39
33
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @default default
|
|
34
|
+
* Appearance of the button
|
|
35
|
+
* @default 'default'
|
|
42
36
|
*/
|
|
43
|
-
|
|
37
|
+
appearance?: ButtonApperance;
|
|
44
38
|
/** Icon to be displayed on the left side of the button */
|
|
45
39
|
iconStart?: React.ElementType;
|
|
46
40
|
/** Icon to be displayed on the right side of the button */
|
|
@@ -49,8 +43,6 @@ export interface CommonButtonProps {
|
|
|
49
43
|
avatars?: SingleAvatarType[];
|
|
50
44
|
/** Optional property to provide component Ref */
|
|
51
45
|
ref?: ButtonRefType;
|
|
52
|
-
/** Content to be displayed inside the button */
|
|
53
|
-
children?: ReactNode;
|
|
54
46
|
}
|
|
55
47
|
export type ButtonElementProps = PrimitiveButtonProps & CommonButtonProps;
|
|
56
48
|
export type AnchorElementProps = PrimitiveAnchorProps & CommonButtonProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5C,MAAM,MAAM,aAAa,GAAG,yBAAyB,GAAG,yBAAyB,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC
|
|
1
|
+
{"version":3,"file":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2DAA2D;IAC3D,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IAE5B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAE7B,iDAAiD;IACjD,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAC1E,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAC1E,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
|
|
@@ -23,7 +23,7 @@ export type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, '
|
|
|
23
23
|
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
24
24
|
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
25
25
|
/**
|
|
26
|
-
* @deprecated make sure you use new Button component via `<Button
|
|
26
|
+
* @deprecated make sure you use new Button component via `<Button useNewButton .. />` and new props
|
|
27
27
|
*/
|
|
28
28
|
declare const LegacyButton: import("react").ForwardRefExoticComponent<(Omit<ButtonProps, "ref"> | Omit<AnchorProps, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
|
|
29
29
|
export default LegacyButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-818845e",
|
|
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
|
-
"@
|
|
95
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
96
|
-
"@
|
|
94
|
+
"@wise/components-theming": "1.6.1",
|
|
95
|
+
"@transferwise/neptune-css": "0.0.0-experimental-818845e",
|
|
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-
|
|
100
|
+
"@transferwise/neptune-css": "0.0.0-experimental-818845e",
|
|
101
101
|
"@wise/art": "^2.16",
|
|
102
102
|
"@wise/components-theming": "^1.0.0",
|
|
103
103
|
"react": ">=18",
|
package/src/button/Button.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
.wds-Button {
|
|
2
2
|
--Button-background: var(--color-interactive-accent);
|
|
3
3
|
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
4
4
|
--Button-background-active: var(--color-interactive-accent-active);
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
14
14
|
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
15
15
|
--Button-avatar-border-color: var(--color-border-neutral);
|
|
16
|
-
--Button-transition-duration: 150ms;
|
|
17
|
-
--Button-transition-easing: ease-in-out;
|
|
18
16
|
--Button-secondary-background: var(--color-interactive-neutral);
|
|
19
17
|
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
20
18
|
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
@@ -31,31 +29,25 @@
|
|
|
31
29
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
32
30
|
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
33
31
|
--Button-primary-negative-color: var(--color-contrast);
|
|
34
|
-
--Button-primary-
|
|
32
|
+
--Button-primary-negative-avatar-border-color: rgba(255,255,255,0.2);
|
|
35
33
|
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
36
34
|
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
37
35
|
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
38
36
|
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
39
|
-
--Button-secondary-
|
|
37
|
+
--Button-secondary-negative-avatar-border-color: rgba(168,32,13,0.12157);
|
|
40
38
|
}
|
|
41
39
|
.np-theme-personal--dark .wds-Button {
|
|
42
|
-
--Button-primary-
|
|
40
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
43
41
|
}
|
|
44
42
|
.np-theme-personal--forest-green .wds-Button {
|
|
45
|
-
--
|
|
46
|
-
--
|
|
47
|
-
--color-interactive-neutral-active: rgba(236,255,224,0.2);
|
|
48
|
-
--color-sentiment-negative-secondary: rgba(255,196,194,0.2);
|
|
49
|
-
--color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
|
|
50
|
-
--color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
|
|
51
|
-
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
52
|
-
--Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
43
|
+
--Button-primary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
44
|
+
--Button-secondary-negative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
53
45
|
}
|
|
54
46
|
.np-theme-personal--bright-green .wds-Button {
|
|
55
47
|
--color-contrast: #FFFFFF;
|
|
56
48
|
--Button-secondary-color: var(--color-interactive-control);
|
|
57
49
|
--Button-secondary-negative-color: var(--color-contrast);
|
|
58
|
-
--Button-secondary-
|
|
50
|
+
--Button-secondary-negative-avatar-border-color: var(--Button-primary-negative-avatar-border-color);
|
|
59
51
|
}
|
|
60
52
|
/* Button Styles */
|
|
61
53
|
.wds-Button {
|
|
@@ -65,13 +57,9 @@
|
|
|
65
57
|
align-items: center;
|
|
66
58
|
justify-content: center;
|
|
67
59
|
vertical-align: middle;
|
|
68
|
-
font-weight: 600;
|
|
69
60
|
font-weight: var(--Button-font-weight);
|
|
70
|
-
font-size: 1rem;
|
|
71
61
|
font-size: var(--Button-font-size);
|
|
72
|
-
letter-spacing: -0.011em;
|
|
73
62
|
letter-spacing: var(--Button-letter-spacing);
|
|
74
|
-
line-height: 24px;
|
|
75
63
|
line-height: var(--Button-line-height);
|
|
76
64
|
text-align: center;
|
|
77
65
|
-webkit-text-decoration: none;
|
|
@@ -81,30 +69,23 @@
|
|
|
81
69
|
-webkit-appearance: none;
|
|
82
70
|
-moz-appearance: none;
|
|
83
71
|
appearance: none;
|
|
84
|
-
background-color: #00a2dd;
|
|
85
72
|
background-color: var(--Button-background);
|
|
86
73
|
border: none;
|
|
87
|
-
border-radius: 9999px;
|
|
88
74
|
border-radius: var(--Button-border-radius);
|
|
89
75
|
color: var(--Button-color);
|
|
90
76
|
cursor: pointer;
|
|
91
|
-
padding: 8px 12px;
|
|
92
77
|
padding: var(--Button-padding);
|
|
93
|
-
transition: color, background-color 150ms ease-in-out;
|
|
94
|
-
transition: color, background-color var(--Button-transition-duration) var(--Button-transition-easing);
|
|
95
78
|
}
|
|
96
79
|
.wds-Button:focus {
|
|
97
80
|
-webkit-text-decoration: none;
|
|
98
81
|
text-decoration: none;
|
|
99
82
|
}
|
|
100
83
|
.wds-Button:hover {
|
|
101
|
-
background-color: #008fc9;
|
|
102
84
|
background-color: var(--Button-background-hover);
|
|
103
85
|
-webkit-text-decoration: none;
|
|
104
86
|
text-decoration: none;
|
|
105
87
|
}
|
|
106
88
|
.wds-Button:active {
|
|
107
|
-
background-color: #0081ba;
|
|
108
89
|
background-color: var(--Button-background-active);
|
|
109
90
|
-webkit-text-decoration: none;
|
|
110
91
|
text-decoration: none;
|
|
@@ -119,7 +100,6 @@
|
|
|
119
100
|
.wds-Button:disabled:hover,
|
|
120
101
|
.wds-Button.wds-Button--disabled:active,
|
|
121
102
|
.wds-Button:disabled:active {
|
|
122
|
-
background-color: #00a2dd;
|
|
123
103
|
background-color: var(--Button-background);
|
|
124
104
|
}
|
|
125
105
|
.wds-Button--secondary {
|
package/src/button/Button.less
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@import './Button.vars.less';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/* Button Styles */
|
|
4
4
|
.wds-Button {
|
|
5
5
|
display: inline-flex;
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
color: var(--Button-color);
|
|
24
24
|
cursor: pointer;
|
|
25
25
|
padding: var(--Button-padding);
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
&:focus {
|
|
29
28
|
text-decoration: none;
|
|
30
29
|
}
|
|
@@ -216,10 +215,10 @@
|
|
|
216
215
|
.tw-icon-arrow-right {
|
|
217
216
|
transform: rotate(180deg);
|
|
218
217
|
}
|
|
219
|
-
|
|
218
|
+
|
|
220
219
|
.tw-icon-chevron-left,
|
|
221
220
|
.tw-icon-arrow-left {
|
|
222
221
|
transform: rotate(180deg);
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
|
-
}
|
|
224
|
+
}
|
|
@@ -29,13 +29,13 @@ export type ButtonProps =
|
|
|
29
29
|
priority?: LegacyButtonProps['priority'];
|
|
30
30
|
type?: LegacyButtonType;
|
|
31
31
|
htmlType?: string;
|
|
32
|
-
|
|
32
|
+
useNewButton?: false;
|
|
33
33
|
})
|
|
34
34
|
| (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &
|
|
35
35
|
CommonButtonProps & {
|
|
36
36
|
priority?: NewButtonProps['priority'];
|
|
37
37
|
type?: NewButtonType;
|
|
38
|
-
|
|
38
|
+
useNewButton: true;
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
@@ -61,7 +61,7 @@ const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
|
61
61
|
|
|
62
62
|
const mappedPriority =
|
|
63
63
|
type && priority ? priorityMapping[type]?.[priority] || priority : priority || null;
|
|
64
|
-
const
|
|
64
|
+
const mappedAppearance = type === 'negative' ? 'negative' : null;
|
|
65
65
|
|
|
66
66
|
const legacyButtonTypes: LegacyButtonType[] = [
|
|
67
67
|
'accent',
|
|
@@ -74,19 +74,12 @@ const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
|
74
74
|
'link',
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
-
const resolveSize = () => {
|
|
78
|
-
if (size) {
|
|
79
|
-
return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return size;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
77
|
return {
|
|
86
78
|
...newProps,
|
|
87
|
-
size:
|
|
79
|
+
size:
|
|
80
|
+
size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
88
81
|
priority: mappedPriority,
|
|
89
|
-
|
|
82
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : null),
|
|
90
83
|
type:
|
|
91
84
|
type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,
|
|
92
85
|
href: as === 'a' ? props.href || '' : null,
|
|
@@ -94,9 +87,9 @@ const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
|
94
87
|
};
|
|
95
88
|
|
|
96
89
|
const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {
|
|
97
|
-
const {
|
|
90
|
+
const { useNewButton, as, ...rest } = props;
|
|
98
91
|
|
|
99
|
-
if (
|
|
92
|
+
if (useNewButton) {
|
|
100
93
|
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
101
94
|
return (
|
|
102
95
|
<NewButton
|
|
@@ -11,21 +11,21 @@ describe('Button', () => {
|
|
|
11
11
|
|
|
12
12
|
const newProps: ButtonProps = {
|
|
13
13
|
as: 'button',
|
|
14
|
-
|
|
14
|
+
useNewButton: true,
|
|
15
15
|
priority: 'primary',
|
|
16
16
|
size: 'md',
|
|
17
17
|
type: 'accent',
|
|
18
18
|
testId: 'new-button',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
it('renders LegacyButton when
|
|
21
|
+
it('renders LegacyButton when useNewButton is false', () => {
|
|
22
22
|
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
23
23
|
const button = screen.getByText('Legacy Button');
|
|
24
24
|
expect(button).toBeInTheDocument();
|
|
25
25
|
expect(button).toHaveClass('btn btn-md np-btn np-btn-md btn-accent btn-priority-1');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it('renders the new Button when
|
|
28
|
+
it('renders the new Button when useNewButton is true', () => {
|
|
29
29
|
render(<Button {...newProps}>New Button</Button>);
|
|
30
30
|
const button = screen.getByTestId('new-button');
|
|
31
31
|
expect(button).toBeInTheDocument();
|