loading up the forgejo repo on tangled to test page performance

fix(ui): ensure consistent switch position in markdown editor (#7492)

Followup to https://codeberg.org/forgejo/forgejo/pulls/7481.

Fix a bug reported by @Gusted where the switch would jump ~1px up when switched to preview mode.

It was because the switch is always center-aligning to the largest element in the toolbar. With toolbar buttons disappearing, the largest element was the switch itself. By placing it in a box with same height as the buttons we can ensure it can always stay in the same position.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7492
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>

authored by 0ko 0ko and committed by Gusted 282125e9 eca57cc3

Changed files
+10 -4
templates
web_src
+5 -3
templates/shared/combomarkdowneditor.tmpl
··· 16 16 17 17 <markdown-toolbar> 18 18 {{if .MarkdownPreviewUrl}} 19 - <div class="switch"> 20 - <a href="#" class="active item" data-tab-for="markdown-writer">{{ctx.Locale.Tr "write"}}</a> 21 - <a href="#" class="item" data-tab-for="markdown-previewer" data-preview-url="{{.MarkdownPreviewUrl}}" data-preview-context="{{.MarkdownPreviewContext}}">{{ctx.Locale.Tr "preview"}}</a> 19 + <div class="markdown-toolbar-switch"> 20 + <div class="switch"> 21 + <a href="#" class="active item" data-tab-for="markdown-writer">{{ctx.Locale.Tr "write"}}</a> 22 + <a href="#" class="item" data-tab-for="markdown-previewer" data-preview-url="{{.MarkdownPreviewUrl}}" data-preview-context="{{.MarkdownPreviewContext}}">{{ctx.Locale.Tr "preview"}}</a> 23 + </div> 22 24 </div> 23 25 {{end}} 24 26 <div class="markdown-toolbar-group">
+5 -1
web_src/css/editor/combomarkdowneditor.css
··· 11 11 flex-wrap: wrap; 12 12 } 13 13 14 - markdown-toolbar .switch .item { 14 + .markdown-toolbar-switch { 15 + display: flex; 16 + height: 30px; 17 + } 18 + .markdown-toolbar-switch .switch .item { 15 19 padding: 0.25em 1em; 16 20 } 17 21