Added theme system

pull/126/head
tycrek 2 years ago
parent a6c246b134
commit 1f94513e1c
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -1,5 +1,38 @@
const primary = '#FD842D'; const fs = require('fs-extra');
const primaryDim = '#B64D02'; const path = require('path');
const themePath = path.join(process.cwd(), 'share', 'theme.json');
/**
* ! IMPORTANT !
* Do NOT edit this file directly!
*
* Instead, edit the `theme.js` file in the `share` directory.
* For more info, please see the README: https://github.com/tycrek/ass/#customizing-the-viewer
*/
const defaults = {
// Font
font: '"Josefin Sans"',
// Background colours
bgPage: '#212121',
bgViewer: '#151515',
// Text colours
txtPrimary: '#FD842D',
txtSecondary: '#BDBDBD',
// Links
linkHover: '#FD710D',
linkActive: '#DE5E02',
// Other
borderHover: '#B64D02',
};
let theme = {};
if (fs.existsSync(themePath))
theme = fs.readJsonSync(themePath);
module.exports = { module.exports = {
separator: '_', separator: '_',
darkMode: 'class', darkMode: 'class',
@ -10,23 +43,20 @@ module.exports = {
theme: { theme: {
extend: { extend: {
fontFamily: { fontFamily: {
main: ['"Josefin Sans"', 'ui-sans-serif', 'system-ui', 'sans-serif'] main: [theme.font || defaults.font, 'ui-sans-serif', 'system-ui', 'sans-serif']
}, },
backgroundColor: { backgroundColor: {
'primary': primary, 'page': theme.bgPage || defaults.bgPage,
'body': '#212121', 'viewer': theme.bgViewer || defaults.bgViewer,
}, },
colors: { colors: {
'content-bg': '#151515', 'primary': theme.txtPrimary || defaults.txtPrimary,
'primary': primary, 'secondary': theme.txtSecondary || defaults.txtSecondary,
'primary-dim': primaryDim, 'link-hover': theme.linkHover || defaults.linkHover,
'primary-dark': '#793301', 'link-active': theme.linkActive || defaults.linkActive,
'link-hover': '#FD710D',
'link-active': '#DE5E02',
'text-primary': '#BDBDBD',
}, },
borderColor: { borderColor: {
'primary-dim': primaryDim 'hover': theme.borderHover || defaults.borderHover
}, },
maxHeight: { maxHeight: {
'half-port': '50vh' 'half-port': '50vh'

@ -17,7 +17,7 @@
/* hover */ /* hover */
hover_text-link-hover hover_text-link-hover
hover_border-primary-dim hover_border-hover
/* active */ /* active */
active_text-link-active active_text-link-active

@ -21,10 +21,10 @@ html
* { display: none !important; } * { display: none !important; }
meta(http-equiv='refresh' content=`0; url='${resourceAttr.src}'`) meta(http-equiv='refresh' content=`0; url='${resourceAttr.src}'`)
body.font-main.text-text-primary.bg-body body.font-main.text-secondary.bg-page
.w-full.h-full.flex.justify-center.items-center.text-center .w-full.h-full.flex.justify-center.items-center.text-center
.bg-content-bg.rounded-24 .bg-viewer.rounded-24
h4.mt-6.mb-4.text-3xl.font-main!=title h4.mx-4.mt-6.mb-4.text-3xl.font-main!=title
figure.block.mx-10.my-4.flex.flex-col.align-items-center figure.block.mx-10.my-4.flex.flex-col.align-items-center
if fileIs.video if fileIs.video
video.res-media(controls loop muted playsinline preload='metadata')&attributes(resourceAttr) video.res-media(controls loop muted playsinline preload='metadata')&attributes(resourceAttr)

Loading…
Cancel
Save