Skip to content

Build your personal knowledge base with Trilium Notes

style/collapsible: full restyle

Adorian Doran9523be995fa7
diff --git a/packages/ckeditor5-collapsible/theme/collapsible.css b/packages/ckeditor5-collapsible/theme/collapsible.css
index 96e86575d4..7567261e8d 100644
--- a/packages/ckeditor5-collapsible/theme/collapsible.css
+++ b/packages/ckeditor5-collapsible/theme/collapsible.css
@@ -4,22 +4,81 @@
*/
.ck-content details.trilium-collapsible {
- border: 1px solid var(--card-border-color, #ddd);
- border-radius: 6px;
- background: var(--card-background-color, transparent);
- padding: 0.5em 1em;
+ --collapsible-block-background: var(--card-background-color);
+ --collapsible-block-summary-background: var(--card-background-color);
+
+ --_border-radius: 8px;
+ --_block-padding: .75rem;
+ --_inline-padding: 1rem;
+ --_margin-between-collapsibles: 3px;
+ --_content-indent: 2rem;
+ --_arrow-gap: 2rem;
+
+ position: relative;
+ overflow: hidden;
+ isolation: isolate;
margin: 1em 0;
-}
+ border-radius: var(--_border-radius);
+ background: var(--collapsible-block-background);
+ padding: var(--_block-padding) var(--_inline-padding) var(--_block-padding) var(--_content-indent);
-.ck-content details.trilium-collapsible > summary {
- cursor: pointer;
- font-weight: 600;
- padding: 0.25em 0;
- outline: none;
-}
+ &:not(& + &):has(+ details.trilium-collapsible) {
+ /* First collapsibile from the series */
+ margin-bottom: var(--_margin-between-collapsibles);
+ border-end-start-radius: 0;
+ border-end-end-radius: 0;
+ }
+
+ & + &:has(+ details.trilium-collapsible) {
+ /* Middle collapsibile blocks from the series */
+ margin-bottom: var(--_margin-between-collapsibles);
+ margin-top: 0;
+ border-radius: 0;
+ }
+
+ & + &:not(:has(+ details.trilium-collapsible)) {
+ /* The last collapsibile from the series */
+ margin-top: 0;
+ border-start-start-radius: 0;
+ border-start-end-radius: 0;
+ }
+
+ > summary {
+ position: relative;
+ left: calc(0px - var(--_content-indent ) / 2);
+ width: calc(100% + var(--_content-indent));
+ cursor: pointer;
+ font-weight: 500;
+ outline: none;
+
+ &::after {
+ display: block;
+ content: "";
+ z-index: -1;
+ position: absolute;
+ top: calc(0px - (var(--_block-padding) + 1px));
+ left: calc(0px - var(--_content-indent ) / 2);
+ width: calc(100% + var(--_inline-padding) * 2 + 1px);
+ height: calc(100% + var(--_block-padding) * 2 + 1px);
+ background: var(--collapsible-block-summary-background);
+ }
+
+ &:hover::after {
+ background: var(--card-background-hover-color);
+ }
+ }
-.ck-content details.trilium-collapsible[open] > summary {
- margin-bottom: 0.5em;
+ &[open] > summary {
+ margin-bottom: calc(var(--_block-padding) * 2);
+
+ &::after {
+ border-bottom: 2px solid white;
+ }
+ }
+
+ > *:not(summary) {
+ margin-bottom: 0;
+ }
}
/*
@@ -29,43 +88,52 @@
* The data/published view is untouched.
*/
-.ck-editor__editable details.trilium-collapsible > summary {
- cursor: text;
- list-style: none;
- position: relative;
- padding-left: 1.5em;
-}
+.ck-editor__editable details.trilium-collapsible {
+ > summary {
+ cursor: text;
+ list-style: none;
+ position: relative;
+ padding-left: var(--_arrow-gap);
-.ck-editor__editable details.trilium-collapsible > summary::-webkit-details-marker {
- display: none;
-}
+ &::-webkit-details-marker {
+ display: none;
+ }
-/* The arrow lands wherever in DOM the conversion mapper ends up putting it, but
- * we pin it visually to the left edge of the summary with absolute positioning
- * so the title text always reads left-to-right with the arrow first. */
-.ck-editor__editable details.trilium-collapsible > summary > .trilium-collapsible-arrow {
- position: absolute;
- left: 0;
- top: 0.25em;
- cursor: pointer;
- user-select: none;
- color: var(--muted-text-color, currentColor);
- transition: transform 0.15s ease;
- line-height: 1;
-}
+ /* CKEditor's placeholder ::before is positioned absolute left:0 by default —
+ * push it past the arrow so it aligns with where the typed title will appear. */
+ &.ck-placeholder::before {
+ left: var(--_arrow-gap);
+ opacity: 0.5;
+ }
-.ck-editor__editable details.trilium-collapsible > summary > .trilium-collapsible-arrow::before {
- /* U+25B6 BLACK RIGHT-POINTING TRIANGLE; CSS escape avoids encoding pitfalls. */
- content: "\25B6";
- font-size: 0.8em;
-}
+ /* The arrow lands wherever in DOM the conversion mapper ends up putting it,
+ * but we pin it visually to the left edge of the summary with absolute
+ * positioning so the title text always reads left-to-right with the arrow first. */
+ > .trilium-collapsible-arrow {
+ position: absolute;
+ left: 0;
+ top: -0.05em;
+ cursor: pointer;
+ user-select: none;
+ transition: transform 0.15s ease;
+ width: 1lh;
+ height: 1lh;
-.ck-editor__editable details.trilium-collapsible[open] > summary > .trilium-collapsible-arrow {
- transform: rotate(90deg);
-}
+ &::before {
+ position: absolute;
+ inset: 0;
+ content: "";
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ align-content: center;
+ font-size: 1.3em;
+ font-family: boxicons;
+ }
+ }
+ }
-/* CKEditor's placeholder ::before is positioned absolute left:0 by default —
- * push it past the arrow so it aligns with where the typed title will appear. */
-.ck-editor__editable details.trilium-collapsible > summary.ck-placeholder::before {
- left: 1.5em;
+ &[open] > summary > .trilium-collapsible-arrow {
+ transform: rotate(90deg);
+ }
}