Let the cards at the top of the dashboard be hidden
Customise now puts a name bar with Hide / Show above Needs attention, My work, Since you last looked, Getting started and the To do list, like the Overview cards. Hidden cards are gone outside Customise (dimmed inside it), the choice is saved on the user record and Reset to default clears it. When every card of one side of the top row is hidden the other takes the full width; hiding all removes the row. The standalone To do card is an ordinary card rather than the side-by-side one. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2b0623531a
commit
8a9317772c
3 files changed
+105
-14
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { IconEye, IconEyeOff } from "@tabler/icons-react";
|
||||
import { setCardHidden, useDashboardLayout } from "../utils/dashboardLayout";
|
||||
|
||||
/** Whether the person has hidden a dashboard card, whether they are arranging the dashboard, and so whether the card is to be drawn (hidden ones are drawn, dimmed, while arranging). */
|
||||
export function useCardState(label: string): { hidden: boolean; editing: boolean; shown: boolean } {
|
||||
const { layout, editing } = useDashboardLayout();
|
||||
const hidden = layout.hidden.includes(label);
|
||||
return { hidden, editing, shown: !hidden || editing };
|
||||
}
|
||||
|
||||
/** The bar above a card while the dashboard is being arranged: its name and a button to hide it or bring it back. */
|
||||
export function HideBar({ label, hidden }: { label: string; hidden: boolean }) {
|
||||
return (
|
||||
<div className="card-customise">
|
||||
<span className="small text-secondary">{label}</span>
|
||||
<button type="button" className="btn btn-sm ms-auto d-inline-flex align-items-center gap-1" aria-pressed={hidden} onClick={() => void setCardHidden(label, !hidden)}>
|
||||
{hidden ? <IconEye size={16} aria-hidden="true" /> : <IconEyeOff size={16} aria-hidden="true" />}
|
||||
{hidden ? "Show" : "Hide"}
|
||||
<span className="visually-hidden"> {label}</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A card at the top of the dashboard that the person can hide. Hidden, it is gone; while they arrange the dashboard (Customise) it is there, dimmed, under a bar that hides it or brings it back.
|
||||
* It is kept the same way as the other cards' arrangement — on their user record, so it follows them to any browser — and Reset to default shows it again.
|
||||
*/
|
||||
export default function Hideable({ label, children }: { label: string; children: ReactNode }) {
|
||||
const { hidden, editing, shown } = useCardState(label);
|
||||
if (!shown) return null;
|
||||
return (
|
||||
<div className={`hideable ${hidden ? "card-hidden" : ""}`}>
|
||||
{editing && <HideBar label={label} hidden={hidden} />}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user