Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
leugimkm committed Sep 26, 2024
2 parents fd65f99 + 19e346c commit 6a1adbf
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
Binary file added tools/days_passed/assets/images/favicon.ico
Binary file not shown.
18 changes: 18 additions & 0 deletions tools/days_passed/assets/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// uncomment when using Cirrus headers
//
// document.querySelector(".nav-btn").addEventListener("click", function () {
// document.getElementById("header-menu").classList.toggle("active");
// this.classList.toggle("active");
// });

function loadConfig() {
fetch("setup.json")
.then((response) => response.json())
.then((data) => {
document.getElementById("title").textContent = data.title;
document.getElementById("subtitle").textContent = data.subtitle;
})
.catch((error) => console.error("Error: error loading json", error));
}

loadConfig();
73 changes: 73 additions & 0 deletions tools/days_passed/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="shortcut icon" href="assets/images/favicon.ico" />
<title>AyudaEnPython | Demo</title>
<link href="https://unpkg.com/cirrus-ui" type="text/css" rel="stylesheet" />
<link
href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@200;300;400;600;700&family=Montserrat:wght@400;700&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://pyscript.net/releases/2024.9.1/core.css"
/>
<script
type="module"
src="https://pyscript.net/releases/2024.9.1/core.js"
></script>
</head>
<body>
<py-config>
[[fetch]]
files = ['main.py']
</py-config>
<py-script>
from pyscript import when, display, document
from main import get_days

@when("click", "#clear-btn")
def clear_all(event):
document.getElementById("main-input").value = ""
document.getElementById("result").innerHTML = "</br>"

@when("click", "#show-btn")
def click_handler(event):
name = document.getElementById("main-input").value
result = get_days(name)
document.getElementById("result").innerHTML = result
</py-script>
<div class="hero fullscreen bg-yellow-200">
<div class="hero-body">
<div class="mx-auto">
<h1 class="title uppercase text-indigo-600" id="title"></h1>
<h3 class="subtitle text-gray-600" id="subtitle"></h1>
<!-- Make changes from here -->
<div class="form-group">
<label class="form-group-label">></label>
<input type="number" id="main-input" class="form-group-input"/>
</div>
<div class="u-center u-gap-2">
<button id="show-btn">Show</button>
<button id="clear-btn">Clear</button>
</div>
<div class="u-round-xs u-shadow-xl p-3 bg-indigo-200">
<div class="u-flex u-justify-center u-gap-2">
<div class="text-indigo-600 font-semibold tracking-looser" id="result"></br></div>
</div>
</div>
<!-- to here -->
</div>
</div>
</div>
<script src="assets/js/main.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions tools/days_passed/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from datetime import date


def get_days(year):
today_ = date.today()
dob = date(int(year), 1, 1)
return (today_ - dob).days
4 changes: 4 additions & 0 deletions tools/days_passed/setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Días transcurridos",
"subtitle": "AyudaEnPython"
}

0 comments on commit 6a1adbf

Please sign in to comment.