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

Improvements to WLF view selector #274

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
.WebvizViewList {
position: absolute;
max-width: 40vw;
background-color: white;
border: 1px #ccc solid;
border-radius: 4px;
z-index: 1300;
-webkit-box-shadow: 1px 2px 6px -1px rgba(0, 0, 0, 0.33);
box-shadow: 1px 2px 6px -1px rgba(0, 0, 0, 0.33);
}

.WebvizViewList__Content {
.WebvizViewList__Content__Below {
}

.WebvizViewList__Content__Aside {
z-index: 1;
width: 100%;
height: 100%;
Expand All @@ -19,7 +15,20 @@
padding-top: 8px;
}

.WebvizViewList__Below {
-webkit-box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.32) inset;
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.32) inset;
border-bottom: 1px #ccc solid;
}

.WebvizViewList__Aside {
position: absolute;
max-width: 40vw;
border: 1px #ccc solid;
border-radius: 4px;
z-index: 1300;
-webkit-box-shadow: 1px 2px 6px -1px rgba(0, 0, 0, 0.33);
box-shadow: 1px 2px 6px -1px rgba(0, 0, 0, 0.33);
margin-top: -20px;
}

Expand Down Expand Up @@ -75,6 +84,10 @@
height: 24px;
}

.WebvizViewList__Item__Active {
background-color: rgba(240, 240, 240, 0.22);
}

.WebvizViewList__Item:hover {
background-color: rgba(196, 196, 196, 0.22);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
}}
ref={ref}
>
{props.location === "aside" && (
<div
className={`WebvizViewList__Arrow WebvizViewList__Arrow${
props.location.charAt(0).toUpperCase() +
(props.location as string).slice(1)
}`}
/>
)}
<div
className={`WebvizViewList__Arrow WebvizViewList__Arrow${
className={`WebvizViewList__Content__${
props.location.charAt(0).toUpperCase() +
(props.location as string).slice(1)
}`}
/>
<div className="WebvizViewList__Content">
>
{viewGroups.map((el) => {
if (el.group === "") {
return (
Expand All @@ -107,7 +114,11 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
enterNextDelay={1000}
>
<div
className="WebvizViewList__Item"
className={`WebvizViewList__Item${
el.views[0].id === props.activeViewId
? " WebvizViewList__Item__Active"
: ""
}`}
onClick={() =>
props.onActiveViewChange(el.views[0].id)
}
Expand Down Expand Up @@ -141,7 +152,11 @@ export const ViewList: React.FC<ViewListProps> = (props: ViewListProps) => {
enterNextDelay={1000}
>
<div
className="WebvizViewList__Item"
className={`WebvizViewList__Item${
view.id === props.activeViewId
? " WebvizViewList__Item__Active"
: ""
}`}
onClick={() =>
props.onActiveViewChange(
view.id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";

import { view_carousel, chevron_down } from "@equinor/eds-icons";
import { view_carousel, chevron_down, chevron_up } from "@equinor/eds-icons";
import { Icon } from "@equinor/eds-core-react";
Icon.add({ view_carousel, chevron_down });
Icon.add({ view_carousel, chevron_down, chevron_up });

import { StoreActions, useStore } from "../../../WebvizContentManager";

Expand Down Expand Up @@ -55,12 +55,12 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
const ViewListElements = () => (
<>
<Overlay
visible={menuOpen}
visible={menuOpen && !props.open}
onClick={() => setMenuOpen(false)}
zIndex={1003}
/>
<ViewList
open={menuOpen}
open={menuOpen && !props.open}
views={
store.state.pluginsData.find(
(plugin) =>
Expand All @@ -78,7 +78,7 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
? viewNameRef.current
: viewCarouselRef.current
}
location={props.open ? "below" : "aside"}
location={"aside"}
onActiveViewChange={handleSelectViewClick}
/>
</>
Expand Down Expand Up @@ -111,6 +111,7 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
clearTimeout(transitionTimer.current);
}
if (!props.open) {
setMenuOpen(false);
transitionTimer.current = setTimeout(
() => setIsCollapsed(true),
1000
Expand All @@ -123,49 +124,82 @@ export const ViewSelector: React.FC<ViewSelectorProps> = (
const handleSelectViewClick = React.useCallback(
(view: string) => {
if (store && plugin?.activeViewId !== view) {
if (!props.open) {
setMenuOpen(false);
}
store.dispatch({
type: StoreActions.SetActiveView,
payload: { viewId: view },
});
}
},
[store]
[store, props.open]
);

return (
<Tooltip title="Change view">
<div
className="WebvizViewSelector"
style={{
width: isCollapsed ? "auto" : props.width - 36,
minHeight:
plugin?.views && plugin.views.length > 1 ? 56 : 0,
opacity: plugin?.views && plugin.views.length > 1 ? 1 : 0,
}}
onClick={() => setMenuOpen(true)}
>
<div ref={viewCarouselRef} className="WebvizViewSelector__Icon">
<Icon name="view_carousel" />
</div>
<div
ref={viewNameRef}
className="WebvizViewSelector__ViewName"
style={{
opacity: props.open ? 1 : 0,
width: isCollapsed ? 0 : "auto",
}}
>
{plugin?.views && plugin.views.length > 1 && activeViewName}
</div>
<>
<Tooltip title="Change view">
<div
className="WebvizViewSelector"
style={{
opacity: props.open ? 1 : 0,
width: isCollapsed ? 0 : "auto",
width: isCollapsed ? "auto" : props.width - 36,
minHeight:
plugin?.views && plugin.views.length > 1 ? 56 : 0,
opacity:
plugin?.views && plugin.views.length > 1 ? 1 : 0,
}}
onClick={() => setMenuOpen(!menuOpen)}
>
<Icon name="chevron_down" />
<div
ref={viewCarouselRef}
className="WebvizViewSelector__Icon"
>
<Icon name="view_carousel" />
</div>
<div
ref={viewNameRef}
className="WebvizViewSelector__ViewName"
style={{
opacity: props.open ? 1 : 0,
width: isCollapsed ? 0 : "auto",
}}
>
{plugin?.views &&
plugin.views.length > 1 &&
activeViewName}
</div>
<div
style={{
opacity: props.open ? 1 : 0,
width: isCollapsed ? 0 : "auto",
}}
>
{menuOpen ? (
<Icon name="chevron_up" />
) : (
<Icon name="chevron_down" />
)}
</div>
</div>
</div>
</Tooltip>
</Tooltip>
<ViewList
open={menuOpen && props.open}
views={
store.state.pluginsData.find(
(plugin) => plugin.id === store.state.activePluginId
)?.views || []
}
activeViewId={
store.state.pluginsData.find(
(plugin) => plugin.id === store.state.activePluginId
)?.activeViewId || ""
}
anchorElement={
props.open ? viewNameRef.current : viewCarouselRef.current
}
location={"below"}
onActiveViewChange={handleSelectViewClick}
/>
</>
);
};