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
c044f02
commit 6c01edc
Showing
3 changed files
with
63 additions
and
1 deletion.
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,29 @@ | ||
const d3 = require("d3"); | ||
const jsdom = require("jsdom"); | ||
const { JSDOM } = jsdom; | ||
|
||
class Card { | ||
constructor(height = 1024, width = 1280) { | ||
this.height = height; | ||
this.width = width; | ||
// use fake dom let us can get html element | ||
const fakeDom = new JSDOM("<!DOCTYPE html><html><body></body></html>"); | ||
this.body = d3.select(fakeDom.window.document).select("body"); | ||
this.svg = this.body | ||
.append("div") | ||
.attr("class", "container") | ||
.append("svg") | ||
.attr("width", width) | ||
.attr("height", height); | ||
} | ||
|
||
getSVG() { | ||
return this.svg; | ||
} | ||
|
||
toString() { | ||
return this.body.select(".container").html(); | ||
} | ||
} | ||
|
||
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,32 @@ | ||
const Theme = require("../const/theme"); | ||
const getRepoLanguage = require("../utils/github-api/langs"); | ||
const writeSVG = require("../utils/svg-writer"); | ||
const Card = require("./card"); | ||
|
||
function logMapElements(value, key, map) {} | ||
|
||
function createLanguageNode() {} | ||
|
||
const createRepoLanguageCard = async function (username) { | ||
let langMap = await getRepoLanguage(username); | ||
for (let [key, value] of langMap) { | ||
console.log(key + " = " + value); | ||
} | ||
|
||
// Draw a line | ||
let card= new Card(); | ||
console.log(card.toString()); | ||
let circle = card.getSVG() | ||
.append("line") | ||
.attr("x1", 5) | ||
.attr("y1", 5) | ||
.attr("x2", 500) | ||
.attr("y2", 500) | ||
.attr("stroke-width", 2) | ||
.attr("stroke", "black"); | ||
|
||
// Output the result to console | ||
console.log(card.toString()); | ||
}; | ||
|
||
module.exports = createRepoLanguageCard; |