-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add correct languages calculation and display
- Loading branch information
Showing
4 changed files
with
45 additions
and
26 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
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 |
---|---|---|
@@ -1,16 +1,12 @@ | ||
import colors from "github-colors/colors.json"; | ||
import { Language } from "@octokit/graphql-schema"; | ||
|
||
const userLangs = (langs: string[], joinLiteral = "") => langs.map(lang => { | ||
const colorKey = Object.keys(colors).find(key => key.toLowerCase() === lang.toLowerCase()); | ||
const color = colorKey ? colors[colorKey as keyof typeof colors].color ?? "#000" : "#000"; | ||
|
||
return ` | ||
<div style=" | ||
width: ${Math.round(100 / langs.length)}%; | ||
height: 10%; | ||
background: ${color}; | ||
"/> | ||
`; | ||
}).join(joinLiteral); | ||
const userLangs = (langs: (Language & { | ||
size: number, | ||
})[], totalCount = 0, joinLiteral = "") => langs.map(({ color, size }) => ` | ||
<div style=" | ||
width: ${totalCount > 0 ? Math.round( size / totalCount * 100) : 100 / langs.length}%; | ||
height: 11px; | ||
background: ${color ?? "#000"}; | ||
"/>`).join(joinLiteral); | ||
|
||
export default userLangs; |
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