Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Dialog Component #275

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bcd2aa2
Backup
jorgenherje Sep 20, 2022
fcbe7e6
Starting implementation of move - Not correct! Only backup
jorgenherje Sep 21, 2022
c0b239f
Backup
jorgenherje Sep 23, 2022
06fc92d
Update resize logic
jorgenherje Sep 27, 2022
79dd77c
Backup
jorgenherje Sep 28, 2022
bfcadba
Improve dragging and add touch events
jorgenherje Sep 29, 2022
35250bd
Next iteration
jorgenherje Sep 29, 2022
8c5947e
Improve drag move and resize bug
jorgenherje Oct 3, 2022
0ac6235
Update enum to uppercase
jorgenherje Oct 3, 2022
e949075
Changed render method in `WebvizDialog`
rubenthoms Oct 3, 2022
010777c
Make WebvizDialog_root Id instead of className
jorgenherje Oct 3, 2022
d0c991c
Improve window resize event handling
jorgenherje Oct 5, 2022
de6a21d
Backup
jorgenherje Oct 5, 2022
e4630c5
Bug fixing for resize
jorgenherje Oct 5, 2022
fd50795
Fix adjusting dialog width to window width on open
jorgenherje Oct 6, 2022
f3139fd
Replace resizeObserver with mutationObserver
jorgenherje Oct 6, 2022
14d6108
Add close on escape button down
jorgenherje Oct 7, 2022
bcf00d9
Adjust class names based on open state
jorgenherje Oct 7, 2022
4e17595
Simplify close on escape button down event handling
jorgenherje Oct 7, 2022
adfea52
Improve resize handling and rename padding to margin for constant names
jorgenherje Oct 7, 2022
bb7899a
Fix inconsistent add/remove of eventListeners
jorgenherje Oct 10, 2022
1a47c92
Prevent dragging when mousedown/touchstart for close button
jorgenherje Oct 10, 2022
f0a36a5
Add WebvizDialog to view element for testing
jorgenherje Oct 10, 2022
4107ec6
Changed from `ReactDOM.render` to `ReactDOM.createPortal`
rubenthoms Oct 10, 2022
4bf295b
Bugfix for renderer and add scrollArea for dialog content
jorgenherje Oct 11, 2022
f5facb1
Fix bug in activation of ScrollArea when opening dialog.
jorgenherje Oct 12, 2022
b2abb57
Add storybook
jorgenherje Oct 12, 2022
570e964
Remove usage of mutation observer.
jorgenherje Oct 12, 2022
ec2f6ca
Merge commit 'fb3968736afff47854535df1b228643f97564f66' into EQ_261-n…
jorgenherje Oct 13, 2022
b181e43
Make use of Size-object and improve initial size/position code
jorgenherje Oct 13, 2022
ff7b948
Remove unused code
jorgenherje Oct 13, 2022
bd9a365
Adjust box shadow
jorgenherje Oct 13, 2022
a8cb76e
Remove test code from demo
jorgenherje Oct 13, 2022
7fd29dc
Update CHANGELOG
jorgenherje Oct 13, 2022
d2a7250
Fix eslint
jorgenherje Oct 13, 2022
8b61675
Fix typo
jorgenherje Oct 13, 2022
b056a4b
Updates based on review
jorgenherje Oct 18, 2022
5ffeec6
Rename renderer to WebvizRenderer
jorgenherje Oct 18, 2022
0c71d66
Fix incorrect positioning when initial open state is true
jorgenherje Oct 18, 2022
af73f3b
Change default value for disableDraggable
jorgenherje Oct 18, 2022
f0fb2ee
Set max height of dialog content
jorgenherje Oct 18, 2022
24ae27c
Remove isMovedOutsideWindow state and minor bug fix
jorgenherje Oct 19, 2022
dac060d
Keep previously active dialog when opening a modal dialog
jorgenherje Oct 19, 2022
c69ab88
Fit dialog content according to minWidth
jorgenherje Oct 19, 2022
7d851e7
Bugfix for dialog content according to minWidth
jorgenherje Oct 19, 2022
75f050a
Add height owner, add height resize event handling and refactor compo…
jorgenherje Nov 1, 2022
13c3015
Adjust dialog actions code for empty list of actions
jorgenherje Nov 1, 2022
c43ae4a
Adjust storybook values
jorgenherje Nov 2, 2022
0160f69
Add control of z-index for correct z-index
jorgenherje Nov 2, 2022
2bbd7ad
Add useLayoutEffect for update of prop.modal -
jorgenherje Nov 2, 2022
6882100
Rename utility function
jorgenherje Nov 3, 2022
70df1db
Add dialog to advanced storybook example
jorgenherje Nov 3, 2022
52fba63
Improve css
jorgenherje Nov 3, 2022
3baf884
Fix import order in index.ts
jorgenherje Nov 3, 2022
6f5f5c6
Updates based on review
jorgenherje Nov 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#273](https://github.com/equinor/webviz-core-components/pull/273) - Adjusted `propTypes` for `width` and `height` properties of `ScrollArea` component to also accept strings. Adjusted its handle sizes and their positions and improved UX with small areas and large content as well as with two scrollbars.

