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

feat: sidebar rework #1301

Merged
merged 6 commits into from
Oct 4, 2024
Merged
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
Expand Up @@ -7,21 +7,33 @@ import {
} from "@equinor/eds-core-react"
import { arrow_drop_up, arrow_drop_down } from "@equinor/eds-icons"
import Grid from "@mui/material/Grid"
import styled from "styled-components"

import { useAppContext } from "@/Context/AppContext"
import { Timeline, Header } from "../Sidebar"
import ArchivedCasesList from "./ArchivedCasesList"

const ClickableTitle = styled.div`
cursor: pointer;
`

const ArchivedCasesDetails: React.FC = () => {
const [expandList, setExpandList] = useState(false);
const { sidebarOpen } = useAppContext()

return (
<>

<Grid item xs={12} container alignItems="center" justifyContent={sidebarOpen ? "space-between" : "center"}>
<Grid item container alignItems="start" justifyContent={sidebarOpen ? "space-between" : "start"}>
<Header>
<Typography variant="overline">Archived Cases</Typography>
{sidebarOpen ? (
<Typography variant="overline">Archived Cases</Typography>
) : (
<Tooltip placement="right" title="Expand Archived Cases">
<ClickableTitle onClick={() => setExpandList(!expandList)}>
<Typography variant="overline">Archived</Typography>
</ClickableTitle>
</Tooltip>
)}
</Header>
{sidebarOpen && (
<Grid item>
Expand All @@ -38,7 +50,7 @@ const ArchivedCasesDetails: React.FC = () => {
)}
</Grid>
{!expandList ? null : (
<Timeline data-timeline container justifyContent="flex-start" alignItems="flex-start" direction="column">
<Timeline data-timeline container minHeight="100px" justifyContent="flex-start" alignItems="flex-start" direction="column">
<ArchivedCasesList />
</Timeline>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,35 @@ import {
Typography,
Tooltip,
} from "@equinor/eds-core-react"
import styled from "styled-components"
import { add } from "@equinor/eds-icons"
import Grid from "@mui/material/Grid"
import { useModalContext } from "../../../../Context/ModalContext"
import { useAppContext } from "../../../../Context/AppContext"

import { useModalContext } from "@/Context/ModalContext"
import { useAppContext } from "@/Context/AppContext"
import CasesList from "../Components/CasesList"
import { Timeline, Header } from "../Sidebar"
import { sharedTimelineStyles } from "../sharedStyles"
import { Header } from "../Sidebar"

export const CasesTimeline = styled(Grid)`
height: 100%;
${sharedTimelineStyles}
`

const GrowBox = styled.div`
flex-grow: 1;
flex-shrink: 1;
overflow-y: auto;
min-height: 100px;
`

const CasesDetails: React.FC = () => {
const { sidebarOpen } = useAppContext()
const { addNewCase } = useModalContext()

return (
<>

<Grid item xs={12} container alignItems="center" justifyContent={sidebarOpen ? "start" : "center"}>
<Grid item container alignItems="flex-start" justifyContent={sidebarOpen ? "space-between" : "start"}>
<Header>
<Typography variant="overline">Cases</Typography>
</Header>
Expand All @@ -30,10 +44,11 @@ const CasesDetails: React.FC = () => {
</Grid>
)}
</Grid>
<Timeline data-timeline container justifyContent="flex-start" alignItems="flex-start" direction="column">
<CasesList />
</Timeline>

<GrowBox>
<CasesTimeline data-timeline container justifyContent="flex-start" alignItems="flex-start" direction="column">
<CasesList />
</CasesTimeline>
</GrowBox>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import React from "react"
import styled from "styled-components"
import { Typography, Tooltip } from "@equinor/eds-core-react"
import { useParams } from "react-router-dom"
import { useCaseContext } from "../../../../Context/CaseContext"
import { useAppContext } from "../../../../Context/AppContext"
import HistoryButton from "../../../Buttons/HistoryButton"
import CaseEditHistory from "../../../Case/Components/CaseEditHistory"
import { Header } from "../Sidebar"

import { useCaseContext } from "@/Context/CaseContext"
import { useAppContext } from "@/Context/AppContext"
import HistoryButton from "@/Components/Buttons/HistoryButton"
import CaseEditHistory from "@/Components/Case/Components/CaseEditHistory"
import { Header, StyledDivider } from "../Sidebar"

const Container = styled.div<{ $sidebarOpen: boolean }>`
display: flex;
Expand Down Expand Up @@ -50,6 +51,7 @@ const CurrentCaseEditHistory: React.FC = () => {
{sidebarOpen && caseId && <CaseEditHistory caseId={caseId} />}
{sidebarOpen && caseEditsBelongingToCurrentCase?.length === 0 && <NextValue>No recent edits..</NextValue>}
</Content>
<StyledDivider />
</Container>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ import {
settings,
compare,
} from "@equinor/eds-icons"
import { projectPath } from "../../../../Utils/common"

import { projectPath } from "@/Utils/common"
import { useAppContext } from "@/Context/AppContext"
import { TimelineElement, Timeline, Header } from "../Sidebar"
import { useAppContext } from "../../../../Context/AppContext"

const ProjectTitle = styled(Typography)`
line-break: anywhere;
`

const CenterIcon = styled.div`
padding-right: 20px;
`

const ProjectDetails: React.FC = () => {
const { sidebarOpen } = useAppContext()
const { currentContext } = useModuleCurrentContext()
Expand All @@ -46,7 +51,7 @@ const ProjectDetails: React.FC = () => {
>
{sidebarOpen
? "Overview"
: <Tooltip title="Overview" placement="right"><Icon data={dashboard} /></Tooltip>}
: <CenterIcon><Tooltip title="Overview" placement="right"><Icon data={dashboard} /></Tooltip></CenterIcon>}
</TimelineElement>
</Grid>
<Grid item>
Expand Down
58 changes: 23 additions & 35 deletions frontend/src/Components/Controls/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import ProjectDetails from "./Components/ProjectDetails"
import CasesDetails from "./Components/CasesDetails"
import CurrentCaseEditHistory from "./Components/CurrentCaseEditHistory"
import ArchivedCasesDetails from "./Components/ArchivedCasesDetails"
import { sharedTimelineStyles } from "./sharedStyles"

const { Toggle, Footer } = SideBar

const { Toggle, Content, Footer } = SideBar
const Wrapper = styled.div`
position: relative;
`
`

const Sticky = styled.div`
position: sticky;
top: 0;
Expand All @@ -26,44 +29,32 @@ const Sticky = styled.div`
`

const StyledSideBar = styled(SideBar)`
height: auto;
`
height: 100%;
border-right: 0px;
display: flex;
flex-direction: column;
`

export const Header = styled.div`
margin: 15px 10px;
`

export const Timeline = styled(Grid)`
padding-left: 10px;
max-height: 200px;
overflow: auto;
&[data-timeline="true"] {
overflow-y: auto;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
scrollbar-width: none;
& > * {
border-left: 2px solid #DCDCDC;

&[data-timeline-active="true"]{
border-left: 2px solid #007079;
}
}
}

${sharedTimelineStyles}
`

const HorizontalScrollContent = styled(Content)`
overflow-x: auto;
white-space: nowrap;
export const StyledDivider = styled(Divider)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne styled divider-stylingen er ikke spesielt elegant, men hvis jeg bruker eds divideren uten disse stylingene så forsvinner dividerne (elementene er fortsatt i DOMen men de er usynelig på skjermen) når jeg kjører lokalt.
For en eller annen grunn kan dividerne brukes rett fra eds i CI uten problemer... for å være på den sikre siden har jeg overstyrt css fra eds og laget denne "StyledDivider"

height: 0px;
margin-left: 2px;
margin-right: 2px;
border: 0.5px solid rgba(220, 220, 220, 1);
`

export const TimelineElement = styled(Button)`
text-align: left;
height: 28px;
padding: 10px 5px 10px 10px;

padding: 10px 0px 10px 5px;
`

const Sidebar = () => {
Expand All @@ -90,20 +81,17 @@ const Sidebar = () => {
<Wrapper>
<Sticky>
<StyledSideBar open={sidebarOpen} onToggle={(toggle) => setSidebarOpen(toggle)}>
<HorizontalScrollContent>
<ProjectDetails />
<Divider />
<CasesDetails />
<Divider />
<ProjectDetails />
<StyledDivider />
<CasesDetails />
<StyledDivider />
{archivedCases.length > 0 && (
<>
<ArchivedCasesDetails />
<Divider />
<StyledDivider />
</>
)}
<CurrentCaseEditHistory />
<Divider />
</HorizontalScrollContent>
<CurrentCaseEditHistory />
<Footer>
<Toggle />
</Footer>
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/Components/Controls/Sidebar/sharedStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { css } from "styled-components"

export const sharedTimelineStyles = css`
padding-left: 10px;
overflow: auto;
&[data-timeline="true"] {
overflow-y: auto;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
scrollbar-width: none;
& > * {
border-left: 2px solid #DCDCDC;

&[data-timeline-active="true"]{
border-left: 2px solid #007079;
}
}
}
`
2 changes: 1 addition & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"noEmit": true,
"moduleResolution": "node",
"paths": {
"@/Components/*": ["./src/components/*"],
"@/Components/*": ["./src/Components/*"],
"@/Context/*": ["./src/Context/*"],
"@/Hooks/*": ["./src/Hooks/*"],
"@/Models/*": ["./src/Models/*"],
Expand Down