Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8128b8
feat: create GlobalContent.
crhallberg Feb 7, 2023
186bf23
refactor: apply GlobalContext.
crhallberg Feb 7, 2023
454a2cc
refactor: remove unused mock context.
crhallberg Feb 7, 2023
7dc0c55
feat: begin to move modal control to GlobalContext.
crhallberg Feb 8, 2023
c2463eb
feat: add theme switcher to GlobalContext.
crhallberg Feb 8, 2023
9ecd09d
refactor: move colors to CSS variables in globals.css
crhallberg Feb 8, 2023
edbf0cd
refactor: modernize justgrid.css
crhallberg Feb 8, 2023
c3f164e
style: Touch up styles, focused on the editor.
demiankatz Feb 9, 2023
d5a3433
fix: StateModal and modal closing behavior.
demiankatz Feb 9, 2023
6492d60
revert: move theme functionality to dark-theme branch.
crhallberg Feb 14, 2023
cafb3b1
Merge branch 'global-context' into dark-mode
crhallberg Feb 14, 2023
02aa1b1
types: fix GlobalState.
crhallberg Feb 14, 2023
6eb65fd
Merge branch 'global-context' into dark-mode
crhallberg Feb 14, 2023
7bb076c
feat: catch ThemeMenu from global-context branch.
crhallberg Feb 14, 2023
67a3f3d
revert: add back in lost styles.
crhallberg Feb 14, 2023
10d9cae
style(dark): draft dark theme.
crhallberg Feb 14, 2023
e42d28c
style: button line height.
crhallberg Feb 14, 2023
97b1e72
mix: GlobalContext feedback 1 (no tests).
crhallberg Feb 15, 2023
81d6d67
revert: wrong branch.
crhallberg Feb 15, 2023
c37e79a
Merge remote-tracking branch 'origin/dev' into dark-mode
crhallberg Jul 8, 2024
4f1a08a
Fix merge glitch.
demiankatz Jul 9, 2024
ef11d27
Flip inverted comments.
demiankatz Jul 9, 2024
375a1b7
Merge branch 'dev' into dark-mode
demiankatz Jul 9, 2024
f7644a2
Fix merge error.
demiankatz Jul 9, 2024
60f1374
Fix broken tests.
demiankatz Jul 9, 2024
ff5ecd5
Remove whitespace diff.
demiankatz Jul 9, 2024
0ee22b9
Merge branch 'dev' into dark-mode
demiankatz Jul 9, 2024
26274b1
Merge remote-tracking branch 'origin/dev' into dark-mode
crhallberg Oct 30, 2024
4fccbf4
style: improve ChildList and Child
crhallberg Oct 30, 2024
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
35 changes: 35 additions & 0 deletions client/components/ThemeMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react";
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select, { SelectChangeEvent } from '@mui/material/Select';
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're importing SelectChangeEvent but not using it.


import { useGlobalContext } from "../context/GlobalContext";

export default function ThemeMenu() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add a test for this component once it is finalized and before we merge this PR.

const {
state: { userTheme },
action: { setUserTheme },
} = useGlobalContext();

function changeTheme(e) {
setUserTheme(e.target.value);
}

