forked from vn7n24fzkq/github-profile-summary-cards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3af16
commit 5cdd595
Showing
7 changed files
with
120 additions
and
4 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
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,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()); |
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,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; |
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,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; |
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,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; |
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,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); | ||
}); | ||
}; |