From 57e496dbda0dd770edd20a3b798047e06c496488 Mon Sep 17 00:00:00 2001 From: Nekyll <88288807+Nekyl@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:26:32 +0000 Subject: [PATCH] fix(ui): make user cards full width on mobile (#40408) Use "display: grid" for "user-cards" list to make sure the card width is correct for all widths. Also clean up and simplify tailwind font size helper classes. --------- Co-authored-by: wxiaoguang --- tailwind.config.ts | 18 +++++------------ templates/org/header.tmpl | 2 +- templates/repo/user_cards.tmpl | 37 +++++++++++++++++----------------- web_src/css/repo.css | 33 +++++++++--------------------- 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/tailwind.config.ts b/tailwind.config.ts index b7e5ae0a109..c63531eda26 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -73,21 +73,13 @@ export default { semibold: 'var(--font-weight-semibold)', bold: 'var(--font-weight-bold)', }, - fontSize: { // rarely used, but "text-base" (matching body's 1em=14px) is useful to reset font-size in a header container + fontSize: { 'xs': '11px', 'sm': '12px', - 'base': '14px', - 'lg': '18px', - 'xl': '20px', - '2xl': '24px', - '3xl': '30px', - '4xl': '36px', - '5xl': '48px', - '6xl': '60px', - '7xl': '72px', - '8xl': '96px', - '9xl': '128px', - ...Object.fromEntries(Array.from({length: 100}, (_, i) => { + 'base': '14px', // match body's 1em=14px + 'lg': '16px', + 'xl': '18px', + ...Object.fromEntries(Array.from({length: 48}, (_, i) => { return [String(i), i === 0 ? '0' : `${i}px`]; })), }, diff --git a/templates/org/header.tmpl b/templates/org/header.tmpl index 58300edc5b6..3b20d3b787d 100644 --- a/templates/org/header.tmpl +++ b/templates/org/header.tmpl @@ -3,7 +3,7 @@
- {{.Org.DisplayName}} + {{.Org.DisplayName}} {{if .Org.Visibility.IsLimited}}{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}{{end}} {{if .Org.Visibility.IsPrivate}}{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}{{end}}
diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl index 8e6bd74ee21..05ca6a0648e 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -1,26 +1,25 @@ {{/* need to reload after "watch/unwatch" or "star/unstar" fetch actions */}}
{{if .CardsTitle}} -

- {{.CardsTitle}} -

+

{{.CardsTitle}}

{{end}} -
    - {{range .Cards}} -
  • - - {{ctx.AvatarUtils.Avatar . 48}} - -

    {{.DisplayName}}{{template "shared/user/user_type_label" .}}

    - -
    - {{if .Website}} - {{svg "octicon-link"}} {{.Website}} - {{else if .Location}} - {{svg "octicon-location"}} {{.Location}} - {{else}} - {{svg "octicon-calendar"}} {{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .CreatedUnix)}} - {{end}} +
      + {{range $card := .Cards}} +
    • + {{ctx.AvatarUtils.Avatar $card 48}} +
      +
      + {{template "shared/user/name" $card}} +
      +
      + {{if $card.Website}} + {{svg "octicon-link"}} {{$card.Website}} + {{else if $card.Location}} + {{svg "octicon-location"}} {{$card.Location}} + {{else}} + {{svg "octicon-calendar"}} {{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort $card.CreatedUnix)}} + {{end}} +
    • {{end}} diff --git a/web_src/css/repo.css b/web_src/css/repo.css index c7b2b04de53..549dc271dca 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -983,34 +983,19 @@ padding: 0 10px; } -.user-cards .list { +.user-cards > ul { + margin: 0; padding: 0; - display: flex; - flex-wrap: wrap; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); + gap: var(--gap-block); } -.user-cards .list .item { +.user-cards > ul > li.ui.segment { + margin: 0; list-style: none; - width: 32%; - margin: 10px 10px 10px 0; - padding-bottom: 14px; - float: left; -} - -.user-cards .list .item .avatar { - float: left; - display: block; - margin-right: 10px; -} - -.user-cards .list .item .name { - margin-top: 0; - margin-bottom: 0; - font-weight: var(--font-weight-normal); -} - -.user-cards .list .item .meta { - margin-top: 5px; + display: flex; + gap: var(--gap-block); } #search-user-box .results .result .image {