User Themes refactor

Instead of fighting to override Bulma CSS classes, add user-theme-*
classes for simpler styling.
This commit is contained in:
Noah Petherbridge 2024-10-13 20:31:09 -07:00
parent b7bee75e1f
commit 704124157d
3 changed files with 79 additions and 91 deletions

View File

@ -41,6 +41,7 @@ func Profile() http.HandlerFunc {
vars := map[string]interface{}{ vars := map[string]interface{}{
"User": user, "User": user,
"IsExternalView": true,
} }
if err := tmpl.Execute(w, r, vars); err != nil { if err := tmpl.Execute(w, r, vars); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -2,7 +2,7 @@
{{define "content"}} {{define "content"}}
{{template "profile-theme-style" .User}} {{template "profile-theme-style" .User}}
<div class="container"> <div class="container">
<section class="hero {{if and .LoggedIn (not .IsPrivate)}}is-info{{else}}is-light is-bold{{end}}"> <section class="hero {{if and .LoggedIn (not .IsPrivate)}}is-info{{else}}is-light is-bold{{end}} {{if not .IsExternalView}}user-theme-hero{{end}}">
<div class="hero-body"> <div class="hero-body">
<div class="container"> <div class="container">
<div class="columns"> <div class="columns">
@ -313,7 +313,7 @@
<div class="column is-two-thirds"> <div class="column is-two-thirds">
<div class="card block"> <div class="card block">
<header class="card-header has-background-link"> <header class="card-header has-background-link user-theme-card-title">
<div class="card-header-title"> <div class="card-header-title">
<div class="columns is-mobile is-gapless nonshy-fullwidth"> <div class="columns is-mobile is-gapless nonshy-fullwidth">
<div class="column"> <div class="column">
@ -330,7 +330,7 @@
</div> </div>
</header> </header>
<div class="card-content"> <div class="card-content user-theme-card-body">
<div class="content"> <div class="content">
{{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "about_me"))) "n/a"}} {{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "about_me"))) "n/a"}}
</div> </div>
@ -338,7 +338,7 @@
</div> </div>
<div class="card block"> <div class="card block">
<header class="card-header has-background-link"> <header class="card-header has-background-link user-theme-card-title">
<div class="card-header-title"> <div class="card-header-title">
<div class="columns is-mobile is-gapless nonshy-fullwidth"> <div class="columns is-mobile is-gapless nonshy-fullwidth">
<div class="column"> <div class="column">
@ -355,7 +355,7 @@
</div> </div>
</header> </header>
<div class="card-content"> <div class="card-content user-theme-card-body">
<div class="content"> <div class="content">
{{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "interests"))) "n/a"}} {{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "interests"))) "n/a"}}
</div> </div>
@ -363,7 +363,7 @@
</div> </div>
<div class="card block"> <div class="card block">
<header class="card-header has-background-link"> <header class="card-header has-background-link user-theme-card-title">
<div class="card-header-title"> <div class="card-header-title">
<div class="columns is-mobile is-gapless nonshy-fullwidth"> <div class="columns is-mobile is-gapless nonshy-fullwidth">
<div class="column"> <div class="column">
@ -380,7 +380,7 @@
</div> </div>
</header> </header>
<div class="card-content"> <div class="card-content user-theme-card-body">
<div class="content"> <div class="content">
{{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "music_movies"))) "n/a"}} {{or (ReSignPhotoLinks (ToMarkdown (.User.GetProfileField "music_movies"))) "n/a"}}
</div> </div>
@ -390,14 +390,14 @@
<div class="column"> <div class="column">
<div class="card block"> <div class="card block">
<header class="card-header has-background-info"> <header class="card-header has-background-info user-theme-card-title">
<p class="card-header-title has-text-light"> <p class="card-header-title has-text-light">
<i class="fa fa-user pr-2"></i> <i class="fa fa-user pr-2"></i>
About {{.User.Username}} About {{.User.Username}}
</p> </p>
</header> </header>
<div class="card-content"> <div class="card-content user-theme-card-body">
<table class="table is-fullwidth" style="font-size: small"> <table class="table is-fullwidth" style="font-size: small">
<tr> <tr>
<td class="has-text-right"> <td class="has-text-right">
@ -476,14 +476,14 @@
</div> </div>
<div class="card block"> <div class="card block">
<header class="card-header has-background-info"> <header class="card-header has-background-info user-theme-card-title">
<p class="card-header-title has-text-light"> <p class="card-header-title has-text-light">
<i class="fa fa-chart-line pr-2"></i> <i class="fa fa-chart-line pr-2"></i>
Activity Activity
</p> </p>
</header> </header>
<div class="card-content"> <div class="card-content user-theme-card-body">
<!-- Lazy load the statistics card--> <!-- Lazy load the statistics card-->
<div hx-get="/htmx/user/profile/activity?username={{.User.Username}}" hx-trigger="load"> <div hx-get="/htmx/user/profile/activity?username={{.User.Username}}" hx-trigger="load">

