Skip to content

Commit 2da646a

Browse files
authored
[Bot] feat: added resize functionality to modal in dbot (deriv-com#13145)
* feat: added resize functionality to modals in dbot * fix: fixed the failing test case in transaction-details-desktop spec file
1 parent 3d9df83 commit 2da646a

File tree

7 files changed

+36
-20
lines changed

7 files changed

+36
-20
lines changed

packages/bot-web-ui/src/components/draggable/draggable.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function Draggable({
2323
bounds = 'window',
2424
children,
2525
dragHandleClassName,
26-
enableResizing = false,
26+
enableResizing = true,
2727
header_title,
2828
height = 'fit-content',
2929
is_visible,
@@ -54,7 +54,7 @@ export default function Draggable({
5454
top: yaxis,
5555
}}
5656
dragHandleClassName={dragHandleClassName}
57-
enableResizing={enableResizing}
57+
enableResizing={{ right: enableResizing, bottom: enableResizing, bottomRight: enableResizing }}
5858
minHeight={height}
5959
minWidth={minWidth}
6060
onDrag={(e, data) => {

packages/bot-web-ui/src/components/transaction-details/__tests__/transaction-details-desktop.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('TransactionDetailsDesktop', () => {
7777
const computedStyle = window.getComputedStyle(draggable_element);
7878
const transformValue = computedStyle.getPropertyValue('transform');
7979

80-
expect(transformValue).toBe('translate(-1034px,0px)');
80+
expect(transformValue).toBe('translate(-882px,0px)');
8181
});
8282

8383
it('should close DesktopTransactionTable modal', () => {

packages/bot-web-ui/src/components/transaction-details/desktop-transaction-table.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function DesktopTransactionTable({
6161
balance,
6262
}: TDesktopTransactionTable) {
6363
return (
64-
<div data-testid='transaction_details_tables'>
64+
<div data-testid='transaction_details_tables' className='transaction-details-tables'>
6565
<div
6666
className={classNames(
6767
`${PARENT_CLASS}__table-container`,
@@ -134,10 +134,15 @@ export default function DesktopTransactionTable({
134134
);
135135
})}
136136
</div>
137-
<div className={classNames(`${PARENT_CLASS}__table-container`)}>
137+
<div
138+
className={classNames(
139+
`${PARENT_CLASS}__table-container`,
140+
`${PARENT_CLASS}__table-container__bottom-table`
141+
)}
142+
>
138143
<TableHeader columns={result_columns} />
139144
<div className={`${PARENT_CLASS}__table-row`}>
140-
<TableCell label={account} />
145+
<TableCell label={account} extra_classes={[`${PARENT_CLASS}__table-cell--grow-mid`]} />
141146
<TableCell label={result?.number_of_runs} />
142147
<TableCell label={Math.abs(result?.total_stake ?? 0).toFixed(2)} />
143148
<TableCell label={Math.abs(result?.total_payout ?? 0).toFixed(2)} />

packages/bot-web-ui/src/components/transaction-details/transaction-details-desktop.scss

+14-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
&__table-container {
2323
display: flex;
2424
flex-direction: column;
25-
overflow: auto;
26-
max-height: 40vh;
2725
margin-bottom: 8px;
2826
&__top-table {
29-
height: 40vh;
27+
overflow: auto;
28+
height: inherit;
29+
}
30+
&__bottom-table {
31+
overflow: unset;
3032
}
3133
}
3234

@@ -57,7 +59,7 @@
5759
white-space: normal;
5860
word-wrap: break-word;
5961
&--grow-big {
60-
flex-grow: 3;
62+
flex-grow: 2.5;
6163
}
6264
&--grow-mid {
6365
flex-grow: 1.5;
@@ -94,3 +96,11 @@
9496
padding: 4px 16px;
9597
}
9698
}
99+
100+
.transaction-details-tables {
101+
height: calc(100% - 48px);
102+
display: flex;
103+
flex-direction: column;
104+
justify-content: space-between;
105+
overflow: hidden;
106+
}

packages/bot-web-ui/src/components/transaction-details/transaction-details-desktop.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const transaction_columns: TColumn[] = [
2020

2121
/* TODO: Add back account & balance when we have support from transaction store */
2222
const result_columns: TColumn[] = [
23-
{ key: 'account', label: localize('Account') },
23+
{ key: 'account', label: localize('Account'), extra_class: '--grow-mid' },
2424
{ key: 'no_of_runs', label: localize('No. of runs') },
2525
{ key: 'total_stake', label: localize('Total stake') },
2626
{ key: 'total_payout', label: localize('Total payout') },
@@ -57,8 +57,8 @@ const TransactionDetailsDesktop = observer(() => {
5757
}, []);
5858

5959
// Calculate xaxis and yaxis to center the modal on open
60-
const modalWidth = 1034;
61-
const modalHeight = 800;
60+
const modalWidth = 882;
61+
const modalHeight = 404;
6262
const xaxis = (screenDimensions.width - modalWidth) / 2;
6363
const yAxisValue = (screenDimensions.height - modalHeight) / 2;
6464
const yaxis = yAxisValue >= 0 ? yAxisValue : 0;
@@ -71,6 +71,7 @@ const TransactionDetailsDesktop = observer(() => {
7171
minWidth={modalWidth}
7272
onCloseDraggable={() => toggleTransactionDetailsModal(false)}
7373
width={modalWidth}
74+
height={modalHeight}
7475
xaxis={xaxis}
7576
yaxis={yaxis}
7677
header_title={'Transactions detailed summary'}

packages/bot-web-ui/src/pages/chart/chart-modal/chart-modal-desktop.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const ChartModalDesktop = observer(() => {
2525
};
2626
}, []);
2727

28-
const modalWidth = 426;
29-
const modalHeight = 481;
28+
const modalWidth = 526;
29+
const modalHeight = 524;
3030

3131
const xAxisValue = (screenDimensions.width - modalWidth) / 2;
3232
const yAxisValue = (screenDimensions.height - modalHeight) / 2;
@@ -44,6 +44,7 @@ const ChartModalDesktop = observer(() => {
4444
onCloseDraggable={setChartModalVisibility}
4545
minWidth={modalWidth}
4646
width={modalWidth}
47+
height={modalHeight}
4748
dragHandleClassName='react-rnd-wrapper-header'
4849
>
4950
<div className='chart-modal-dialog' data-testid='chart-modal-dialog'>

packages/bot-web-ui/src/pages/chart/chart-modal/chart-modal.scss

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
display: flex;
1010
align-items: center;
1111
}
12-
13-
--modal-height: 48.1vh;
14-
12+
padding: 0 0.8rem;
13+
--modal-height: calc(100% - 48px);
1514
height: var(--modal-height);
16-
max-height: var(--modal-height);
1715
@include align-items-center;
1816
justify-content: center;
1917
z-index: 999;
2018
transition: opacity 0.25s cubic-bezier(0.25, 0.1, 0.1, 0.25);
2119

2220
.dashboard__chart-wrapper--modal {
23-
height: var(--modal-height);
21+
height: 100%;
22+
width: 100%;
2423
}
2524

2625
.sc-navigation-widget {

0 commit comments

Comments
 (0)