Skip to content

Compact header height for better above-the-fold density - #101

Merged
alvin000009238 merged 3 commits into
devfrom
codex/reduce-header-height-for-better-ux
Mar 31, 2026
Merged

Compact header height for better above-the-fold density#101
alvin000009238 merged 3 commits into
devfrom
codex/reduce-header-height-for-better-ux

Conversation

@alvin000009238

Copy link
Copy Markdown
Owner

Motivation

  • 頁面頂部 header 佔比過高,導致首屏內容被壓縮和視覺密度過低,手機上問題更明顯。
  • 目標是把 header 壓縮到合理密度(不使用固定高度),保留可讀性與最小點擊區域。

Description

  • .header 垂直 padding 從 14px 調整為 10px,並把 .header-content 改為 nowrap 並縮小 gap 以避免換行撐高容器。
  • 縮小 logo 與 icon 大小(.logo-icon 36→32、svg 20→18)並為標題/副標題設定 line-height 與移除 h1 預設 margin,修正文字造成的額外高度。
  • 調整互動元件尺寸:按鈕使用 min-height: 36px 並減少水平 padding,主題切換按鈕改為 36x36,以維持至少 36px 的最小點擊區域而不鎖定容器高度。
  • 手機版布局調整:將響應式 .header-content 維持為單行(row)、縮小間距、隱藏次要的 time-info,讓 header 在小螢幕更緊湊。

Testing

  • 執行 npm test(前端測試),所有測試通過(13 tests, 0 failed)。
  • 執行 npm run build 成功產生 production build 並更新靜態資產。

Codex Task

Copilot AI review requested due to automatic review settings March 31, 2026 13:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refines the header UI by adjusting dimensions, spacing, and layout properties across base and responsive stylesheets. Key changes include reducing the size of the logo and action buttons, updating padding and gaps, and modifying the responsive behavior of the header content. Feedback identifies potential content overflow risks introduced by disabling flex wrapping and points out several redundant CSS declarations in the responsive styles that are already inherited from the base configuration.

align-items: center;

flex-wrap: wrap;
flex-wrap: nowrap;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

.header-content 設置為 flex-wrap: nowrap 雖然能確保高度固定,但在內容較多(例如標題文字較長或導航項目增加)的情況下,可能會導致內容溢出容器。建議為標題區域設置 min-width: 0 並對 h1 使用 text-overflow: ellipsis,以確保在空間不足時能優雅處理。

Comment thread frontend/styles/responsive.css Outdated
Comment on lines +27 to +33
flex-direction: row;

align-items: center;

gap: 10px;

align-items: flex-start;
flex-wrap: nowrap;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在此媒體查詢中,align-items: centerflex-wrap: nowrap 已在 header.css 的基礎樣式中定義,此處重複設置是多餘的。此外,在手機版強制單行顯示 (flex-direction: rownowrap) 存在佈局溢出風險,建議僅保留必要的屬性變更並檢查窄螢幕下的表現。

Suggested change
flex-direction: row;
align-items: center;
gap: 10px;
align-items: flex-start;
flex-wrap: nowrap;
flex-direction: row;
gap: 10px;

Comment thread frontend/styles/responsive.css Outdated
Comment on lines +62 to +64
font-size: 18px;

line-height: 1.2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

此處的 line-height: 1.2header.css 第 101 行中設置的基礎樣式完全相同。由於該屬性會被繼承且未被修改,在媒體查詢中重複定義是多餘的。

Suggested change
font-size: 18px;
line-height: 1.2;
font-size: 18px;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces the visual height of the top header to improve above-the-fold content density (especially on mobile) by tightening spacing and resizing header elements, while aiming to preserve usable tap targets.

Changes:

  • Reduced header vertical padding and tightened header layout spacing (gap, nowrap behavior).
  • Reduced logo/icon sizing and normalized text vertical metrics (line-height, margins).
  • Reduced interactive control sizing (theme toggle button 40→36, primary header buttons use min-height 36 with smaller horizontal padding) and adjusted mobile header layout (single-row, hide time-info).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/styles/header.css Compacts header padding/layout, reduces logo sizing, adjusts typography metrics, and shrinks primary header button sizing.
