mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-03 10:28:46 +00:00
Add dark mode
This commit is contained in:
parent
8607f16212
commit
3c6653a77b
15 changed files with 124 additions and 23 deletions
|
@ -10,6 +10,7 @@ type HeaderData struct {
|
|||
NotificationCount int
|
||||
CustomCSS string
|
||||
FluorideMode bool
|
||||
DarkMode bool
|
||||
}
|
||||
|
||||
type NavbarData struct {
|
||||
|
@ -58,6 +59,7 @@ type NotificationData struct {
|
|||
Notifications []*mastodon.Notification
|
||||
HasNext bool
|
||||
NextLink string
|
||||
DarkMode bool
|
||||
}
|
||||
|
||||
type UserData struct {
|
||||
|
@ -66,6 +68,7 @@ type UserData struct {
|
|||
Statuses []*mastodon.Status
|
||||
HasNext bool
|
||||
NextLink string
|
||||
DarkMode bool
|
||||
}
|
||||
|
||||
type AboutData struct {
|
||||
|
|
|
@ -11,6 +11,39 @@ import (
|
|||
"mastodon"
|
||||
)
|
||||
|
||||
var (
|
||||
icons = map[string]string{
|
||||
"envelope": "/static/icons/envelope.png",
|
||||
"dark-envelope": "/static/icons/dark-envelope.png",
|
||||
"globe": "/static/icons/globe.png",
|
||||
"dark-globe": "/static/icons/dark-globe.png",
|
||||
"liked": "/static/icons/liked.png",
|
||||
"dark-liked": "/static/icons/liked.png",
|
||||
"link": "/static/icons/link.png",
|
||||
"dark-link": "/static/icons/dark-link.png",
|
||||
"lock": "/static/icons/lock.png",
|
||||
"dark-lock": "/static/icons/dark-lock.png",
|
||||
"mail-forward": "/static/icons/mail-forward.png",
|
||||
"dark-mail-forward": "/static/icons/dark-mail-forward.png",
|
||||
"reply": "/static/icons/reply.png",
|
||||
"dark-reply": "/static/icons/dark-reply.png",
|
||||
"retweet": "/static/icons/retweet.png",
|
||||
"dark-retweet": "/static/icons/dark-retweet.png",
|
||||
"retweeted": "/static/icons/retweeted.png",
|
||||
"dark-retweeted": "/static/icons/retweeted.png",
|
||||
"smile-o": "/static/icons/smile-o.png",
|
||||
"dark-smile-o": "/static/icons/dark-smile-o.png",
|
||||
"star-o": "/static/icons/star-o.png",
|
||||
"dark-star-o": "/static/icons/dark-star-o.png",
|
||||
"star": "/static/icons/star.png",
|
||||
"dark-star": "/static/icons/dark-star.png",
|
||||
"unlock-alt": "/static/icons/unlock-alt.png",
|
||||
"dark-unlock-alt": "/static/icons/dark-unlock-alt.png",
|
||||
"user-plus": "/static/icons/user-plus.png",
|
||||
"dark-user-plus": "/static/icons/dark-user-plus.png",
|
||||
}
|
||||
)
|
||||
|
||||
type Renderer interface {
|
||||
RenderErrorPage(ctx context.Context, writer io.Writer, data *ErrorData)
|
||||
RenderHomePage(ctx context.Context, writer io.Writer, data *HomePageData) (err error)
|
||||
|
@ -42,6 +75,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
|
|||
"TimeSince": TimeSince,
|
||||
"FormatTimeRFC3339": FormatTimeRFC3339,
|
||||
"FormatTimeRFC822": FormatTimeRFC822,
|
||||
"GetIcon": GetIcon,
|
||||
}).ParseGlob(templateGlobPattern)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -180,3 +214,11 @@ func FormatTimeRFC3339(t time.Time) string {
|
|||
func FormatTimeRFC822(t time.Time) string {
|
||||
return t.Format(time.RFC822)
|
||||
}
|
||||
|
||||
func GetIcon(name string, darkMode bool) (icon string) {
|
||||
if darkMode {
|
||||
name = "dark-" + name
|
||||
}
|
||||
icon, _ = icons[name]
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue