Skip to content

Commit 8a35156

Browse files
committed
Add Light/Dark card appearance toggle
Adds an Appearance row to the UI (Dark/Light buttons) that applies a .card-theme-light modifier class to #capture, switching the card to GitHub's light-mode palette (white background, #f6f8fa header, #d0d7de borders). The Terminal template's internal window stays dark in light mode. applyTemplate() now re-applies the card theme class after resetting card.className so switching templates preserves the chosen appearance. https://claude.ai/code/session_019mFhzJHWmUB8cTbLksb6ev
1 parent 81feb23 commit 8a35156

4 files changed

Lines changed: 138 additions & 1 deletion

File tree

assets/css/styles.css

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,23 @@ h1 span {
813813
font-weight: 500;
814814
}
815815

816+
/* ========================= */
817+
/* Card appearance toggle */
818+
/* ========================= */
819+
.card-theme-row {
820+
display: flex;
821+
gap: 8px;
822+
margin-bottom: 28px;
823+
align-items: center;
824+
}
825+
826+
.card-theme-label {
827+
font-size: 16px;
828+
color: var(--fg3);
829+
margin-right: 4px;
830+
font-weight: 500;
831+
}
832+
816833
.platform-desktop .card-header {
817834
height: 70px;
818835
}
@@ -1329,3 +1346,93 @@ h1 span {
13291346
grid-auto-rows: minmax(55px, auto);
13301347
gap: 10px;
13311348
}
1349+
1350+
/* ========================= */
1351+
/* Light card theme */
1352+
/* ========================= */
1353+
.card-theme-light {
1354+
background: #ffffff;
1355+
}
1356+
1357+
.card-theme-light .card-header {
1358+
background: #f6f8fa;
1359+
border-bottom-color: #d0d7de;
1360+
}
1361+
1362+
.card-theme-light .gh-logo {
1363+
fill: #24292f;
1364+
}
1365+
1366+
.card-theme-light .gh-path {
1367+
background: #ffffff;
1368+
border-color: #d0d7de;
1369+
}
1370+
1371+
.card-theme-light .gh-path-text {
1372+
color: #57606a;
1373+
}
1374+
1375+
.card-theme-light .gh-path-slash {
1376+
border-color: #d0d7de;
1377+
color: #57606a;
1378+
}
1379+
1380+
.card-theme-light .hdr-nav span {
1381+
color: #24292f;
1382+
}
1383+
1384+
.card-theme-light .hdr-btn {
1385+
background: #f6f8fa;
1386+
border-color: #d0d7de;
1387+
color: #24292f;
1388+
}
1389+
1390+
.card-theme-light .hdr-btn.cnt {
1391+
background: #ffffff;
1392+
color: #24292f;
1393+
}
1394+
1395+
.card-theme-light .hdr-btn-icon {
1396+
fill: #57606a;
1397+
}
1398+
1399+
.card-theme-light .card-footer {
1400+
background: rgba(246, 248, 250, 0.9);
1401+
border-top-color: #d0d7de;
1402+
}
1403+
1404+
.card-theme-light .foot-item {
1405+
color: #57606a;
1406+
}
1407+
1408+
.card-theme-light .foot-icon {
1409+
fill: #57606a;
1410+
}
1411+
1412+
.card-theme-light .main-repo-title {
1413+
color: #1f2328;
1414+
}
1415+
1416+
.card-theme-light .main-repo-desc {
1417+
color: rgba(31, 35, 40, 0.7);
1418+
}
1419+
1420+
.card-theme-light .bento-box {
1421+
background: rgba(31, 35, 40, 0.04);
1422+
border-color: rgba(31, 35, 40, 0.12);
1423+
}
1424+
1425+
.card-theme-light .bento-box-text {
1426+
color: #1f2328;
1427+
}
1428+
1429+
/* Terminal template in light mode — keep dark terminal window */
1430+
.card-theme-light .template-terminal .card-body {
1431+
background: transparent;
1432+
}
1433+
1434+
.card-theme-light .template-terminal .bento-container {
1435+
background: #0d1117;
1436+
border-color: #30363d;
1437+
color: var(--tc, #3fb950);
1438+
}

assets/js/app.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const elements = getElements();
88
let currentTheme = DEFAULT_THEME;
99
let currentTemplate = 'grid';
1010
let currentPlatform = 'mobile';
11+
let currentCardTheme = 'dark';
1112
let customThemeHex = '#58a6ff';
1213

1314
const ANIMATION_DURATION = 4000;
@@ -70,11 +71,29 @@ function applyTemplate(templateName) {
7071
if (currentPlatform === 'desktop') {
7172
card.classList.add('platform-desktop');
7273
}
74+
if (currentCardTheme === 'light') {
75+
card.classList.add('card-theme-light');
76+
}
7377
elements.templateButtons.forEach((btn) => {
7478
btn.classList.toggle('active', btn.dataset.template === templateName);
7579
});
7680
}
7781

82+
function applyCardTheme(themeName) {
83+
currentCardTheme = themeName;
84+
const card = elements.capture;
85+
86+
if (themeName === 'light') {
87+
card.classList.add('card-theme-light');
88+
} else {
89+
card.classList.remove('card-theme-light');
90+
}
91+
92+
elements.cardThemeButtons.forEach((btn) => {
93+
btn.classList.toggle('active', btn.dataset.cardTheme === themeName);
94+
});
95+
}
96+
7897
function applyPlatform(platformName) {
7998
currentPlatform = platformName;
8099
const card = elements.capture;
@@ -279,12 +298,16 @@ function bindEvents() {
279298
elements.platformButtons.forEach((btn) => {
280299
btn.addEventListener('click', () => applyPlatform(btn.dataset.platform));
281300
});
301+
elements.cardThemeButtons.forEach((btn) => {
302+
btn.addEventListener('click', () => applyCardTheme(btn.dataset.cardTheme));
303+
});
282304
}
283305

284306
bindEvents();
285307
applyTheme(DEFAULT_THEME);
286308
applyTemplate('grid');
287309
applyPlatform('mobile');
310+
applyCardTheme('dark');
288311
startBlobAnimation();
289312

290313
// Custom color picker initialization

assets/js/dom.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export function getElements() {
2525
blob3: document.getElementById('blob3'),
2626
themeDots: Array.from(document.querySelectorAll('.theme-dot')),
2727
templateButtons: Array.from(document.querySelectorAll('[data-template]')),
28-
platformButtons: Array.from(document.querySelectorAll('[data-platform]'))
28+
platformButtons: Array.from(document.querySelectorAll('[data-platform]')),
29+
cardThemeButtons: Array.from(document.querySelectorAll('[data-card-theme]'))
2930
};
3031
}
3132

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ <h1>GitHub Social <span>Preview</span></h1>
7171
<button class="template-btn" data-platform="desktop">Desktop</button>
7272
</div>
7373

74+
<div class="card-theme-row">
75+
<span class="card-theme-label">Appearance</span>
76+
<button class="template-btn active" data-card-theme="dark">Dark</button>
77+
<button class="template-btn" data-card-theme="light">Light</button>
78+
</div>
79+
7480
<div class="dl-row">
7581
<button class="btn-dl" id="btn-jpg">
7682
<svg width="15" height="15" fill="currentColor" viewBox="0 0 16 16"><path d="M2.75 14A1.75 1.75 0 011 12.25v-2.5a.75.75 0 011.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25v-2.5a.75.75 0 011.5 0v2.5A1.75 1.75 0 0113.25 14H2.75z"/><path d="M7.25 7.689V2a.75.75 0 011.5 0v5.689l1.97-1.969a.749.749 0 111.06 1.06l-3.25 3.25a.749.749 0 01-1.06 0L4.22 6.78a.749.749 0 111.06-1.06l1.97 1.969z"/></svg>

0 commit comments

Comments
 (0)