Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ program
.command('card')
.description('Generate a shareable SVG card')
.option('--dark', 'Dark theme (default)')
.option('--midnight', 'Midnight theme')
.option('--light', 'Light theme')
.option('-p, --period <period>', 'today, week, month, all', 'all')
.option('-o, --output <file>', 'Output file', 'flex-card.svg')
.action((opts) => {
ensureRepo();
const theme = opts.light ? 'light' : 'dark';
const theme = opts.midnight ? 'midnight' : opts.light ? 'light' : 'dark';
const { since, label } = getTimeRange(opts.period);
const repoName = getRepoName();
const stats = computeStats({ since });
const streakData = getStreakData(getCurrentUser());
const svg = generateSVG(stats, streakData, repoName, label, theme);
writeFileSync(opts.output, svg);
console.log(`\u2728 Card saved to ${opts.output} (${theme} theme)`);
console.log(` Card saved to ${opts.output} (${theme} theme)`);
});

program
Expand All @@ -102,4 +103,4 @@ program
console.log(renderLangs(stats, repoName, label));
});

program.parse();
program.parse();
9 changes: 8 additions & 1 deletion src/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const DARK = {
purple: '#bc8cff', grad1: '#0d1117', grad2: '#161b22',
};

const MIDNIGHT = {
bg1: '#09090b', bg2: '#18181b', border: '#27272a',
text: '#f4f4f5', textDim: '#71717a', accent: '#10b981',
green: '#22c55e', red: '#ef4444', yellow: '#eab308',
purple: '#a855f7', grad1: '#09090b', grad2: '#18181b',
};

const LIGHT = {
bg1: '#ffffff', bg2: '#f6f8fa', border: '#d0d7de',
text: '#1f2328', textDim: '#656d76', accent: '#0969da',
Expand All @@ -17,7 +24,7 @@ const LIGHT = {
};

export function generateSVG(stats, streakData, repoName, periodLabel, theme = 'dark') {
const c = theme === 'light' ? LIGHT : DARK;
const c = theme === 'light' ? LIGHT : theme === 'midnight' ? MIDNIGHT : DARK;
const rank = getRank(stats, streakData);
const level = getLevel(stats.commits);
const highlights = getHighlights(stats, streakData);
Expand Down