Skip to content

Commit dfe2e2a

Browse files
committed
Merge branch 'main' of github.com:deriv-com/ui into aizad/FEQ-1566/add-accordion
2 parents aea0f58 + 4d5318b commit dfe2e2a

File tree

14 files changed

+501
-378
lines changed

14 files changed

+501
-378
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## [1.10.4](https://github.com/deriv-com/ui/compare/v1.10.3...v1.10.4) (2024-03-07)
2+
3+
4+
### ♻️ Chores
5+
6+
* append prefix for css variables ([189cc82](https://github.com/deriv-com/ui/commit/189cc82ffbdf8dc18e1c44415fad8fd84ddf1e29))
7+
* refactor Text component ([9bc99e8](https://github.com/deriv-com/ui/commit/9bc99e8b07f84d0788f0e1d75af75e9779ee4122))
8+
9+
## [1.10.3](https://github.com/deriv-com/ui/compare/v1.10.2...v1.10.3) (2024-03-07)
10+
11+
12+
### ♻️ Chores
13+
14+
* add unit tests for button ([5c5fb21](https://github.com/deriv-com/ui/commit/5c5fb21bd319be0f7e368889f8cc9baabc461e88))
15+
* add unit tests for button ([cf8c43f](https://github.com/deriv-com/ui/commit/cf8c43fffacae82734a456d02ec5c6c3f9f6dd95))
16+
* add unit tests for button ([a7f6af5](https://github.com/deriv-com/ui/commit/a7f6af58f4463a7df5ccdbc45ff2100c82de65f0))
17+
18+
19+
### 🐛 Bug Fixes
20+
21+
* add lg type for rounded ([d94d8d8](https://github.com/deriv-com/ui/commit/d94d8d8873cf7a1e6cde2895ef77cf93868103a3))
22+
123
## [1.10.2](https://github.com/deriv-com/ui/compare/v1.10.1...v1.10.2) (2024-03-06)
224

325

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import { Button } from '../';
4+
5+
describe('Button component', () => {
6+
it('renders without crashing', () => {
7+
render(<Button>Test Button</Button>);
8+
expect(screen.getByRole('button', { name: /test button/i })).toBeInTheDocument();
9+
});
10+
11+
it('applies the "contained" variant classes when variant is "contained"', () => {
12+
const { container } = render(<Button variant="contained">Test Button</Button>);
13+
expect(container.firstChild).toHaveClass('deriv-button__variant--contained');
14+
});
15+
16+
it('applies the "ghost" variant classes when variant is "ghost"', () => {
17+
const { container } = render(<Button variant="ghost">Test Button</Button>);
18+
expect(container.firstChild).toHaveClass('deriv-button__variant--ghost');
19+
});
20+
21+
it('applies the "outlined" variant classes when variant is "outlined"', () => {
22+
const { container } = render(<Button variant="outlined">Test Button</Button>);
23+
expect(container.firstChild).toHaveClass('deriv-button__variant--outlined');
24+
});
25+
26+
it('applies the correct color class based on the "color" prop', () => {
27+
const { container } = render(<Button color="primary">Test Button</Button>);
28+
expect(container.firstChild).toHaveClass('deriv-button__color--primary');
29+
});
30+
31+
it('applies full width class when "isFullWidth" prop is true', () => {
32+
const { container } = render(<Button isFullWidth>Test Button</Button>);
33+
expect(container.firstChild).toHaveClass('deriv-button__full-width');
34+
});
35+
36+
it('does not apply full width class when "isFullWidth" prop is false', () => {
37+
const { container } = render(<Button>Test Button</Button>);
38+
expect(container.firstChild).not.toHaveClass('deriv-button__full-width');
39+
});
40+
41+
it('shows loader when "isLoading" prop is true', () => {
42+
render(<Button isLoading>Test Button</Button>);
43+
expect(screen.getByTestId('dt_derivs-loader')).toBeInTheDocument();
44+
});
45+
46+
it('does not show loader when "isLoading" prop is false', () => {
47+
render(<Button>Test Button</Button>);
48+
expect(screen.queryByTestId('loader')).toBeNull();
49+
});
50+
51+
it('disables the button when "disabled" prop is true', () => {
52+
render(<Button disabled>Test Button</Button>);
53+
expect(screen.getByRole('button', { name: /test button/i })).toBeDisabled();
54+
});
55+
56+
it('disables the button when "isLoading" prop is true', () => {
57+
render(<Button isLoading>Test Button</Button>);
58+
expect(screen.getByRole('button', { name: /test button/i })).toBeDisabled();
59+
});
60+
61+
it('applies the correct size class based on the "size" prop', () => {
62+
const { container } = render(<Button size="lg">Test Button</Button>);
63+
expect(container.firstChild).toHaveClass('deriv-button__size--lg');
64+
});
65+
66+
it('applies the correct rounded class based on the "rounded" prop', () => {
67+
const { container } = render(<Button rounded="md">Test Button</Button>);
68+
expect(container.firstChild).toHaveClass('deriv-button__rounded--md');
69+
});
70+
71+
it('shows the icon when provided and not loading', () => {
72+
const Icon = () => <span>Icon</span>;
73+
render(<Button icon={<Icon />}>Test Button</Button>);
74+
expect(screen.getByText('Icon')).toBeInTheDocument();
75+
});
76+
77+
it('does not show the icon when "isLoading" prop is true', () => {
78+
const Icon = () => <span>Icon</span>;
79+
render(<Button isLoading icon={<Icon />}>Test Button</Button>);
80+
expect(screen.queryByText('Icon')).toBeNull();
81+
});
82+
83+
it('renders children text when not loading', () => {
84+
render(<Button>Test Button</Button>);
85+
expect(screen.getByRole('button', { name: /test button/i })).toHaveTextContent('Test Button');
86+
});
87+
88+
it('does not render children text when "isLoading" prop is true', () => {
89+
render(<Button isLoading>Test Button</Button>);
90+
expect(screen.queryByText('Test Button')).toBeNull();
91+
});
92+
});

lib/components/Button/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface ButtonProps extends ComponentProps<"button"> {
1313
icon?: ReactElement;
1414
isFullWidth?: boolean;
1515
isLoading?: boolean;
16-
rounded?: Extract<TGenericSizes, "md" | "sm">;
16+
rounded?: Extract<TGenericSizes, "lg" | "md" | "sm">;
1717
size?: Extract<TGenericSizes, "lg" | "md" | "sm">;
1818
textSize?: ComponentProps<typeof Text>["size"];
1919
variant?: TVariant;
@@ -84,6 +84,7 @@ export const Button = ({
8484
className,
8585
)}
8686
disabled={rest.disabled || isLoading}
87+
aria-label={rest.children && typeof rest.children === 'string' ? rest.children : ''}
8788
{...rest}
8889
>
8990
{isLoading && (

lib/components/Dropdown/Dropdown.scss

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pointer-events: none;
88

99
& label {
10-
color: var(--system-light-5-active-background, #999);
10+
color: var(--du-system-light-5-active-background, #999);
1111
}
1212
}
1313

@@ -24,7 +24,7 @@
2424
}
2525
&__content {
2626
width: 100%;
27-
background: var(--system-light-8-primary-background, #fff);
27+
background: var(--du-system-light-8-primary-background, #fff);
2828
display: flex;
2929
align-items: center;
3030

@@ -44,7 +44,7 @@
4444
outline: 0;
4545
font-size: 14px;
4646
background-color: transparent;
47-
color: var(--system-light-2-general-text, #333);
47+
color: var(--du-system-light-2-general-text, #333);
4848
transition: border-color 0.2s;
4949
cursor: unset;
5050
user-select: none;
@@ -84,7 +84,7 @@
8484
}
8585

8686
&__field:focus ~ &__label {
87-
color: var(--brand-blue, #85acb0);
87+
color: var(--du-brand-blue, #85acb0);
8888
}
8989

9090
&__items {
@@ -95,13 +95,13 @@
9595
align-items: flex-start;
9696
z-index: 2;
9797
border-radius: 4px;
98-
background: var(--system-light-8-primary-background, #fff);
98+
background: var(--du-system-light-8-primary-background, #fff);
9999
box-shadow: 0 32px 64px 0 rgba(14, 14, 14, 0.14);
100100
overflow-y: auto;
101101
width: 328px;
102102

103103
&--full {
104-
width: 100%;
104+
width: 100%;
105105
}
106106

107107
& > :first-child {
@@ -141,11 +141,11 @@
141141

142142
&:hover:not(&--active) {
143143
cursor: pointer;
144-
background: var(--system-light-6-hover-background, #e6e9e9);
144+
background: var(--du-system-light-6-hover-background, #e6e9e9);
145145
}
146146

147147
&--active {
148-
background: var(--system-light-5-active-background, #d6dadb);
148+
background: var(--du-system-light-5-active-background, #d6dadb);
149149
}
150150
}
151151
}

lib/components/LinearProgressBar/LinearProgressBar.scss

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
$inactive_color: var(--general-main-3, #999999);
2-
$success_color: var(--status-success, #4bb4b3 );
3-
$warning_color: var(--status-warning, #ffad3a);
4-
$error_color: var(--status-danger, #ec3f3f);
5-
$active_color:var(--state-active, #d6dadb);
6-
$border_section:var(--border-divider, #f2f3f4);
7-
$state_hover:var(--general-hover, #e6e9e9);
8-
$BORDER_RADIUS:4px;
1+
$inactive_color: var(--du-general-main-3, #999999);
2+
$success_color: var(--du-status-success, #4bb4b3);
3+
$warning_color: var(--du-status-warning, #ffad3a);
4+
$error_color: var(--du-status-danger, #ec3f3f);
5+
$active_color: var(--du-state-active, #d6dadb);
6+
$border_section: var(--du-border-divider, #f2f3f4);
7+
$state_hover: var(--du-general-hover, #e6e9e9);
98

109
.deriv-linear-progress-bar {
1110
position: relative;
1211
width: 100%;
1312
padding: unset;
1413
box-sizing: border-box;
1514
margin: 8px 0;
16-
border-bottom: 1px solid $border_section ;
15+
border-bottom: 1px solid $border_section;
1716

1817
&__track {
1918
background: $inactive_color;
2019
position: relative;
2120
margin: 2px 0 8px;
2221
height: 6px;
2322
width: 100%;
24-
border-radius: #{$BORDER_RADIUS * 2};
23+
border-radius: $border-radius-2;
2524
}
2625

2726
&__line {
@@ -30,7 +29,7 @@ $BORDER_RADIUS:4px;
3029
top: 0;
3130
left: 0;
3231
height: 100%;
33-
border-radius: #{$BORDER_RADIUS * 2};
32+
border-radius: $border-radius-2;
3433
pointer-events: none;
3534
transition: width 0.3s;
3635

@@ -60,7 +59,7 @@ $BORDER_RADIUS:4px;
6059

6160
&:before,
6261
&:after {
63-
content: '';
62+
content: "";
6463
position: absolute;
6564
background-color: inherit;
6665
top: 0;
@@ -69,10 +68,12 @@ $BORDER_RADIUS:4px;
6968
will-change: left, right;
7069
}
7170
&:before {
72-
animation: skelton-loader 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
71+
animation: skelton-loader 2.1s
72+
cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
7373
}
7474
&:after {
75-
animation: skelton-loader-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;
75+
animation: skelton-loader-short 2.1s
76+
cubic-bezier(0.165, 0.84, 0.44, 1) infinite;
7677
animation-delay: 1.15s;
7778
}
7879
}

lib/components/Tabs/Tabs.scss

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
width: 100%;
55
&__btn {
66
display: inline-flex;
7-
gap: 0.8rem;
7+
gap: 8px;
88
align-items: center;
99
justify-content: center;
1010
width: 50%;
1111
border: none;
12-
border-bottom: 0.2rem solid var(--light-7-secondary-background, #f2f3f4);
12+
border-bottom: 2px solid var(--du-light-7-secondary-background, #f2f3f4);
1313
background: none;
14-
padding: 1rem 0;
14+
padding: 10px 0;
1515
cursor: pointer;
1616
&--active {
1717
width: 50%;
1818
border: none;
19-
border-bottom: 0.2rem solid var(--brand-coral, #ff444f);
19+
border-bottom: 2px solid var(--du-brand-coral, #ff444f);
2020
background: none;
21-
padding: 1rem 0;
21+
padding: 10px 0;
2222
}
2323
}
2424
}
@@ -33,14 +33,14 @@
3333

3434
&__btn {
3535
display: inline-flex;
36-
gap: 0.8rem;
36+
gap: 8px;
3737
align-items: center;
3838
justify-content: center;
3939
width: 50%;
4040
border: none;
41-
border-bottom: 0.2rem solid var(--light-7-secondary-background, #f2f3f4);
41+
border-bottom: 2px solid var(--du-light-7-secondary-background, #f2f3f4);
4242
background: none;
43-
padding: 0.5rem 0;
43+
padding: 5px 0;
4444
cursor: pointer;
4545
span {
4646
color: #999;

0 commit comments

Comments
 (0)