Skip to content

Commit

Permalink
Add a simple board
Browse files Browse the repository at this point in the history
  • Loading branch information
vn7n24fzkq committed Aug 15, 2020
1 parent 2b3af16 commit 5cdd595
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 4 deletions.
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "github-profile-card",
"version": "0.0.1",
"description": "Generate github profile card",
"main": "index.js",
"main": "src/app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
8 changes: 8 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

const writer = require("./utils/svg-writer");
const TopLangCard = require("./templates/top-lang-card");

var myArgs = process.argv.slice(2);
let card = new TopLangCard("user");
writer.save("test", card.getSVG());
12 changes: 12 additions & 0 deletions src/const/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Theme={
default:
`
.card-title{
font: 500 20px 'Segoe UI', Ubuntu, Sans-Serif;
fill: black;
}
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: grey }
`
}

module.exports = Theme;
65 changes: 65 additions & 0 deletions src/templates/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const Theme = require("../const/theme");

class Card {
constructor(
title = "Title",
width = 320,
height = 180,
theme = Theme.default
) {
this.title = title;
this.paddingX = 20;
this.paddingY = 30;
this.theme = theme;
this.width = width;
this.height = height;
}

getContentSVG() {
return "";
}

getSVG() {
return `
<svg
height= "${this.height}"
width= "${this.width}"
viewBox="0 0 ${this.width} ${this.height}"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<style>
${this.theme}
</style>
<rect
data-testid="card-bg"
rx="4.0"
ry="4.0"
height="100%"
stroke="#E4E2E2"
fill="#006600"
stroke-opacity="1"
/>
<g
data-testid="card-title"
transform="translate(${this.paddingX}, ${this.paddingY})"
>
<text
class="card-title"
data-testid="card-title"
>
${this.title}
</text>
</g>
<g
data-testid="card-content"
>
</g>
</svg>
`;
}
}

module.exports = Card;
21 changes: 21 additions & 0 deletions src/templates/top-lang-card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Theme = require("../const/theme");
const Card = require("./card");

class TopLangCard extends Card {
constructor(
username,
title = "TopLangCard",
width = 320,
height = 180,
theme = Theme.default
) {
super(title, width, height, theme);
this.username = username;
}
getContentSVG() {
return `
`;
}
}

module.exports = TopLangCard;
13 changes: 13 additions & 0 deletions src/utils/svg-writer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require("fs");
module.exports.save = function (filename, svgString) {
const folder = "/tmp/github-svg/";
fs.mkdir(folder, { recursive: true }, (err) => {
if (err) throw err;
});
fs.writeFileSync(`${folder}${filename}.svg`, svgString, function (
err,
result
) {
if (err) console.log("error", err);
});
};

0 comments on commit 5cdd595

Please sign in to comment.