Skip to content

Commit

Permalink
Add ESLint and a <time> converter
Browse files Browse the repository at this point in the history
And some style tweaks.
  • Loading branch information
samwilson authored Sep 26, 2020
1 parent 7e64065 commit bdde925
Show file tree
Hide file tree
Showing 15 changed files with 934 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4],
"semi": ["error", "always"]
}
}
5 changes: 5 additions & 0 deletions assets/css/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
article {
max-width: 66em;
margin: auto;

.meta {
color: #626463;
font-variant: small-caps;
}
}

blockquote {
Expand Down
12 changes: 12 additions & 0 deletions assets/css/post.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ h1 { text-align: center; }
font-size: smaller;
text-align: right;
}

@media screen and (max-width: 500px) {
header {
flex-direction: column;

time {
text-align: center;
font-variant: small-caps;
}
}
}

article { padding: 1em; }

footer {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import '../css/app.less';

import './timezone-converter';
18 changes: 18 additions & 0 deletions assets/js/timezone-converter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function () {
document.body.querySelectorAll('time').forEach(function (timeEl) {
// Show the UTC time as the tooltip.
timeEl.title = 'UTC time: ' + timeEl.innerText;
// Convert to local browser time for actual display.
const date = new Date(Date.parse(timeEl.dateTime));
const options = {
timeZoneName: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long',
hour: 'numeric',
minute: 'numeric'
};
timeEl.innerText = date.toLocaleString([], options) + '.';
});
}());
Loading

0 comments on commit bdde925

Please sign in to comment.