From 3328998973cda43a37d6f8e980a2c128523e6d82 Mon Sep 17 00:00:00 2001 From: whereareiam Date: Sat, 5 Sep 2026 22:33:49 +0200 Subject: [PATCH] fix(code): unify expanded repository search controls --- styles/public/dropdown/selection_dropdown.ts | 4 +- styles/public/input.ts | 95 +++++++++++++++++++- styles/templates/repo/home.ts | 10 +++ templates/repo/view_content.tmpl | 2 +- 4 files changed, 107 insertions(+), 4 deletions(-) diff --git a/styles/public/dropdown/selection_dropdown.ts b/styles/public/dropdown/selection_dropdown.ts index a6f59473..93f5f4f1 100644 --- a/styles/public/dropdown/selection_dropdown.ts +++ b/styles/public/dropdown/selection_dropdown.ts @@ -23,8 +23,8 @@ import { activeItemAfterStyle } from "@lutinglt/gitea-github-theme/styles/common // 选择框的下拉菜单看起来像普通按钮 const selectionDropdown = css` /* 排除可搜索输入框和 Forgejo 15 的仓库拥有者选择框 */ - .ui.selection.dropdown:not(.search):not(:has(> #uid)), - .ui.selection.dropdown.active:not(.search):not(:has(> #uid)) { + .ui.selection.dropdown:not(.search):not(:has(> #uid)):not(.theme-search-control .dropdown), + .ui.selection.dropdown.active:not(.search):not(:has(> #uid)):not(.theme-search-control .dropdown) { background-color: ${themeVars.color.button}; border-color: ${themeVars.color.light.border}; border-radius: ${otherThemeVars.border.radius}; diff --git a/styles/public/input.ts b/styles/public/input.ts index 834c703a..30519bd6 100644 --- a/styles/public/input.ts +++ b/styles/public/input.ts @@ -139,4 +139,97 @@ const checkBoxAndRadio = css` } `; -export default cssCombine(input, checkBoxAndRadio); +// Opt-in search group for native Forgejo query/mode/submit controls. +const searchControl = css` + .ui.form.theme-search-control > .ui.action.input { + display: flex; + align-items: stretch; + height: 32px; + min-width: 0; + border: 1px solid ${themeVars.color.light.border}; + border-radius: ${otherThemeVars.border.radius}; + background: ${themeVars.color.body}; + box-shadow: none; + &:has(> input:focus-visible) { + outline: 2px solid ${themeVars.github.fgColor.accent}; + outline-offset: -1px; + } + & > input[type="search"] { + min-width: 0; + width: 0; + flex: 1 1 0; + height: 30px; + padding: 5px 12px; + font-size: 14px; + line-height: 20px; + background: transparent; + border: 0; + border-radius: inherit; + box-shadow: none; + outline: none; + } + & > .ui.selection.dropdown, + & > .ui.button { + flex: 0 0 auto; + height: 30px; + min-height: 30px; + margin: 0; + border: 0; + border-left: 1px solid ${themeVars.color.light.border}; + border-radius: 0; + background: transparent; + box-shadow: none; + color: ${themeVars.color.text.light.num1}; + &:hover { + background: ${themeVars.color.hover.self}; + } + &:focus-visible { + outline: 2px solid ${themeVars.github.fgColor.accent}; + outline-offset: -2px; + } + } + & > .ui.selection.dropdown { + display: flex; + align-items: center; + width: auto; + min-width: 88px; + padding: 5px 28px 5px 8px; + font-size: 12px; + line-height: 20px; + & > .text { + margin: 0; + line-height: 20px; + } + & > .dropdown.icon { + top: 50%; + transform: translateY(-50%); + right: 8px; + padding: 0; + margin: 0; + width: 16px; + height: 16px; + } + & > .menu { + left: auto; + right: 0; + width: 200px; + min-width: 200px; + margin-top: 4px; + } + } + & > .ui.button { + display: grid; + place-items: center; + width: 32px; + padding: 0 !important; + border-radius: 0 ${otherThemeVars.border.radius} ${otherThemeVars.border.radius} 0; + & > svg { + width: 16px; + height: 16px; + margin: 0; + } + } + } +`; + +export default cssCombine(input, checkBoxAndRadio, searchControl); diff --git a/styles/templates/repo/home.ts b/styles/templates/repo/home.ts index af760483..169909f6 100644 --- a/styles/templates/repo/home.ts +++ b/styles/templates/repo/home.ts @@ -228,6 +228,7 @@ const repositoryHome = css` border-bottom: 1px solid ${themeVars.color.light.border}; } .page-content.repository.file.list .repo-button-row { + position: relative; flex-wrap: nowrap; align-items: center; } @@ -246,6 +247,15 @@ const repositoryHome = css` .page-content.repository.file.list .repo-button-row .repo-add-file { display: none; } + .page-content.repository.file.list .repo-code-dropdown { + position: static; + } + .page-content.repository.file.list .repo-button-row .repo-code-dropdown > .content { + left: 0; + right: 0; + top: 100%; + width: auto; + } .page-content.repository.file.list .repo-code-dropdown > summary > span { display: none; } diff --git a/templates/repo/view_content.tmpl b/templates/repo/view_content.tmpl index 9603a3ee..12ac0045 100644 --- a/templates/repo/view_content.tmpl +++ b/templates/repo/view_content.tmpl @@ -106,7 +106,7 @@ {{if and (not (StringUtils.HasPrefix .BranchNameSubURL "commit")) (or .CodeIndexerDisabled (and (not .TagName) (eq .Repository.DefaultBranch .BranchName)))}}