Skip to content

Commit 52755bf

Browse files
committed
fix(Dialog): remove underlay from type panel dialogs
1 parent cd06c0d commit 52755bf

File tree

7 files changed

+46
-5
lines changed

7 files changed

+46
-5
lines changed

.changeset/eleven-foxes-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': minor
3+
---
4+
5+
Remove underlay from dialogs with type `panel`.

.changeset/metal-worms-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': minor
3+
---
4+
5+
Add ReturnIcon component.

src/components/overlays/Dialog/DialogContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface CubeDialogContainerProps {
1919
* The type of Dialog that should be rendered. See the visual options below for examples of each.
2020
* @default 'modal'
2121
*/
22-
type?: 'modal' | 'fullscreen' | 'fullscreenTakeover';
22+
type?: 'modal' | 'fullscreen' | 'fullscreenTakeover' | 'panel';
2323
/** Whether the Dialog is dismissible. See the [Dialog docs](Dialog.html#dismissable-dialogs) for more details. */
2424
isDismissable?: boolean;
2525
/**

src/components/overlays/Dialog/context.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { createContext, HTMLAttributes, useContext } from 'react';
22
import invariant from 'tiny-invariant';
33

44
export interface DialogContextValue extends HTMLAttributes<HTMLElement> {
5-
type?: 'modal' | 'popover' | 'tray' | 'fullscreen' | 'fullscreenTakeover';
5+
type?:
6+
| 'modal'
7+
| 'popover'
8+
| 'tray'
9+
| 'fullscreen'
10+
| 'fullscreenTakeover'
11+
| 'panel';
612
isDismissable?: boolean;
713
onClose?: (arg?: string) => void;
814
}

src/components/overlays/Modal/Modal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,19 @@ const ModalElement = tasty({
4949
'[data-type="fullscreenTakeover"] | [data-type="panel"]': '100dvh 100dvh',
5050
'[data-type="fullscreen"]': '90dvh 90dvh',
5151
'[data-type="fullscreenTakeover"]': '100dvh 100dvh',
52+
'[data-type="panel"]': 'auto',
5253
},
5354
width: {
54-
width: '288px 90vw',
55+
'': '288px 90vw',
56+
'[data-type="panel"]': 'auto',
5557
},
5658
pointerEvents: 'none',
5759
transition: 'opacity .25s linear, transform .25s ease-in-out',
5860
transform: {
5961
'': 'initial',
6062
'[data-type="modal"] & !open': 'translate(0, -3x) scale(1, 1)',
61-
'[data-type^="fullscreen"] & !open': 'translate(0, 0) scale(1.02, 1.02)',
63+
'([data-type^="fullscreen"] | [data-type="panel"]) & !open':
64+
'translate(0, 0) scale(1.02, 1.02)',
6265
},
6366
opacity: {
6467
'': 0,
@@ -86,7 +89,9 @@ function Modal(props: CubeModalProps, ref) {
8689

8790
return (
8891
<Overlay {...otherProps}>
89-
{type !== 'fullscreenTakeover' && <Underlay {...underlayProps} />}
92+
{type !== 'fullscreenTakeover' && type !== 'panel' && (
93+
<Underlay {...underlayProps} />
94+
)}
9095
<ModalWrapper
9196
ref={domRef}
9297
qa={qa}

src/icons/ReturnIcon.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { wrapIcon } from './wrap-icon';
2+
3+
export const ReturnIcon = wrapIcon(
4+
'ReturnIcon',
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
width="16"
8+
height="16"
9+
fill="none"
10+
viewBox="0 0 16 16"
11+
>
12+
<path
13+
fill="currentColor"
14+
fillRule="evenodd"
15+
d="M8.556 3.9a.6.6 0 0 0 0 1.2h3.455v4.794H5V8.442a.4.4 0 0 0-.684-.282L2.278 10.22a.4.4 0 0 0 0 .562l2.038 2.059A.4.4 0 0 0 5 12.558v-1.464h7.011a1.2 1.2 0 0 0 1.2-1.2V5.1a1.2 1.2 0 0 0-1.2-1.2z"
16+
clipRule="evenodd"
17+
/>
18+
</svg>,
19+
);

src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export { PauseCircleIcon } from './PauseCircleIcon';
5151
export { PieChartIcon } from './PieChartIcon';
5252
export { PlusIcon } from './PlusIcon';
5353
export { ReloadIcon } from './ReloadIcon';
54+
export { ReturnIcon } from './ReturnIcon';
5455
export { RightIcon } from './RightIcon';
5556
export { SearchIcon } from './SearchIcon';
5657
export { SettingsIcon } from './SettingsIcon';

0 commit comments

Comments
 (0)