View File

@ -24,97 +24,84 @@ section.hero {
{{$cardTitleFG := or (.GetProfileField "card-title-fg") "#f7f7f7"}} {{$cardTitleFG := or (.GetProfileField "card-title-fg") "#f7f7f7"}}
{{$cardLinkFG := or (.GetProfileField "card-link-color") "#0099ff"}} {{$cardLinkFG := or (.GetProfileField "card-link-color") "#0099ff"}}
{{$cardLightness := .GetProfileField "card-lightness"}} {{$cardLightness := .GetProfileField "card-lightness"}}
{{$heroA := or (.GetProfileField "hero-color-start") "#0f81cc"}}
{{$heroB := or (.GetProfileField "hero-color-end") "#7683cc"}}
<style type="text/css"> <style type="text/css">
{{template "profile-theme-hero-style" .}} /* Hero banner */
header.card-header { .user-theme-hero {
background-color: {{$cardTitleBG}} !important; background-image: linear-gradient(141deg, {{$heroA}}, {{$heroB}}) !important;
.title, .subtitle {
color: {{if eq (.GetProfileField "hero-text-dark") "true"}}#4a4a4a{{else}}#f5f5f5{{end}} !important;
} }
p.card-header-title { }
/* Card Title colors */
.user-theme-card-title {
background-color: {{$cardTitleBG}} !important;
* {
color: {{$cardTitleFG}} !important; color: {{$cardTitleFG}} !important;
} }
.button.is-outlined {
border-color: {{$cardTitleFG}} !important;
}
}
/* Card Body colors */
.user-theme-card-body {
a {
color: {{$cardLinkFG}} !important;
}
}
/* Forced light theme overrides */
{{if eq $cardLightness "light"}} {{if eq $cardLightness "light"}}
div.box, .container div.card-content, table.table, table.table strong, td { .user-theme-card-body {
background-color: #fff !important; background-color: #fff !important;
color: #4a4a4a !important; color: #4a4a4a !important;
}
aside.menu ul.menu-list li a { * {
background-color: #ccc !important;
color: #4a4a4a !important; color: #4a4a4a !important;
} }
blockquote, pre, code {
a > * {
color: {{$cardLinkFG}} !important;
}
blockquote, pre, code, .tag {
background-color: #ccc !important; background-color: #ccc !important;
color: #4a4a4a; color: #4a4a4a m !important;
}
div.tag {
background-color: #ccc;
color: #4a4a4a;
}
strong {
color: #4a4a4a;
} }
/* More text color overrides (h1's etc. look light on prefers-dark color schemes) */ .table {
.container div.card-content .content * { background-color: inherit;
color: #4a4a4a;
}
/* Slightly less light on dark theme devices */
@media (prefers-color-scheme: dark) {
div.box, .container div.card-content, table.table, table.table strong {
background-color: #e4e4e4;
color: #4a4a4a;
} }
} }
{{else if eq $cardLightness "dark"}} {{else if eq $cardLightness "dark"}}
div.box, .container div.card-content, table.table, table.table strong, td { .user-theme-card-body {
background-color: #4a4a4a !important; background-color: #4a4a4a !important;
color: #f5f5f5 !important; color: #f5f5f5 !important;
}
aside.menu ul.menu-list li a { * {
background-color: #1a1a1a !important;
color: #f5f5f5 !important; color: #f5f5f5 !important;
} }
blockquote, pre, code {
a > * {
color: {{$cardLinkFG}} !important;
}
blockquote, pre, code, .tag {
background-color: #1a1a1a !important; background-color: #1a1a1a !important;
color: #f5f5f5; color: #f5f5f5 m !important;
}
div.tag {
background-color: #333;
color: #f5f5f5;
}
strong {
color: #f5f5f5;
} }
/* More text color overrides (h1's etc. look dark on prefers-light color schemes) */ .table {
.container div.card-content .content * { background-color: inherit;
color: #f5f5f5;
}
/* Even darker on dark theme devices */
@media (prefers-color-scheme: dark) {
div.box, .container div.card-content, table.table, table.table strong {
background-color: #0a0a0a;
color: #b5b5b5;
} }
} }
{{end}} {{end}}
.container div.card-content a {
color: {{$cardLinkFG}} !important;
}
.card-content .menu-list li a {
color: inherit !important;
}
.container div.card-content a:hover {
color: inherit;
}
/* Override link color for the Activity box, so users don't set black-on-black and wreck the links */
.card-content table a.has-text-info {
color: #3e8ed0 !important;
}
</style> </style>
{{end}} {{end}}