From cad31a338296930d3a8e35fd75c300df7f1b5b6a Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Sat, 11 Nov 2023 19:49:04 +0100 Subject: [PATCH] Fix rendering of inline code blocks for docs E2E tests can be added rather easily to this. Styling of codeblocks: - Uniform margins as other documentation elements. - Add small margin for inline code-blocks. - Use different background color for inline code-blocks. - Introduce `inline-code` and `code-block` mixins for clarity in styling. Overflowing of codeblocks: - Improve flex layout of the tree component to be handle overflowing content and providing maximum available width. To be able to correctly provide maximum available width in card content, card expansion layout is changed so both close button and the content gets their full width. - Other refactorings to support this: - Introduce separate Vue component for checkboxes of nodes for better separation of concerns and improved maintainability. - Refactor `LeafTreeNode` to make it simpler, separating layout concerns from other styling. - `ScriptsTree.vue`: Prefer `
`s instead of ``s as they represent large content. - Remove unnecessary `
`s and use ` @@ -184,20 +184,24 @@ $card-horizontal-gap : $card-gap; position: relative; background-color: $color-primary-darker; color: $color-on-primary; + display: flex; align-items: center; + flex-direction: column; &__content { - flex: 1; display: flex; justify-content: center; word-break: break-word; + margin-bottom: 1em; + margin-left: 0.5em; + margin-right: 0.5em; + max-width: 100%; // Ensure the inner content does not horizontally grow (e.g., when a code block is shown) } &__close-button { - width: auto; font-size: 1.5em; - align-self: flex-start; + align-self: flex-end; margin-right: 0.25em; @include clickable; color: $color-primary-light; @@ -242,8 +246,6 @@ $card-horizontal-gap : $card-gap; .card__expander { min-height: 200px; - // max-height: 1000px; - // overflow-y: auto; margin-top: $expanded-margin-top; opacity: 1; } diff --git a/src/presentation/components/Scripts/View/TheScriptsView.vue b/src/presentation/components/Scripts/View/TheScriptsView.vue index f0d481dde..f7742b923 100644 --- a/src/presentation/components/Scripts/View/TheScriptsView.vue +++ b/src/presentation/components/Scripts/View/TheScriptsView.vue @@ -1,6 +1,6 @@ +
diff --git a/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentableNode.vue b/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentableNode.vue index f1687fed8..3e8a5548f 100644 --- a/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentableNode.vue +++ b/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentableNode.vue @@ -62,6 +62,7 @@ export default defineComponent({ .container { display: flex; flex-direction: column; + width: 100%; // This prevents content overflowing on smaller screens *:not(:first-child) { margin-left: 5px; } @@ -69,7 +70,7 @@ export default defineComponent({ display: flex; flex-direction: row; .content { - flex: 1; + flex: 1; } } .docs { diff --git a/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentationText.vue b/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentationText.vue index 3dcdc08c9..d2f032e41 100644 --- a/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentationText.vue +++ b/src/presentation/components/Scripts/View/Tree/NodeContent/Documentation/DocumentationText.vue @@ -60,15 +60,47 @@ function renderAsMarkdownListItem(content: string): string { $text-color: $color-on-primary; $text-size: 0.75em; // Lower looks bad on Firefox +@mixin code-block() { + pre { + // :has(> code) { @content; } would be better, but Firefox doesn't support it https://caniuse.com/css-has + @content; + } +} + +@mixin inline-code() { + :not(pre) > code { + @content; + } +} + +@mixin code() { + code { + @content; + } +} + .documentation-text { color: $text-color; font-size: $text-size; font-family: $font-main; - code { - word-break: break-all; // Inline code should wrap with the line, or whole text overflows + $standard-gap: $text-size; + + @include code { font-family: $font-normal; font-weight: 600; } + + @include inline-code { + word-break: break-all; // Inline code should wrap with the line, or whole text overflows + } + + @include code-block { + padding: $standard-gap; + background: $color-primary-darker; + display: block; + overflow: auto; + } + a { &[href] { word-break: break-word; // So URLs don't overflow @@ -135,6 +167,7 @@ $text-size: 0.75em; // Lower looks bad on Firefox @include no-margin('p'); @include no-margin('h1, h2, h3, h4, h5, h6'); @include no-margin('blockquote'); + @include no-margin('pre'); /* Add spacing between elements using `margin-bottom` only (bottom-out instead of top-down strategy). */ $small-gap: math.div($vertical-gap, 2); @@ -144,6 +177,7 @@ $text-size: 0.75em; // Lower looks bad on Firefox @include bottom-margin('li', $small-gap); @include bottom-margin('table', $vertical-gap); @include bottom-margin('blockquote', $vertical-gap); + @include bottom-margin('pre', $vertical-gap); } @mixin apply-uniform-horizontal-spacing($horizontal-gap) { @@ -167,7 +201,7 @@ $text-size: 0.75em; // Lower looks bad on Firefox } blockquote { - padding: 0 1em; + padding: 0 $standard-gap; border-left: .25em solid $color-primary; } } diff --git a/src/presentation/components/Scripts/View/Tree/NodeContent/NodeContent.vue b/src/presentation/components/Scripts/View/Tree/NodeContent/NodeContent.vue index 57f247268..c2d496237 100644 --- a/src/presentation/components/Scripts/View/Tree/NodeContent/NodeContent.vue +++ b/src/presentation/components/Scripts/View/Tree/NodeContent/NodeContent.vue @@ -40,6 +40,7 @@ export default defineComponent({ display: flex; flex-direction: row; flex-wrap: wrap; + .text { display: flex; align-items: center; diff --git a/src/presentation/components/Scripts/View/Tree/ScriptsTree.vue b/src/presentation/components/Scripts/View/Tree/ScriptsTree.vue index 51a201823..4206e42da 100644 --- a/src/presentation/components/Scripts/View/Tree/ScriptsTree.vue +++ b/src/presentation/components/Scripts/View/Tree/ScriptsTree.vue @@ -1,6 +1,6 @@ + +
+ + diff --git a/src/presentation/components/Scripts/View/Tree/TreeView/Node/HierarchicalTreeNode.vue b/src/presentation/components/Scripts/View/Tree/TreeView/Node/HierarchicalTreeNode.vue index cc3c38026..e7979492e 100644 --- a/src/presentation/components/Scripts/View/Tree/TreeView/Node/HierarchicalTreeNode.vue +++ b/src/presentation/components/Scripts/View/Tree/TreeView/Node/HierarchicalTreeNode.vue @@ -5,7 +5,6 @@ :style="{ 'padding-left': `${currentNode.hierarchy.depthInTree * 24}px`, }" - @click="toggleCheck" >
- - - +
+ + + +
-