Skip to content

Commit

Permalink
Merge pull request #133 from jasonlong/halloween-fix
Browse files Browse the repository at this point in the history
Handle halloween colors
  • Loading branch information
jasonlong authored Oct 31, 2020
2 parents a5e10ec + e8086c0 commit b706096
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"xo": {
"semicolon": false,
"space": true,
"prefer-numeric-literals": 0,
"global": [
"obelisk",
"chrome"
Expand All @@ -24,9 +25,6 @@
"ignores": [
"src/webext-domain-permission-toggle.js",
"src/background.js"
],
"rules": [
"prefer-numeric-literals": 0
]
}
}
32 changes: 30 additions & 2 deletions src/iso.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const dateOptions = {month: 'short', day: 'numeric'}
let calendarGraph
let contributionsBox
let colors = []
let halloweenColors = []
let yearTotal = 0
let averageCount = 0
let maxCount = 0
Expand Down Expand Up @@ -49,6 +50,24 @@ const loadColors = () => {
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-graph-day-L4-bg').replace('#', ''), 16)
)
]

halloweenColors = [
new obelisk.CubeColor().getByHorizontalColor(
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-halloween-graph-day-bg').replace('#', ''), 16)
),
new obelisk.CubeColor().getByHorizontalColor(
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-halloween-graph-day-L1-bg').replace('#', ''), 16)
),
new obelisk.CubeColor().getByHorizontalColor(
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-halloween-graph-day-L2-bg').replace('#', ''), 16)
),
new obelisk.CubeColor().getByHorizontalColor(
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-halloween-graph-day-L3-bg').replace('#', ''), 16)
),
new obelisk.CubeColor().getByHorizontalColor(
Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--color-calendar-halloween-graph-day-L4-bg').replace('#', ''), 16)
)
]
}

const getSettings = () => {
Expand Down Expand Up @@ -262,6 +281,16 @@ const getSquareColor = fill => {
return colors[3]
case 'var(--color-calendar-graph-day-L4-bg)':
return colors[4]
case 'var(--color-calendar-halloween-graph-day-bg)':
return halloweenColors[0]
case 'var(--color-calendar-halloween-graph-day-L1-bg)':
return halloweenColors[1]
case 'var(--color-calendar-halloween-graph-day-L2-bg)':
return halloweenColors[2]
case 'var(--color-calendar-halloween-graph-day-L3-bg)':
return halloweenColors[3]
case 'var(--color-calendar-halloween-graph-day-L4-bg)':
return halloweenColors[4]
default:
if (fill.includes('#')) {
return new obelisk.CubeColor().getByHorizontalColor(Number.parseInt('0x' + fill.replace('#', ''), 16))
Expand Down Expand Up @@ -412,8 +441,7 @@ if (document.querySelector('.js-calendar-graph')) {
generateIsometricChart()
}
})
}
else if (mutation.attributeName === 'data-color-mode') {
} else if (mutation.attributeName === 'data-color-mode') {
loadColors()
renderIsometricChart()
}
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "GitHub Isometric Contributions",
"version": "1.1.6",
"version": "1.1.7",
"description": "Renders an isometric pixel view of GitHub contribution graphs.",
"content_scripts": [ {
"css": [ "iso.css" ],
Expand Down

0 comments on commit b706096

Please sign in to comment.