Skip to content

Commit

Permalink
add bootdev-based theme
Browse files Browse the repository at this point in the history
  • Loading branch information
ellielle committed May 31, 2024
1 parent cd4d211 commit 9d91985
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 9 deletions.
11 changes: 9 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ func (a *App) LoginUserWithToken() (bool, error) {

// UserData sends an authenticated request to gather the user's
// data for display in the app.
func (a *App) UserData() {
log.Print("UserData")
func (a *App) UserData() (bootdevapi.UserData, error) {
userData, err := bootdevapi.UserInfo(a.cache, a.tokens.AccessToken)
if err != nil {
return bootdevapi.UserData{}, nil
}

log.Print(userData)

return userData, nil
}
100 changes: 100 additions & 0 deletions bootdevtheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/** @type {import('@skeletonlabs/tw-plugin').CustomThemeConfig} */
export const bootDevTheme = {
name: "bootdev",
properties: {
// =~= Theme Properties =~=
"--theme-font-family-base": `system-ui`,
"--theme-font-family-heading": `system-ui`,
"--theme-font-color-base": "0 0 0",
"--theme-font-color-dark": "255 255 255",
"--theme-rounded-base": "9999px",
"--theme-rounded-container": "8px",
"--theme-border-base": "1px",
// =~= Theme On-X Colors =~=
"--on-primary": "0 0 0",
"--on-secondary": "255 255 255",
"--on-tertiary": "0 0 0",
"--on-success": "0 0 0",
"--on-warning": "0 0 0",
"--on-error": "255 255 255",
"--on-surface": "255 255 255",
// =~= Theme Colors =~=
// primary | #7E88F7
"--color-primary-50": "236 237 254", // #ecedfe
"--color-primary-100": "229 231 253", // #e5e7fd
"--color-primary-200": "223 225 253", // #dfe1fd
"--color-primary-300": "203 207 252", // #cbcffc
"--color-primary-400": "165 172 249", // #a5acf9
"--color-primary-500": "126 136 247", // #7E88F7
"--color-primary-600": "113 122 222", // #717ade
"--color-primary-700": "95 102 185", // #5f66b9
"--color-primary-800": "76 82 148", // #4c5294
"--color-primary-900": "62 67 121", // #3e4379
// secondary | #2b2c31
"--color-secondary-50": "223 223 224", // #dfdfe0
"--color-secondary-100": "213 213 214", // #d5d5d6
"--color-secondary-200": "202 202 204", // #cacacc
"--color-secondary-300": "170 171 173", // #aaabad
"--color-secondary-400": "107 107 111", // #6b6b6f
"--color-secondary-500": "43 44 49", // #2b2c31
"--color-secondary-600": "39 40 44", // #27282c
"--color-secondary-700": "32 33 37", // #202125
"--color-secondary-800": "26 26 29", // #1a1a1d
"--color-secondary-900": "21 22 24", // #151618
// tertiary | #2B2C31
"--color-tertiary-50": "223 223 224", // #dfdfe0
"--color-tertiary-100": "213 213 214", // #d5d5d6
"--color-tertiary-200": "202 202 204", // #cacacc
"--color-tertiary-300": "170 171 173", // #aaabad
"--color-tertiary-400": "107 107 111", // #6b6b6f
"--color-tertiary-500": "43 44 49", // #2B2C31
"--color-tertiary-600": "39 40 44", // #27282c
"--color-tertiary-700": "32 33 37", // #202125
"--color-tertiary-800": "26 26 29", // #1a1a1d
"--color-tertiary-900": "21 22 24", // #151618
// success | #39d50d
"--color-success-50": "225 249 219", // #e1f9db
"--color-success-100": "215 247 207", // #d7f7cf
"--color-success-200": "206 245 195", // #cef5c3
"--color-success-300": "176 238 158", // #b0ee9e
"--color-success-400": "116 226 86", // #74e256
"--color-success-500": "57 213 13", // #39d50d
"--color-success-600": "51 192 12", // #33c00c
"--color-success-700": "43 160 10", // #2ba00a
"--color-success-800": "34 128 8", // #228008
"--color-success-900": "28 104 6", // #1c6806
// warning | #fad35f
"--color-warning-50": "254 248 231", // #fef8e7
"--color-warning-100": "254 246 223", // #fef6df
"--color-warning-200": "254 244 215", // #fef4d7
"--color-warning-300": "253 237 191", // #fdedbf
"--color-warning-400": "252 224 143", // #fce08f
"--color-warning-500": "250 211 95", // #fad35f
"--color-warning-600": "225 190 86", // #e1be56
"--color-warning-700": "188 158 71", // #bc9e47
"--color-warning-800": "150 127 57", // #967f39
"--color-warning-900": "123 103 47", // #7b672f
// error | #e4184b
"--color-error-50": "251 220 228", // #fbdce4
"--color-error-100": "250 209 219", // #fad1db
"--color-error-200": "248 197 210", // #f8c5d2
"--color-error-300": "244 163 183", // #f4a3b7
"--color-error-400": "236 93 129", // #ec5d81
"--color-error-500": "228 24 75", // #e4184b
"--color-error-600": "205 22 68", // #cd1644
"--color-error-700": "171 18 56", // #ab1238
"--color-error-800": "137 14 45", // #890e2d
"--color-error-900": "112 12 37", // #700c25
// surface | #1f1f23
"--color-surface-50": "221 221 222", // #ddddde
"--color-surface-100": "210 210 211", // #d2d2d3
"--color-surface-200": "199 199 200", // #c7c7c8
"--color-surface-300": "165 165 167", // #a5a5a7
"--color-surface-400": "98 98 101", // #626265
"--color-surface-500": "31 31 35", // #1f1f23
"--color-surface-600": "28 28 32", // #1c1c20
"--color-surface-700": "23 23 26", // #17171a
"--color-surface-800": "19 19 21", // #131315
"--color-surface-900": "15 15 17", // #0f0f11
},
};
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Boot.dev Buddy</title>
</head>

<body style="--wails-draggable:drag" data-theme="gold-nouveau">
<body style="--wails-draggable:drag" data-theme="bootdev">
<div id="app"></div>
<script src="./src/main.js" type="module"></script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/User.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<script></script>
<script>
</script>
6 changes: 4 additions & 2 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// @ts-check
import { join } from "path";

// 1. Import the Skeleton plugin
import { skeleton } from "@skeletonlabs/tw-plugin";
import { bootDevTheme } from "../bootdevtheme.js";

/** @type {import('tailwindcss').Config} */
export default {
Expand All @@ -23,7 +23,9 @@ export default {
plugins: [
// 4. Append the Skeleton plugin (after other plugins)
skeleton({
themes: { preset: ["gold-nouveau"] },
themes: {
custom: [bootDevTheme],
},
}),
],
};
4 changes: 4 additions & 0 deletions internal/bootdevapi/api_remap_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type ActivityFeedUser struct {
CourseName string `json:"CourseName"`
}

// LeaderboardUser is a struct to hold users from
// the leaderboard_stats endpoint
// string pointers are used for nullable fields
type LeaderboardUser struct {
DiscordUserHandle *string `json:"DiscordUserHandle"`
Expand Down Expand Up @@ -53,6 +55,7 @@ type LeaderboardUser struct {
XPEarned int `json:"XPEarned"`
}

// Archmage holds users from the leaderboard_archmage endpoint
type Archmage struct {
LeaderboardUser
ArchmageUnlockedAt time.Time `json:"ArchmageUnlockedAt"`
Expand All @@ -65,6 +68,7 @@ type Archon struct {
Karma int `json:"Karma"`
}

// UserData holds data about the user from the users endpoint
type UserData struct {
DiscordUserHandle string `json:"DiscordUserHandle"`
SyncedGoogleID any `json:"SyncedGoogleID"`
Expand Down
13 changes: 10 additions & 3 deletions internal/bootdevapi/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ package bootdevapi
import (
"encoding/json"
"errors"
"log"
"net/http"

"github.com/ellielle/bootdev-buddy/internal/cache"
)

func UserInfo(c cache.Cache) (UserData, error) {
func UserInfo(c cache.Cache, token string) (UserData, error) {
// User information URL
userURL, err := BootDevAPIMap("user")
if err != nil {
return UserData{}, errors.New("error getting user url")
}

log.Println("user url: ", userURL)

var user = UserData{}

// Check cache for a hit before requesting
Expand All @@ -28,12 +31,16 @@ func UserInfo(c cache.Cache) (UserData, error) {
return user, nil
}

log.Print("cache hit? :", cacheHit)

// Create a new request
req, err := http.NewRequest("POST", userURL, nil)
req, err := http.NewRequest("GET", userURL, nil)
if err != nil {
return UserData{}, errors.New("error creating user request")
return UserData{}, err
}

req.Header.Set("Authorization", "Bearer "+token)

resp, err := http.DefaultClient.Do(req)
if err != nil {
return UserData{}, err
Expand Down

0 comments on commit 9d91985

Please sign in to comment.