feat(status_bar): functional attribute toggle button

This commit is contained in:
Elian Doran
2025-12-12 21:57:42 +02:00
parent 685109556c
commit 60fc34ffac
3 changed files with 22 additions and 14 deletions

View File

@@ -154,7 +154,7 @@ button.btn.btn-success kbd {
color: var(--button-group-active-button-text-color); color: var(--button-group-active-button-text-color);
} }
/* /*
* Input boxes * Input boxes
*/ */
@@ -399,7 +399,8 @@ button.select-button.dropdown-toggle.btn:active {
select:focus, select:focus,
select.form-select:focus, select.form-select:focus,
select.form-control:focus, select.form-control:focus,
.select-button.dropdown-toggle.btn:focus { .select-button.dropdown-toggle.btn:focus,
.select-button.focus-outline:focus {
box-shadow: unset; box-shadow: unset;
outline: 3px solid var(--input-focus-outline-color); outline: 3px solid var(--input-focus-outline-color);
outline-offset: 0; outline-offset: 0;
@@ -422,7 +423,7 @@ optgroup {
line-height: 40px; line-height: 40px;
} }
/* /*
* File input * File input
* *
* <label class="tn-file-input tn-input-field"> * <label class="tn-file-input tn-input-field">
@@ -784,4 +785,4 @@ input[type="range"] {
scrollbar-color: unset; scrollbar-color: unset;
scrollbar-width: unset; scrollbar-width: unset;
} }
} }

View File

@@ -26,6 +26,7 @@
align-items: center; align-items: center;
border: 0; border: 0;
&.active,
&:focus, &:focus,
&:hover { &:hover {
background: var(--input-background-color); background: var(--input-background-color);

View File

@@ -36,11 +36,12 @@ interface StatusBarContext {
export default function StatusBar() { export default function StatusBar() {
const { note, noteContext, viewScope } = useActiveNoteContext(); const { note, noteContext, viewScope } = useActiveNoteContext();
const [ attributesShown, setAttributesShown ] = useState(false);
const context = note && noteContext && { note, noteContext, viewScope } satisfies StatusBarContext; const context = note && noteContext && { note, noteContext, viewScope } satisfies StatusBarContext;
return ( return (
<div className="status-bar"> <div className="status-bar">
{context && <AttributesPane {...context} />} {context && <AttributesPane shown={attributesShown} {...context} />}
<div className="status-bar-main-row"> <div className="status-bar-main-row">
{context && <> {context && <>
@@ -49,7 +50,7 @@ export default function StatusBar() {
</div> </div>
<div className="actions-row"> <div className="actions-row">
<AttributesButton {...context} /> <AttributesButton attributesShown={attributesShown} setAttributesShown={setAttributesShown} {...context} />
<AttachmentCount {...context} /> <AttachmentCount {...context} />
<BacklinksBadge {...context} /> <BacklinksBadge {...context} />
<LanguageSwitcher {...context} /> <LanguageSwitcher {...context} />
@@ -93,12 +94,13 @@ interface StatusBarButtonBaseProps {
title: string; title: string;
text?: string | number; text?: string | number;
disabled?: boolean; disabled?: boolean;
active?: boolean;
} }
type StatusBarButtonWithCommand = StatusBarButtonBaseProps & { triggerCommand: CommandNames; }; type StatusBarButtonWithCommand = StatusBarButtonBaseProps & { triggerCommand: CommandNames; };
type StatusBarButtonWithClick = StatusBarButtonBaseProps & { onClick: () => void; }; type StatusBarButtonWithClick = StatusBarButtonBaseProps & { onClick: () => void; };
function StatusBarButton({ className, icon, text, title, ...restProps }: StatusBarButtonWithCommand | StatusBarButtonWithClick) { function StatusBarButton({ className, icon, text, title, active, ...restProps }: StatusBarButtonWithCommand | StatusBarButtonWithClick) {
const parentComponent = useContext(ParentComponent); const parentComponent = useContext(ParentComponent);
const buttonRef = useRef<HTMLButtonElement>(null); const buttonRef = useRef<HTMLButtonElement>(null);
useStaticTooltip(buttonRef, { useStaticTooltip(buttonRef, {
@@ -111,7 +113,7 @@ function StatusBarButton({ className, icon, text, title, ...restProps }: StatusB
return ( return (
<button <button
ref={buttonRef} ref={buttonRef}
className={clsx("btn select-button", className)} className={clsx("btn select-button focus-outline", className, active && "active")}
type="button" type="button"
onClick={() => { onClick={() => {
if ("triggerCommand" in restProps) { if ("triggerCommand" in restProps) {
@@ -246,7 +248,10 @@ function AttachmentCount({ note }: StatusBarContext) {
//#endregion //#endregion
//#region Attributes //#region Attributes
function AttributesButton({ note }: StatusBarContext) { function AttributesButton({ note, attributesShown, setAttributesShown }: StatusBarContext & {
attributesShown: boolean;
setAttributesShown: (shown: boolean) => void;
}) {
const [ count, setCount ] = useState(note.attributes.length); const [ count, setCount ] = useState(note.attributes.length);
// React to changes in count. // React to changes in count.
@@ -262,14 +267,15 @@ function AttributesButton({ note }: StatusBarContext) {
icon="bx bx-list-check" icon="bx bx-list-check"
title={t("status_bar.attributes_title")} title={t("status_bar.attributes_title")}
text={t("status_bar.attributes", { count })} text={t("status_bar.attributes", { count })}
onClick={() => { active={attributesShown}
alert("Hi"); onClick={() => setAttributesShown(!attributesShown)}
}}
/> />
); );
} }
function AttributesPane({ note, noteContext }: StatusBarContext) { function AttributesPane({ note, noteContext, shown }: StatusBarContext & {
shown: boolean;
}) {
const parentComponent = useContext(ParentComponent); const parentComponent = useContext(ParentComponent);
const api = useRef<AttributeEditorImperativeHandlers>(null); const api = useRef<AttributeEditorImperativeHandlers>(null);
@@ -280,7 +286,7 @@ function AttributesPane({ note, noteContext }: StatusBarContext) {
}; };
return (context && return (context &&
<div className="attribute-list"> <div className={clsx("attribute-list", !shown && "hidden-ext")}>
<InheritedAttributesTab {...context} /> <InheritedAttributesTab {...context} />
<AttributeEditor <AttributeEditor