A simple calendar with basic navigation. Works with the lang
attribute for localization.
Also, lang="fr-FR"
, where the week starts on Monday.
Here, lang="ae-AE"
is used.
const app = document.querySelector('ui-calendar');
app.addEventListener(
'keydown',
(e) => e.key === 'Enter' && select(e.target),
);
app.addEventListener(
'click',
(e) =>
e.target.hasAttribute('datetime') && select(e.target),
);
const select = (node) =>
console.log(node.getAttribute('datetime') || '');