From fc8d61e1ef551fbd6171b4764f8bc61c9bf647a7 Mon Sep 17 00:00:00 2001 From: Astra Date: Thu, 15 May 2025 16:20:16 +0900 Subject: [PATCH] Theming 101 --- src/themes/colors.css | 11 -- src/themes/theme.css | 357 ----------------------------------- themes/colors.css | 22 +++ themes/default/theme.css | 0 themes/witchcraft/theme.css | 358 ++++++++++++++++++++++++++++++++++++ theming.ts | 10 +- 6 files changed, 385 insertions(+), 373 deletions(-) delete mode 100644 src/themes/colors.css delete mode 100644 src/themes/theme.css create mode 100644 themes/colors.css create mode 100644 themes/default/theme.css create mode 100644 themes/witchcraft/theme.css diff --git a/src/themes/colors.css b/src/themes/colors.css deleted file mode 100644 index bc036e4..0000000 --- a/src/themes/colors.css +++ /dev/null @@ -1,11 +0,0 @@ -:root { - --link-color: #646cff; - --link-hover-color: #535bf2; - --background-color: #12082b; - --header-background-color: #1f1145; - --content-background-color: #0d0620; - --text-color: white; - --border-color: #8054f0; - --indicator-inactive-color: #4a4a4a; - --indicator-active-color: #8054f0; -} \ No newline at end of file diff --git a/src/themes/theme.css b/src/themes/theme.css deleted file mode 100644 index 4ae67be..0000000 --- a/src/themes/theme.css +++ /dev/null @@ -1,357 +0,0 @@ -@font-face { - font-family: "ProggyClean"; - src: url(https://witchcraft.systems/ProggyCleanNerdFont-Regular.ttf); -} - -::-webkit-scrollbar { - width: 0px; - background: transparent; - padding: 0; - margin: 0; -} -::-webkit-scrollbar-thumb { - background: transparent; - border-radius: 0; -} -::-webkit-scrollbar-track { - background: transparent; - border-radius: 0; -} -::-webkit-scrollbar-corner { - background: transparent; - border-radius: 0; -} -::-webkit-scrollbar-button { - background: transparent; - border-radius: 0; -} -* { - scrollbar-width: none; - scrollbar-color: transparent transparent; - -ms-overflow-style: none; /* IE and Edge */ - -webkit-overflow-scrolling: touch; - -webkit-scrollbar: none; /* Safari */ -} - -a { - font-weight: 500; - color: var(--link-color); - text-decoration: inherit; -} -a:hover { - color: var(--link-hover-color); - text-decoration: underline; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; - background-color: var(--background-color); - font-family: "ProggyClean", monospace; - font-size: 24px; - color: var(--text-color); - border-color: var(--border-color); - overflow-wrap: break-word; - word-wrap: normal; - word-break: break-word; - hyphens: none; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -#app { - max-width: 1400px; - width: 100%; - margin: 0; - padding: 0; - margin-left: auto; - margin-right: auto; - text-align: center; -} - -/* Post Component */ - a:hover { - text-decoration: underline; - } - #postContainer { - display: flex; - flex-direction: column; - border: 1px solid var(--border-color); - background-color: var(--background-color); - margin-bottom: 15px; - overflow-wrap: break-word; - } - #postHeader { - display: flex; - flex-direction: row; - align-items: center; - justify-content: start; - background-color: var(--header-background-color); - padding: 0px 0px; - height: fit-content; - border-bottom: 1px solid var(--border-color); - font-weight: bold; - overflow-wrap: break-word; - height: 60px; - } - #displayName { - display: block; - color: var(--text-color); - font-size: 1.2em; - padding: 0; - margin: 0; - overflow-wrap:normal; - word-wrap: break-word; - word-break: break-word; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - width: 100%; - } - #handle { - display: block; - color: var(--border-color); - font-size: 0.8em; - padding: 0; - margin: 0; - } - - #postLink { - color: var(--border-color); - font-size: 0.8em; - padding: 0; - margin: 0; - } - #postContent { - display: flex; - text-align: start; - flex-direction: column; - padding: 10px; - background-color: var(--content-background-color); - color: var(--text-color); - overflow-wrap: break-word; - white-space: pre-line; - } - #replyingText { - font-size: 0.7em; - margin: 0; - padding: 0; - padding-bottom: 5px; - } - #quotingText { - font-size: 0.7em; - margin: 0; - padding: 0; - padding-bottom: 5px; - } - #postText { - margin: 0; - padding: 0; - overflow-wrap: break-word; - word-wrap: normal; - word-break: break-word; - hyphens: none; - } - #headerText { - margin-left: 10px; - font-size: 0.9em; - text-align: start; - word-break: break-word; - max-width: 80%; - max-height: 95%; - overflow: hidden; - align-self: flex-start; - margin-top: auto; - margin-bottom: auto; - } - #avatar { - height: 60px; - width: 60px; - margin: 0px; - margin-left: 0px; - overflow: hidden; - object-fit: cover; - border-right: var(--border-color) 1px solid; - } - #carouselContainer { - position: relative; - width: 100%; - margin-top: 10px; - display: flex; - flex-direction: column; - align-items: center; - } - #carouselControls { - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - max-width: 500px; - margin-top: 5px; - } - #carouselIndicators { - display: flex; - gap: 5px; - } - .indicator { - width: 8px; - height: 8px; - background-color: var(--indicator-inactive-color); - } - .indicator.active { - background-color: var(--indicator-active-color); - } - #prevBtn, - #nextBtn { - background-color: rgba(31, 17, 69, 0.7); - color: var(--text-color); - border: 1px solid var(--border-color); - width: 30px; - height: 30px; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - } - #prevBtn:disabled, - #nextBtn:disabled { - opacity: 0.5; - cursor: not-allowed; - } - #embedVideo { - width: 100%; - max-width: 500px; - margin-top: 10px; - align-self: center; - } - - #embedImages { - min-width: min(100%, 500px); - max-width: min(100%, 500px); - max-height: 500px; - object-fit: contain; - - margin: 0; - } - -/* Account Component */ - #accountContainer { - display: flex; - text-align: start; - align-items: center; - background-color: var(--background-color); - padding: 0px; - margin-bottom: 15px; - border: 1px solid var(--border-color); - } - #accountName { - margin-left: 10px; - font-size: 0.9em; - max-width: 80%; - - /* replace overflow with ellipsis */ - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - #avatar { - width: 50px; - height: 50px; - margin: 0px; - object-fit: cover; - border-right: var(--border-color) 1px solid; - } - -/* App.Svelte */ - /* desktop style */ - - #Content { - display: flex; - /* split the screen in half, left for accounts, right for posts */ - width: 100%; - height: 100%; - flex-direction: row; - justify-content: space-between; - align-items: center; - background-color: var(--background-color); - color: var(--text-color); - } - #Feed { - overflow-y: scroll; - width: 65%; - height: 100vh; - padding: 20px; - padding-bottom: 0; - padding-top: 0; - margin-top: 0; - margin-bottom: 0; - } - #spacer { - padding: 0; - margin: 0; - height: 10vh; - width: 100%; - } - #Account { - width: 35%; - display: flex; - flex-direction: column; - border: 1px solid var(--border-color); - background-color: var(--content-background-color); - height: 80vh; - padding: 20px; - margin-left: 20px; - } - #accountsList { - display: flex; - flex-direction: column; - overflow-y: scroll; - height: 100%; - width: 100%; - padding: 0px; - margin: 0px; - } - - #Header { - text-align: center; - font-size: 2em; - margin-bottom: 20px; - } - - /* mobile style */ - @media screen and (max-width: 600px) { - #Content { - flex-direction: column; - width: auto; - padding-left: 0px; - padding-right: 0px; - margin-top: 5%; - } - #Account { - width: 85%; - padding-left: 5%; - padding-right: 5%; - margin-bottom: 20px; - margin-left: 5%; - margin-right: 5%; - height: auto; - } - #Feed { - width: 95%; - margin: 0px; - margin-left: 10%; - margin-right: 10%; - padding: 0px; - overflow-y: visible; - } - - #spacer { - height: 0; - } - } \ No newline at end of file diff --git a/themes/colors.css b/themes/colors.css new file mode 100644 index 0000000..b522a4f --- /dev/null +++ b/themes/colors.css @@ -0,0 +1,22 @@ +:root { + /* Primary hue of the theme */ + /* You can adjust it, or edit the values below directly */ + --primary-h: 260; + + /* Primary saturation and lightness of the theme, usually you shouldn't want to change those */ + --primary-s: 75%; + --primary-l: 60%; + + /* Derived colors using H, S, L manipulation */ + /* You can set those to be static values if you want, i.e.: */ + /* --link-color: #c579ff; */ + --link-color: hsl(calc(var(--primary-h) - 30), 75%, 60%); + --link-hover-color: hsl(calc(var(--primary-h) - 30), 75%, 50%); + --background-color: hsl(var(--primary-h), 75%, 10%); + --header-background-color: hsl(var(--primary-h), 75%, 18%); + --content-background-color: hsl(var(--primary-h), 75%, 8%); + --text-color: #fff; + --border-color: hsl(var(--primary-h), 75%, calc(var(--primary-l) * 1.05)); + --indicator-inactive-color: #4a4a4a; + --indicator-active-color: var(--border-color); +} diff --git a/themes/default/theme.css b/themes/default/theme.css new file mode 100644 index 0000000..e69de29 diff --git a/themes/witchcraft/theme.css b/themes/witchcraft/theme.css new file mode 100644 index 0000000..eee1f37 --- /dev/null +++ b/themes/witchcraft/theme.css @@ -0,0 +1,358 @@ +@font-face { + font-family: "ProggyClean"; + src: url(https://witchcraft.systems/ProggyCleanNerdFont-Regular.ttf); +} + +a { + font-weight: 500; + color: var(--link-color); + text-decoration: inherit; +} +a:hover { + color: var(--link-hover-color); + text-decoration: underline; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; + background-color: var(--background-color); + font-family: "ProggyClean", monospace; + font-size: 24px; + color: var(--text-color); + border-color: var(--border-color); + overflow-wrap: break-word; + word-wrap: normal; + word-break: break-word; + hyphens: none; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +#app { + max-width: 1400px; + width: 100%; + margin: 0; + padding: 0; + margin-left: auto; + margin-right: auto; + text-align: center; +} + +/* Post Component */ +a:hover { + text-decoration: underline; +} +#postContainer { + display: flex; + flex-direction: column; + border: 1px solid var(--border-color); + background-color: var(--background-color); + margin-bottom: 15px; + overflow-wrap: break-word; +} +#postHeader { + display: flex; + flex-direction: row; + align-items: center; + justify-content: start; + background-color: var(--header-background-color); + padding: 0px 0px; + height: fit-content; + border-bottom: 1px solid var(--border-color); + font-weight: bold; + overflow-wrap: break-word; + height: 60px; +} +#displayName { + display: block; + color: var(--text-color); + font-size: 1.2em; + padding: 0; + margin: 0; + overflow-wrap: normal; + word-wrap: break-word; + word-break: break-word; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + width: 100%; +} +#handle { + display: block; + color: var(--border-color); + font-size: 0.8em; + padding: 0; + margin: 0; +} + +#postLink { + color: var(--border-color); + font-size: 0.8em; + padding: 0; + margin: 0; +} +#postContent { + display: flex; + text-align: start; + flex-direction: column; + padding: 10px; + background-color: var(--content-background-color); + color: var(--text-color); + overflow-wrap: break-word; + white-space: pre-line; +} +#replyingText { + font-size: 0.7em; + margin: 0; + padding: 0; + padding-bottom: 5px; +} +#quotingText { + font-size: 0.7em; + margin: 0; + padding: 0; + padding-bottom: 5px; +} +#postText { + margin: 0; + padding: 0; + overflow-wrap: break-word; + word-wrap: normal; + word-break: break-word; + hyphens: none; +} +#headerText { + margin-left: 10px; + font-size: 0.9em; + text-align: start; + word-break: break-word; + max-width: 80%; + max-height: 95%; + overflow: hidden; + align-self: flex-start; + margin-top: auto; + margin-bottom: auto; +} +#avatar { + height: 60px; + width: 60px; + margin: 0px; + margin-left: 0px; + overflow: hidden; + object-fit: cover; + border-right: var(--border-color) 1px solid; +} +#carouselContainer { + position: relative; + width: 100%; + margin-top: 10px; + display: flex; + flex-direction: column; + align-items: center; +} +#carouselControls { + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; + max-width: 500px; + margin-top: 5px; +} +#carouselIndicators { + display: flex; + gap: 5px; +} +.indicator { + width: 8px; + height: 8px; + background-color: var(--indicator-inactive-color); +} +.indicator.active { + background-color: var(--indicator-active-color); +} +#prevBtn, +#nextBtn { + background-color: rgba(31, 17, 69, 0.7); + color: var(--text-color); + border: 1px solid var(--border-color); + width: 30px; + height: 30px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; +} +#prevBtn:disabled, +#nextBtn:disabled { + opacity: 0.5; + cursor: not-allowed; +} +#embedVideo { + width: 100%; + max-width: 500px; + margin-top: 10px; + align-self: center; +} + +#embedImages { + min-width: min(100%, 500px); + max-width: min(100%, 500px); + max-height: 500px; + object-fit: contain; + + margin: 0; +} + +/* Account Component */ +#accountContainer { + display: flex; + text-align: start; + align-items: center; + background-color: var(--background-color); + padding: 0px; + margin-bottom: 15px; + border: 1px solid var(--border-color); +} +#accountName { + margin-left: 10px; + font-size: 0.9em; + max-width: 80%; + + /* replace overflow with ellipsis */ + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +#avatar { + width: 50px; + height: 50px; + margin: 0px; + object-fit: cover; + border-right: var(--border-color) 1px solid; +} + +/* App.Svelte */ +/* desktop style */ + +#Content { + display: flex; + /* split the screen in half, left for accounts, right for posts */ + width: 100%; + height: 100%; + flex-direction: row; + justify-content: space-between; + align-items: center; + background-color: var(--background-color); + color: var(--text-color); +} +#Feed { + overflow-y: scroll; + width: 65%; + height: 100vh; + padding: 20px; + padding-bottom: 0; + padding-top: 0; + margin-top: 0; + margin-bottom: 0; +} +#spacer { + padding: 0; + margin: 0; + height: 10vh; + width: 100%; +} +#Account { + width: 35%; + display: flex; + flex-direction: column; + border: 1px solid var(--border-color); + background-color: var(--content-background-color); + height: 80vh; + padding: 20px; + margin-left: 20px; +} +#accountsList { + display: flex; + flex-direction: column; + overflow-y: scroll; + height: 100%; + width: 100%; + padding: 0px; + margin: 0px; +} + +#Header { + text-align: center; + font-size: 2em; + margin-bottom: 20px; +} + +/* mobile style */ +@media screen and (max-width: 600px) { + #Content { + flex-direction: column; + width: auto; + padding-left: 0px; + padding-right: 0px; + margin-top: 5%; + } + #Account { + width: 85%; + padding-left: 5%; + padding-right: 5%; + margin-bottom: 20px; + margin-left: 5%; + margin-right: 5%; + height: auto; + } + #Feed { + width: 95%; + margin: 0px; + margin-left: 10%; + margin-right: 10%; + padding: 0px; + overflow-y: visible; + } + + #spacer { + height: 0; + } +} + +::-webkit-scrollbar { + width: 0px; + background: transparent; + padding: 0; + margin: 0; +} +::-webkit-scrollbar-thumb { + background: transparent; + border-radius: 0; +} +::-webkit-scrollbar-track { + background: transparent; + border-radius: 0; +} +::-webkit-scrollbar-corner { + background: transparent; + border-radius: 0; +} +::-webkit-scrollbar-button { + background: transparent; + border-radius: 0; +} + +* { + scrollbar-width: none; + scrollbar-color: transparent transparent; + -ms-overflow-style: none; /* IE and Edge */ + -webkit-overflow-scrolling: touch; + -webkit-scrollbar: none; /* Safari */ +} \ No newline at end of file diff --git a/theming.ts b/theming.ts index 174daa4..9dd2e14 100644 --- a/theming.ts +++ b/theming.ts @@ -5,20 +5,20 @@ import { Config } from './config'; // Replaces app.css with the contents of the file specified in the // config file. export const themePlugin = (): Plugin => { - const themeFile = Config.THEME; - console.log(`Using theme file: ${themeFile}`); + const themeFolder = Config.THEME; + console.log(`Using theme folder: ${themeFolder}`); return { name: 'theme-generator', transform(code, id) { if (id.endsWith('app.css')) { - const colorsCode = Deno.readTextFileSync(Deno.cwd() + '/src/themes/colors.css'); + const colorsCode = Deno.readTextFileSync(Deno.cwd() + '/themes/colors.css'); // Read the theme file and replace the contents of app.css with it // Needs full path to the file - const themeCode = Deno.readTextFileSync(Deno.cwd() + '/src/themes/' + themeFile); + const themeCode = Deno.readTextFileSync(Deno.cwd() + '/themes/' + themeFolder + '/theme.css'); // Replace the contents of app.css with the theme code // and add a comment at the top - const themeComment = `/* Generated from ${themeFile} */\n`; + const themeComment = `/* Generated from ${themeFolder} */\n`; const themeCodeWithComment = themeComment + colorsCode + themeCode; // Return the theme code as the new contents of app.css return {