frontend/styles/responsive.css Updates <=768px header layout to stay in a compact single-row configuration and hides .time-info on mobile.
frontend/styles/utilities.css Shrinks .theme-toggle-btn dimensions from 40×40 to 36×36.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 37 to +41
align-items: center;

flex-wrap: wrap;
flex-wrap: nowrap;

gap: 16px;
gap: 12px;

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing .header-content to flex-wrap: nowrap makes the header unable to wrap when content is wider than the viewport (logo + 2 action buttons + optional share indicator). Since body sets overflow-x: hidden (frontend/styles/base.css:33-46), this will clip header controls on narrow screens rather than allowing them to remain accessible. Consider allowing wrapping below a small breakpoint, or forcing the logo/text area to shrink/truncate (e.g., min-width: 0 + ellipsis) so the action buttons always fit.

Copilot uses AI. Check for mistakes.
Comment thread frontend/styles/responsive.css Outdated
gap: 10px;

align-items: flex-start;
flex-wrap: nowrap;

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mobile breakpoint, forcing .header-content to stay single-row and nowrap increases the likelihood that the header contents overflow on small devices (e.g., 320px width with "匯入成績" button, plus the readonly share indicator). With overflow-x: hidden on body, this will cut off controls instead of reflowing them. Consider adding an additional narrower breakpoint to either allow wrapping, hide button labels, or apply truncation/shrink rules so all controls remain reachable.

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/styles/responsive.css Outdated
Comment on lines +25 to +29
.header-content {

flex-direction: column;
flex-wrap: wrap;

align-items: flex-start;
gap: 8px;

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the 768px breakpoint the header is allowed to wrap (flex-wrap: wrap), which can still introduce multi-line headers and reduce above-the-fold density. This also conflicts with the PR description that aims to keep the header single-row; consider keeping flex-wrap: nowrap here and relying on min-width: 0 + ellipsis (and/or hiding secondary elements) to prevent height growth.

Copilot uses AI. Check for mistakes.
Comment thread frontend/styles/responsive.css Outdated

.header-actions {
width: auto;
width: 100%;

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting .header-actions { width: 100%; } at the 768px breakpoint forces the actions onto a new line inside .data-time-box, increasing header height on small screens. If the goal is a more compact header, keep actions inline (auto width) and instead reduce spacing/labels or hide less-important elements.

Suggested change
width: 100%;
width: auto;

Copilot uses AI. Check for mistakes.
Comment on lines +176 to +178
.time-info {
padding-right: 8px;
}

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions hiding secondary time-info on small screens, but the 480px rules still keep .time-info visible (only padding is adjusted). If the intent is to remove it to save space, hide the .time-info container (and remove its right border) rather than only tweaking padding.

Copilot uses AI. Check for mistakes.
}

.header-actions .import-dropdown-btn > span:last-child {
display: none;

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On <=480px the visible text label inside .import-dropdown-btn is removed with display: none, but the affected buttons (e.g. 分享 / 匯入成績) do not have aria-labels in the markup. This leaves icon-only controls without an accessible name for screen readers; add aria-label/title to the buttons or hide the label visually (not with display:none).

Suggested change
display: none;
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;

Copilot uses AI. Check for mistakes.
Comment thread frontend/styles/header.css Outdated
Comment on lines 187 to 189
flex-wrap: wrap;
}

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.header-actions is now allowed to wrap by default, which can increase header height at intermediate widths (even outside mobile breakpoints) and partially defeats the goal of a compact header. Consider keeping it nowrap by default and only enabling wrapping at the smallest breakpoint(s) where it’s strictly necessary.

Suggested change
flex-wrap: wrap;
}
flex-wrap: nowrap;
}
@media (max-width: 600px) {
.header-actions {
flex-wrap: wrap;
}
}

Copilot uses AI. Check for mistakes.
@alvin000009238
alvin000009238 merged commit 2c8d37f into dev Mar 31, 2026
1 check passed
@alvin000009238
alvin000009238 deleted the codex/reduce-header-height-for-better-ux branch March 31, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants