Skip to content

Commit

Permalink
refactor: dashboard github
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRiceCold committed Jul 4, 2024
1 parent ce41176 commit e0b0f15
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
29 changes: 13 additions & 16 deletions ags/desktop/fullscreen/dashboard/home/GitHub.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import Gtk from 'gi:https://Gtk?version=3.0'

import options from 'options'

const contribData = Variable()
const { Gtk } = imports.gi
const contribData = Variable([])
const contribCount = Variable(0)
const { username } = options.dashboard.github
const user = options.dashboard.githubUser

Utils.execAsync([
'curl', `https://github-contributions.vercel.app/api/v1/${username.value}`.toLowerCase()
'curl', `https://github-contributions.vercel.app/api/v1/${user.value}`
]).then(x => {
const out = JSON.parse(x)

const daysLeftInYear = 365 - Number(Utils.exec('date +%j'))
contribData.value = out.contributions.slice(daysLeftInYear)

// Count total contribs
let _contribCount = 0
out.years.forEach(y => _contribCount += y.total)
contribCount.value = _contribCount
let count = 0
out.years.forEach(y => count += y.total)
contribCount.value = count
}).catch(err => print(err))

const ContribBox = (intensity = 0) => Widget.DrawingArea({
Expand Down Expand Up @@ -69,10 +67,9 @@ export default Widget.Box({
vertical: true,
className: 'github',
visible: contribCount.bind(),
children: [
Widget.Label({
className: 'header',
label: Utils.merge([username.bind(), contribCount.bind()], (u, c) => ` ${u} | ${c} total lifetime contributions`)
}), ContribGrid
]
})
}, Widget.Label({
className: 'header',
label: Utils.merge(
[user.bind(), contribCount.bind()],
(u, c) => ` ${u} | ${c} total lifetime contributions`)
}), ContribGrid)
14 changes: 9 additions & 5 deletions ags/desktop/fullscreen/dashboard/home/github.sass
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
background-color: $primary-bg
min-width: 0.8rem

window#dashboard .dashboard .github
.header
color: $fg
font-size: 1.25rem
margin-bottom: $spacing
window#dashboard .dashboard
.content .github
@include floating_widget
padding: 1rem
margin: 0
.header
color: $fg
font-size: 1.25rem
margin-bottom: $spacing
3 changes: 1 addition & 2 deletions ags/options/windows/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { opt } from 'lib/option'

export default {
github: { username: opt('TheRiceCold') },
githubUser: opt('TheRiceCold'),
photo: opt(`/home/${Utils.USER}/photo-sample.jpg`),
tasks: { directory: opt(`/home/${Utils.USER}/tasks`) },
bio: opt('~ What we do in life, echoes in eternity ~'),
Expand Down Expand Up @@ -37,5 +37,4 @@ export default {
{ label: 'Virtual Machine Manager', name: 'virt-manager' },
]
]),

}

0 comments on commit e0b0f15

Please sign in to comment.