### Added

- [#275](https://github.com/equinor/webviz-core-components/pull/275) - Added `WebvizDialog` component. New dialog component which handles multiple instances simultaneously, where the currently active dialog is placed on top and highlighted with box shadow.

## [0.6.1] - 2022-10-10

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions react/src/lib/components/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import "./backdrop.css";

export type BackdropProps = {
opacity: number;
onClick?: () => void;
};

export const Backdrop: React.FC<BackdropProps> = (props: BackdropProps) => {
const handleClick = React.useCallback(() => {
if (props.onClick !== undefined) {
props.onClick();
}
}, [props.onClick]);
return (
<div
className="Webviz__Backdrop"
onClick={() => handleClick()}
style={{
opacity: props.opacity,
display: props.opacity === 0 ? "none" : "block",
Expand Down
1 change: 1 addition & 0 deletions react/src/lib/components/Backdrop/backdrop.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
height: 100vh;
top: 0;
left: 0;
pointer-events: auto;
}
186 changes: 186 additions & 0 deletions react/src/lib/components/WebvizDialog/WebvizDialog.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import React from "react";

import { ComponentStory, ComponentMeta } from "@storybook/react";

import { WebvizDialog, WebvizDialogProps } from "./WebvizDialog";
import { Button } from "@material-ui/core";

export default {
title: "Components/WebvizDialog",
subcomponents: { WebvizDialog },
argTypes: { actions: { control: "array" } },
} as ComponentMeta<typeof WebvizDialog>;

const Template: ComponentStory<typeof WebvizDialog> = (
args: WebvizDialogProps
) => {
const { ...other } = args;
const [dialogOpen, setDialogOpen] = React.useState<boolean>(false);

return (
<>
<Button
variant="outlined"
onClick={() => setDialogOpen(true)}
>{`Open ${other.id}`}</Button>
<WebvizDialog
{...other}
open={dialogOpen}
setProps={(newProps) => setDialogOpen(newProps.open)}
>
{other.modal ? (
<div style={{ width: 400, height: 300 }}>
This is the content of the modal dialog div (width: 400,
height: 300). Closes when clicking on backdrop.
</div>
) : (
<div style={{ width: 400, height: 600 }}>
This is the content of the non-modal dialog div (width:
400, height: 600)
</div>
)}
</WebvizDialog>
</>
);
};

export const Basic = Template.bind({});
Basic.args = {
id: "Dialog",
title: "My Dialog Title",
open: WebvizDialog.defaultProps?.open || false,
modal: true,
heightOwner: "content",
height: 250,
maxWidth: WebvizDialog.defaultProps?.maxWidth || 1200,
minWidth: WebvizDialog.defaultProps?.minWidth || 100,
disableDraggable: WebvizDialog.defaultProps?.disableDraggable || false,
disableEscapeKeyDown:
WebvizDialog.defaultProps?.disableEscapeKeyDown || false,
children: [],
actions: ["Action 1", "Action 2"],
};

const ExampleMultipleDialogsTemplate: ComponentStory<typeof WebvizDialog> = (
args
) => {
const DialogProps: WebvizDialogProps = {
id: "",
title: "",
open: false,
modal: false,
heightOwner: undefined,
height: undefined,
minWidth: WebvizDialog.defaultProps?.minWidth || 200,
maxWidth: undefined,
disableEscapeKeyDown:
WebvizDialog.defaultProps?.disableEscapeKeyDown || false,
children: [],
actions: WebvizDialog.defaultProps?.actions || [],
setProps: () => {
return;
},
};

const [firstDialogOpen, setFirstDialogOpen] =
React.useState<boolean>(false);
const [secondDialogOpen, setSecondDialogOpen] =
React.useState<boolean>(false);
const [thirdDialogOpen, setThirdDialogOpen] =
React.useState<boolean>(false);
const [modalDialogOpen, setModalDialogOpen] =
React.useState<boolean>(false);
return (
<>
<div style={{ marginBottom: 20 }}>
This is a pre-configured advanced example to show the
functionality for interacting with multiple WebvizDialog
components at the same time. The example consist of 4 dialogs,
three non-modal dialogs and one modal dialog. The dialogs can be
opened and the active dialog is shown on top with a shadow to
highlight it being the currently active dialog. When the modal
dialog is opened, it is placed on top, with a backdrop to fade
out the background. The modal dialog is closed when clicking on
the backdrop, or by regular close actions as pushing the close
button or escape button (if not disabled).
</div>
<Button variant="outlined" onClick={() => setFirstDialogOpen(true)}>
Open First Dialog
</Button>
<Button
variant="outlined"
onClick={() => setSecondDialogOpen(true)}
>
Open Second Dialog
</Button>
<Button variant="outlined" onClick={() => setThirdDialogOpen(true)}>
Open Third Dialog
</Button>
<Button variant="outlined" onClick={() => setModalDialogOpen(true)}>
Open Modal Dialog
</Button>
<WebvizDialog
{...DialogProps}
id={"First Dialog"}
title={"First Dialog Title"}
open={firstDialogOpen}
actions={args.actions}
disableDraggable={false}
disableEscapeKeyDown={args.disableEscapeKeyDown}
setProps={(newProps) => setFirstDialogOpen(newProps.open)}
>
<div style={{ width: 400 }}>
This is the content of the first dialog
</div>
</WebvizDialog>
<WebvizDialog
{...DialogProps}
id={"Second Dialog"}
title={"Second Dialog Title"}
open={secondDialogOpen}
actions={["cancel", "ok"]}
disableDraggable={false}
disableEscapeKeyDown={args.disableEscapeKeyDown}
setProps={(newProps) => setSecondDialogOpen(newProps.open)}
>
This is the content of the second dialog
</WebvizDialog>
<WebvizDialog
{...DialogProps}
id={"Third Dialog"}
title={"Third Dialog Title"}
open={thirdDialogOpen}
actions={["No", "Yes"]}
heightOwner={"content"}
height={200}
disableDraggable={false}
disableEscapeKeyDown={args.disableEscapeKeyDown}
setProps={(newProps) => setThirdDialogOpen(newProps.open)}
>
This is the content of the third dialog
</WebvizDialog>
<WebvizDialog
{...DialogProps}
id={"Modal Dialog"}
title={"Modal Dialog Title"}
open={modalDialogOpen}
modal={true}
heightOwner={"dialog"}
height={400}
actions={args.actions}
disableDraggable={false}
disableEscapeKeyDown={args.disableEscapeKeyDown}
setProps={(newProps) => setModalDialogOpen(newProps.open)}
>
This is a modal dialog. Closes when clicking on backdrop
</WebvizDialog>
</>
);
};

export const ExampleMultipleDialogs = ExampleMultipleDialogsTemplate.bind({});
ExampleMultipleDialogs.args = {
disableEscapeKeyDown:
WebvizDialog.defaultProps?.disableEscapeKeyDown || false,
actions: WebvizDialog.defaultProps?.actions || [],
};
Loading