mirror of
https://github.com/zadam/trilium.git
synced 2025-12-16 20:34:25 +01:00
feat(layout): basic ARIA & some padding
This commit is contained in:
parent
a7ca839afb
commit
5a09a80902
@ -4,8 +4,6 @@ body.experimental-feature-new-layout {
|
||||
}
|
||||
|
||||
.title-actions {
|
||||
padding-inline-start: 15px;
|
||||
padding-top: 1em;
|
||||
padding-bottom: 0.2em;
|
||||
padding: 0.75em 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,10 @@
|
||||
line-height: 1em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: inherit;
|
||||
|
||||
.arrow {
|
||||
font-size: 1.3em;
|
||||
|
||||
@ -4,7 +4,7 @@ import clsx from "clsx";
|
||||
import { ComponentChildren, HTMLAttributes } from "preact";
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
|
||||
import { useElementSize } from "./hooks";
|
||||
import { useElementSize, useUniqueName } from "./hooks";
|
||||
import Icon from "./Icon";
|
||||
|
||||
interface CollapsibleProps extends Pick<HTMLAttributes<HTMLDivElement>, "className"> {
|
||||
@ -18,21 +18,26 @@ export default function Collapsible({ title, children, className, initiallyExpan
|
||||
const innerRef = useRef<HTMLDivElement>(null);
|
||||
const [ expanded, setExpanded ] = useState(initiallyExpanded);
|
||||
const { height } = useElementSize(innerRef) ?? {};
|
||||
const contentId = useUniqueName();
|
||||
|
||||
return (
|
||||
<div className={clsx("collapsible", className, expanded && "expanded")}>
|
||||
<div
|
||||
<button
|
||||
className="collapsible-title"
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
aria-expanded={expanded}
|
||||
aria-controls={contentId}
|
||||
>
|
||||
<Icon className="arrow" icon="bx bx-chevron-right" />
|
||||
{title}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div
|
||||
id={contentId}
|
||||
ref={bodyRef}
|
||||
className="collapsible-body"
|
||||
style={{ height: expanded ? height : "0" }}
|
||||
aria-hidden={!expanded}
|
||||
>
|
||||
<div
|
||||
ref={innerRef}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user