mirror of
https://github.com/zadam/trilium.git
synced 2025-12-16 05:09:54 +01:00
feat(layout): disable transition when promoted attributes are shown by default
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
.collapsible-body {
|
.collapsible-body {
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: height 250ms ease-in;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.collapsible-inner-body {
|
.collapsible-inner-body {
|
||||||
@@ -29,4 +28,10 @@
|
|||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.with-transition {
|
||||||
|
.collapsible-body {
|
||||||
|
transition: height 250ms ease-in;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import "./Collapsible.css";
|
|||||||
|
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { ComponentChildren, HTMLAttributes } from "preact";
|
import { ComponentChildren, HTMLAttributes } from "preact";
|
||||||
import { useRef, useState } from "preact/hooks";
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { useElementSize, useUniqueName } from "./hooks";
|
import { useElementSize, useUniqueName } from "./hooks";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
@@ -26,9 +26,20 @@ export function ExternallyControlledCollapsible({ title, children, className, ex
|
|||||||
const innerRef = useRef<HTMLDivElement>(null);
|
const innerRef = useRef<HTMLDivElement>(null);
|
||||||
const { height } = useElementSize(innerRef) ?? {};
|
const { height } = useElementSize(innerRef) ?? {};
|
||||||
const contentId = useUniqueName();
|
const contentId = useUniqueName();
|
||||||
|
const [ transitionEnabled, setTransitionEnabled ] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
setTransitionEnabled(true);
|
||||||
|
}, 200);
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx("collapsible", className, expanded && "expanded")}>
|
<div className={clsx("collapsible", className, {
|
||||||
|
expanded,
|
||||||
|
"with-transition": transitionEnabled
|
||||||
|
})}>
|
||||||
<button
|
<button
|
||||||
className="collapsible-title"
|
className="collapsible-title"
|
||||||
onClick={() => setExpanded(!expanded)}
|
onClick={() => setExpanded(!expanded)}
|
||||||
|
|||||||
Reference in New Issue
Block a user