-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: allow site name and sidebar colour to be set * feat: sidebar icon * fix: fix build issues * docs: document new branding options
- Loading branch information
Showing
52 changed files
with
379 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {asyncForEach} from '@arcath/utils' | ||
import {getPrisma} from './prisma.server' | ||
|
||
type SettingKey = 'site-name' | 'site-color' | 'site-icon' | ||
|
||
export const DEFAULT_SETTINGS: {[setting in SettingKey]: string} = { | ||
'site-name': 'Net Doc', | ||
'site-color': '#d1d5db', | ||
'site-icon': '/icon.png' | ||
} | ||
|
||
export const getSetting = async (setting: SettingKey) => { | ||
const prisma = getPrisma() | ||
|
||
const dbSetting = await prisma.setting.findFirst({where: {key: setting}}) | ||
|
||
if (dbSetting === null) { | ||
return DEFAULT_SETTINGS[setting] | ||
} | ||
|
||
return dbSetting.value | ||
} | ||
|
||
export const getSettings = async <RequestedKey extends SettingKey>( | ||
settings: RequestedKey[] | ||
) => { | ||
const results = Object.fromEntries(settings.map(v => [v, ''])) as { | ||
[key in RequestedKey]: string | ||
} | ||
|
||
await asyncForEach(settings, async setting => { | ||
results[setting] = await getSetting(setting) | ||
}) | ||
|
||
return results | ||
} | ||
|
||
export const setSetting = async (setting: SettingKey, value: string) => { | ||
const prisma = getPrisma() | ||
|
||
await prisma.setting.upsert({ | ||
where: {key: setting}, | ||
create: {key: setting, value}, | ||
update: {value} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const contrastColor = (color: string) => { | ||
return luma(color) >= 165 ? '#444' : '#fff' | ||
} | ||
const luma = (color: string | Array<number>) => { | ||
// color can be a hx string or an array of RGB values 0-255 | ||
const rgb = typeof color === 'string' ? hexToRGBArray(color) : color | ||
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2] // SMPTE C, Rec. 709 weightings | ||
} | ||
const hexToRGBArray = (color: string) => { | ||
if (color.length === 3) | ||
color = | ||
color.charAt(0) + | ||
color.charAt(0) + | ||
color.charAt(1) + | ||
color.charAt(1) + | ||
color.charAt(2) + | ||
color.charAt(2) | ||
else if (color.length !== 6) throw 'Invalid hex color: ' + color | ||
const rgb = [] | ||
for (let i = 0; i <= 2; i++) rgb[i] = parseInt(color.substr(i * 2, 2), 16) | ||
return rgb | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export const pageTitle = (...parts: string[]) => { | ||
return ['Net Doc', ...parts].join(' / ') | ||
import {type MetaArgs} from '@remix-run/node' | ||
|
||
export const pageTitle = (matches: MetaArgs['matches'], ...parts: string[]) => { | ||
const appName = ( | ||
matches.filter(match => match.pathname === '/app')[0].data as { | ||
settings: {'site-name': string} | ||
} | ||
).settings['site-name'] | ||
|
||
return [appName, ...parts].join(' / ') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.