Skip to content

Commit f4b0232

Browse files
matheusjardimbMatheus Jardim Bernardes
andauthored
Update position duration dinamically (#67)
Co-authored-by: Matheus Jardim Bernardes <matheus.jardim@conceptu.ind.br>
1 parent f23d2cf commit f4b0232

6 files changed

Lines changed: 59 additions & 7 deletions

File tree

.github/lighthouse/budget.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"resourceSizes": [
55
{
66
"resourceType": "document",
7-
"budget": 18
7+
"budget": 25
88
},
99
{
1010
"resourceType": "total",
11-
"budget": 200
11+
"budget": 300
1212
}
1313
]
1414
}

.github/workflows/lighthouse.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ jobs:
66
lighthouse:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v4
1010
- name: Audit URLs using Lighthouse
11-
uses: treosh/lighthouse-ci-action@v9
11+
uses: treosh/lighthouse-ci-action@v11
1212
with:
1313
urls: "https://matheusjardimb.com/"
1414
budgetPath: ".github/lighthouse/budget.json"
1515
uploadArtifacts: true
1616
temporaryPublicStorage: true
1717
configPath: ".github/lighthouse/lighthouserc-static-dist-dir.yml"
18+
env:
19+
LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }}

assets/css/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ main {
850850
line-height: 1.6;
851851
}
852852

853+
#professor-period,
854+
#cto-period {
855+
display: inline;
856+
}
857+
853858
.timeline-item:not(:last-child)::before {
854859
content: "";
855860
position: absolute;

assets/images/my-avatar.png

-383 KB
Binary file not shown.

assets/js/script.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,45 @@ function updateAge() {
3030

3131
setInterval(updateAge, 1000);
3232

33+
// Update work periods
34+
function calculatePeriod(startDate) {
35+
const now = new Date();
36+
const start = new Date(startDate);
37+
const diffTime = Math.abs(now - start);
38+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
39+
40+
const years = Math.floor(diffDays / 365);
41+
const months = Math.floor((diffDays % 365) / 30);
42+
43+
let result = "";
44+
if (years > 0) {
45+
result += `${years} yr${years > 1 ? "s" : ""}`;
46+
}
47+
if (months > 0) {
48+
if (result) result += " ";
49+
result += `${months} mo${months > 1 ? "s" : ""}`;
50+
}
51+
52+
return result || "0 mos";
53+
}
54+
55+
function updateWorkPeriods() {
56+
const professorElement = document.getElementById("professor-period");
57+
const ctoElement = document.getElementById("cto-period");
58+
59+
if (professorElement) {
60+
professorElement.innerHTML = calculatePeriod(new Date(2024, 1, 1)); // Feb 2024
61+
}
62+
63+
if (ctoElement) {
64+
ctoElement.innerHTML = calculatePeriod(new Date(2016, 11, 1)); // Dec 2016
65+
}
66+
}
67+
68+
// Update periods initially and then every hour
69+
updateWorkPeriods();
70+
setInterval(updateWorkPeriods, 3600000); // Update every hour
71+
3372
// element toggle function
3473
const elementToggleFunc = function (elem) {
3574
elem.classList.toggle("active");

index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<meta property="og:url" content="https://matheusjardimb.com/" />
3535
<meta
3636
property="og:image"
37-
content="https://matheusjardimb.com/assets/images/my-avatar.png"
37+
content="https://matheusjardimb.com/assets/images/my-avatar.webp"
3838
/>
3939

4040
<!-- favicon -->
@@ -667,7 +667,10 @@ <h3 class="h3">Experience</h3>
667667
<ol class="timeline-list">
668668
<li class="timeline-item">
669669
<h4 class="h4 timeline-item-title">Professor at Atitus</h4>
670-
<span>Feb 2024 - Present · 3 mos</span>
670+
<span
671+
>Feb 2024 - Present ·
672+
<span id="professor-period">3 mos</span></span
673+
>
671674
<!-- <p class="timeline-text">-->
672675
<!-- TODO-->
673676
<!-- </p>-->
@@ -677,7 +680,10 @@ <h4 class="h4 timeline-item-title">Professor at Atitus</h4>
677680
<h4 class="h4 timeline-item-title">
678681
CTO at Conceptu Protótipos & Sistemas
679682
</h4>
680-
<span>Dec 2016 - Present · 7 yrs 5 mos</span>
683+
<span
684+
>Dec 2016 - Present ·
685+
<span id="cto-period">7 yrs 5 mos</span></span
686+
>
681687
<!-- <p class="timeline-text">-->
682688
<!-- TODO-->
683689
<!-- </p>-->

0 commit comments

Comments
 (0)