return (
<FormControl className="user-theme__menu">
<InputLabel id="user-theme__label">Theme</InputLabel>
<Select
Copy link
Collaborator

Choose a reason for hiding this comment

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

When it comes time to test this, take a look at the test for my bulk editor -- it's a bit tricky to test MUI select controls, but that test does it successfully. (You have to trigger a MouseUp action, if I remember correctly...)

id="user-theme"
value={userTheme}
label="Theme"
labelId="user-theme__label"
onChange={changeTheme}
>
<MenuItem value={"system"}>System</MenuItem>
<MenuItem value={"light"}>Light</MenuItem>
<MenuItem value={"dark"}>Dark</MenuItem>
</Select>
</FormControl>
);
}
2 changes: 1 addition & 1 deletion client/components/edit/ObjectButtonBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ObjectButtonBar = ({ pid }: ObjectButtonBarProps): React.ReactElement => {
<ObjectStatus pid={pid} />
<EditParentsButton pid={pid} />
<button onClick={() => clearPidFromChildListStorage(pid)}>
<Refresh style={{ height: "14px" }} titleAccess="Refresh children" />
<Refresh style={{ height: "20px", verticalAlign: "sub" }} titleAccess="Refresh children" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we give this a class and move the styling to CSS? I'm pretty sure the direct style here was just my laziness, but if we're going to get fancier, maybe we should do things "the right way."

</button>
<ObjectPreviewButton pid={pid} />
<DeleteObjectButton pid={pid} />
Expand Down
26 changes: 18 additions & 8 deletions client/components/edit/ObjectStatus.module.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
.active,
.inactive,
.deleted,
.unknown {
display: inline-flex;
width: 100px;
text-align: left;
}

.indicator__label {
flex: 1 1 0%;
text-align: center;
}

.active .indicator {
color: green;
color: var(--object-status-active);
}

.inactive .indicator {
color: yellow;
color: var(--object-status-inactive);
}

.deleted .indicator {
color: red;
color: var(--object-status-deleted);
}

.unknown .indicator {
color: gray;
}

.indicator {
text-shadow: -1px 1px 0 #000, 1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
color: var(--object-status-unknown);
}
2 changes: 1 addition & 1 deletion client/components/edit/ObjectStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const ObjectStatus = ({ pid }: ObjectStatusProps): React.ReactElement =>
const stateMsg = loaded ? (
<button onClick={clickAction} className={styles[stateTxt.toLowerCase()]}>
<span className={styles.indicator}>&#9673;</span>&nbsp;
{stateTxt}
<span className={styles.indicator__label}>{stateTxt}</span>
</button>
) : (
""
Expand Down
12 changes: 10 additions & 2 deletions client/components/edit/__snapshots__/ObjectStatus.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ exports[`ObjectStatus defaults to unknown state 1`] = `
</span>

Unknown
<span
className="indicator__label"
>
Unknown
</span>
</button>,
",",
]
Expand All @@ -30,7 +34,11 @@ exports[`ObjectStatus displays the state found in the response 1`] = `
</span>

Inactive
<span
className="indicator__label"
>
Inactive
</span>
</button>,
",",
]
Expand Down
30 changes: 19 additions & 11 deletions client/components/edit/children/Child.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import styles from "./ChildList.module.css";
import React, { useState } from "react";
import { useEditorContext } from "../../../context/EditorContext";
import ChildList from "./ChildList";
Expand Down Expand Up @@ -41,7 +42,11 @@ export const Child = ({
const title = !loaded ? initialTitle : extractFirstMetadataValue(details?.metadata ?? {}, "dc:title", "-");
const expandControl = (
<span onClick={() => setExpanded(!expanded)}>
{expanded ? <IndeterminateCheckBox titleAccess="Collapse Tree" /> : <AddBox titleAccess="Expand Tree" />}
{
expanded
? <IndeterminateCheckBox titleAccess="Collapse Tree" className={styles.childlist__expandicon} />
: <AddBox titleAccess="Expand Tree" className={styles.childlist__expandicon} />
}
</span>
);
const childList = expanded ? (
Expand All @@ -53,33 +58,36 @@ export const Child = ({
forceThumbs={thumbnail}
/>
) : (
""
null
);
const hasExtraTools = thumbnail || models || showChildCounts;
const extraTools = hasExtraTools ? (
<Grid item xs={1}>
<Grid item xs>
{thumbnail ? <ObjectThumbnail pid={pid} /> : ""}
{showChildCounts ? <ObjectChildCounts pid={pid} /> : ""}
{models ? <ObjectModels pid={pid} /> : ""}
</Grid>
) : null;
return (
<>
<Grid container>
<Grid item xs={hasExtraTools ? 7 : 8}>
{expandControl}
<div className={styles.childlist__item}>
<Grid container sx={{ spacing: 2, alignItems: "center" }}>
<Grid item xs={6}>
{expandControl}{" "}
{loaded && parentPid ? <ChildPosition pid={pid} parentPid={parentPid} /> : ""}
<Link href={"/edit/object/" + pid}>{(title.length > 0 ? title : "-") + ` [${pid}]`}</Link>{" "}
<CopyPidButton pid={pid} />
<Link href={"/edit/object/" + pid}>{title || "(no title)"}</Link>
</Grid>
<Grid item xs={4}>
<Grid item xs>
{pid}
<CopyPidButton pid={pid} />
</Grid>
<Grid item xs="auto">
{loaded ? <ObjectButtonBar pid={pid} /> : ""}
<ObjectLoader pid={pid} />
</Grid>
{extraTools}
</Grid>
{childList}
</>
</div>
);
};

Expand Down
35 changes: 33 additions & 2 deletions client/components/edit/children/ChildList.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
.childlist {
margin-block: 0.75rem;
}

.childlist__list {
margin-block: 0;
padding-inline: 0;
list-style-type: none;
background-color: white;
}
.childlist__list > li {
margin-block: 0;
border-block-start: 1px solid var(--page-list-border);
}

.childlist__item {
margin-block: 0;
padding: 0.25rem;
}

.childlist__expandicon {
vertical-align: bottom;
}

/* Nested */

.childlist__list .childlist {
margin-inline-start: 1.5rem;
}

.childlist li {
border-top: 1px solid gray;
/* Pagination alignment */

.childlist .pagination {
margin-block-end: 1px;
}
.childlist .pagination li {
margin: 0;
}
73 changes: 38 additions & 35 deletions client/components/edit/children/ChildList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEditorContext } from "../../../context/EditorContext";
import Child from "./Child";
import SelectableChild from "./SelectableChild";
import CircularProgress from "@mui/material/CircularProgress";
import Grid from "@mui/material/Grid";
import Pagination from "@mui/material/Pagination";

export interface ChildListProps {
Expand Down Expand Up @@ -88,38 +89,34 @@ export const ChildList = ({
{showThumbs ? "Hide Thumbnails" : "Show Thumbnails"}
</button>
) : null;
const contents =
childDocs.length > 0 ? (
childDocs.map((child: Record<string, string>) => {
return (
<li key={`${pid}_child_${child.id}`}>
{selectCallback === false ? (
<Child
pid={child.id}
parentPid={pid}
initialTitle={child.title ?? "-"}
thumbnail={forceThumbs ?? showThumbs}
models={forceModels ?? showModels}
showChildCounts={forceChildCounts ?? showChildCounts}
/>
) : (
<SelectableChild
pid={child.id}
selectCallback={selectCallback}
initialTitle={child.title ?? "-"}
thumbnail={forceThumbs ?? showThumbs}
/>
)}
</li>
);
})
) : (
<p>Empty.</p>
);
const contents = childDocs.map((child: Record<string, string>) => {
return (
<li key={`${pid}_child_${child.id}`}>
{selectCallback === false ? (
<Child
pid={child.id}
parentPid={pid}
initialTitle={child.title ?? "-"}
thumbnail={forceThumbs ?? showThumbs}
models={forceModels ?? showModels}
showChildCounts={forceChildCounts ?? showChildCounts}
/>
) : (
<SelectableChild
pid={child.id}
selectCallback={selectCallback}
initialTitle={child.title ?? "-"}
thumbnail={forceThumbs ?? showThumbs}
/>
)}
</li>
);
});
const pageCount = Math.ceil(children.numFound / pageSize);
const paginator =
pageCount > 1 ? (
<Pagination
sx={{ ml: 3 }}
count={pageCount}
page={page}
siblingCount={2}
Expand All @@ -135,20 +132,26 @@ export const ChildList = ({
const endNumber = startNumber + pageSize - 1;
const paginatorLabel =
children.numFound > 1 ? (
<p>
<>
Showing {startNumber} - {children.numFound < endNumber ? children.numFound : endNumber} of{" "}
{children.numFound}
</p>
</>
) : null;
return (
<>
<div className={styles.childlist}>
{thumbsButton}
{modelsButton}
{childButton}
{paginatorLabel}
{paginator}
<ul className={styles.childlist}>{contents}</ul>
</>
<Grid container sx={{ spacing: 2, alignItems: "center" }}>
<Grid item xs="auto">
{paginatorLabel}
</Grid>
<Grid item xs="auto">
{paginator}
</Grid>
</Grid>
<ul className={styles.childlist__list}>{contents.length ? contents : <em>Empty.</em>}</ul>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

exports[`Child handles empty titles appropriately 1`] = `
<div
className="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
className="MuiGrid-root MuiGrid-container child__container css-11lq3yg-MuiGrid-root"
>
<div
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-8 css-vok43g-MuiGrid-root"
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-8 child__label css-vok43g-MuiGrid-root"
>
<span
onClick={[Function]}
>
<svg
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium child__expand-icon css-i4bv87-MuiSvgIcon-root"
data-testid="AddBoxIcon"
focusable="false"
role="img"
Expand Down Expand Up @@ -46,16 +46,16 @@ exports[`Child handles empty titles appropriately 1`] = `

exports[`Child renders a thumbnail 1`] = `
<div
className="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
className="MuiGrid-root MuiGrid-container child__container css-11lq3yg-MuiGrid-root"
>
<div
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-7 css-uqwprf-MuiGrid-root"
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-7 child__label css-uqwprf-MuiGrid-root"
>
<span
onClick={[Function]}
>
<svg
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium child__expand-icon css-i4bv87-MuiSvgIcon-root"
data-testid="AddBoxIcon"
focusable="false"
role="img"
Expand Down Expand Up @@ -194,16 +194,16 @@ exports[`Child renders thumbnail and child counts 1`] = `

exports[`Child renders using ajax-loaded data 1`] = `
<div
className="MuiGrid-root MuiGrid-container css-11lq3yg-MuiGrid-root"
className="MuiGrid-root MuiGrid-container child__container css-11lq3yg-MuiGrid-root"
>
<div
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-8 css-vok43g-MuiGrid-root"
className="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-8 child__label css-vok43g-MuiGrid-root"
>
<span
onClick={[Function]}
>
<svg
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
className="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium child__expand-icon css-i4bv87-MuiSvgIcon-root"
data-testid="AddBoxIcon"
focusable="false"
role="img"
Expand Down
Loading