Skip to content

Commit 483b417

Browse files
committed
fix(style): datetime shortcode text blends with dark background
- When span.current-timestamp (and related shortcodes) are children of .article--content, the text isn't visible in the dark theme--it blends with the background. - Add specific style settings for datetime shortcodes so that the timestamp text is visible outside of a table.
1 parent de585dd commit 483b417

File tree

6 files changed

+55
-2
lines changed

6 files changed

+55
-2
lines changed

assets/js/datetime.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import $ from 'jquery';
22

33
var date = new Date();
44
var currentTimestamp = date.toISOString().replace(/^(.*)(\.\d+)(Z)/, '$1$3'); // 2023-01-01T12:34:56Z
5-
var currentTime = date.toISOString().replace(/(^.*T)(.*)(Z)/, '$2') + '084216'; // 12:34:56.000084216
65

6+
// Microsecond offset appended to the current time string for formatting purposes
7+
const MICROSECOND_OFFSET = '084216';
8+
9+
var currentTime =
10+
date.toISOString().replace(/(^.*T)(.*)(Z)/, '$2') + MICROSECOND_OFFSET; // 12:34:56.000084216
711
function currentDate(offset = 0, trimTime = false) {
812
let outputDate = new Date(date);
913
outputDate.setDate(outputDate.getDate() + offset);

assets/styles/layouts/_datetime.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Datetime Components
3+
----------------------------------------------
4+
*/
5+
6+
.current-timestamp,
7+
.current-date,
8+
.current-time,
9+
.enterprise-eol-date {
10+
color: $current-timestamp-color;
11+
display: inline-block;
12+
font-family: $proxima;
13+
white-space: nowrap;
14+
}
15+
16+
.nowrap {
17+
white-space: nowrap;
18+
}

assets/styles/styles-default.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"layouts/syntax-highlighting",
2424
"layouts/algolia-search-overrides",
2525
"layouts/landing",
26+
"layouts/datetime",
2627
"layouts/error-page",
2728
"layouts/footer-widgets",
2829
"layouts/modals",

assets/styles/themes/_theme-dark.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ $article-btn-text-hover: $g20-white;
203203
$article-nav-icon-bg: $g5-pepper;
204204
$article-nav-acct-bg: $g3-castle;
205205

206+
// Datetime shortcode colors
207+
$current-timestamp-color: $g15-platinum;
208+
$current-date-color: $g15-platinum;
209+
$current-time-color: $g15-platinum;
210+
$enterprise-eol-date-color: $g15-platinum;
211+
206212
// Error Page Colors
207213
$error-page-btn: $b-pool;
208214
$error-page-btn-text: $g20-white;

assets/styles/themes/_theme-light.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ $article-btn-text-hover: $g20-white !default;
203203
$article-nav-icon-bg: $g6-smoke !default;
204204
$article-nav-acct-bg: $g5-pepper !default;
205205

206+
// Datetime Colors
207+
$current-timestamp-color: $article-text !default;
208+
$current-date-color: $article-text !default;
209+
$current-time-color: $article-text !default;
210+
$enterprise-eol-date-color: $article-text !default;
211+
206212
// Error Page Colors
207213
$error-page-btn: $b-pool !default;
208214
$error-page-btn-text: $g20-white !default;

content/example.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,4 +1351,22 @@ and all the rows with the `hum` field will be in another.
13511351
| 2022-01-01T10:00:00Z | home | Living Room | temp | 21.8 |
13521352

13531353
{{% /tab-content %}}
1354-
{{< /tabs-wrapper >}}
1354+
{{< /tabs-wrapper >}}
1355+
1356+
## datetime/current-timestamp shortcode
1357+
1358+
### Default usage
1359+
1360+
{{< datetime/current-timestamp >}}
1361+
1362+
### Format YYYY-MM-DD HH:mm:ss
1363+
1364+
{{< datetime/current-timestamp format="YYYY-MM-DD HH:mm:ss" >}}
1365+
1366+
### Format with UTC timezone
1367+
1368+
{{< datetime/current-timestamp format="YYYY-MM-DD HH:mm:ss" timezone="UTC" >}}
1369+
1370+
### Format with America/New_York timezone
1371+
1372+
{{< datetime/current-timestamp format="YYYY-MM-DD HH:mm:ss" timezone="America/New_York" >}}

0 commit comments

Comments
 (0)