Skip to content

Commit

Permalink
feat: infer content color
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jan 10, 2025
1 parent f388178 commit 2155392
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/import-skins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ async function loadAndConvertSkin(skin: string) {
colors[`${key}_color`] = color;
});

if (colors['text_color']) {
colors['content_color'] = colors['text_color'];
const textRgba = hexToRgba(colors['text_color']);
textRgba[3] = 0.85;

colors['text_color'] = opacifyColor(textRgba, hexToRgba(colors['bg_color'] || 'ffffff'));
}

skins[skin] = colors;
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -272,15 +280,16 @@ async function main() {

return db.queryAsync(
`
INSERT INTO skins (id, bg_color, link_color, text_color, border_color, heading_color, primary_color, header_color)
VALUES(?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO skins (id, bg_color, link_color, text_color, content_color, border_color, heading_color, primary_color, header_color)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE id=id
`,
[
space.id,
skin.bg_color,
skin.link_color,
skin.text_color,
skin.content_color,
skin.border_color,
skin.heading_color,
skin.primary_color,
Expand Down
1 change: 1 addition & 0 deletions test/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ CREATE TABLE skins (
bg_color VARCHAR(6) DEFAULT NULL,
link_color VARCHAR(6) DEFAULT NULL,
text_color VARCHAR(6) DEFAULT NULL,
content_color VARCHAR(6) DEFAULT NULL,
border_color VARCHAR(6) DEFAULT NULL,
heading_color VARCHAR(6) DEFAULT NULL,
primary_color VARCHAR(6) DEFAULT NULL,
Expand Down

0 comments on commit 2155392

Please sign in to comment.