astro-accelerator 5.10.32 → 5.10.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.10.32",
2
+ "version": "5.10.34",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -1323,6 +1323,123 @@ figure:focus .magnify-button {
1323
1323
  margin: 0;
1324
1324
  }
1325
1325
 
1326
+ /* Events timeline */
1327
+
1328
+ .timeline {
1329
+ position: relative;
1330
+ }
1331
+
1332
+ .timeline h2,
1333
+ .timeline h3 {
1334
+ margin: 0 0 0.5rem 0;
1335
+ font-size: var(--font-size-h4)
1336
+ }
1337
+
1338
+ .timeline::before {
1339
+ content: '';
1340
+ position: absolute;
1341
+ left: 2rem;
1342
+ top: 0;
1343
+ bottom: 0;
1344
+ width: 0.4rem;
1345
+ background-color: var(--icon-block);
1346
+ }
1347
+
1348
+ .timeline-event {
1349
+ position: relative;
1350
+ margin-bottom: 1rem;
1351
+ padding-left: 4rem;
1352
+ transition: margin-bottom 0.3s ease;
1353
+ }
1354
+
1355
+ .timeline-event::before {
1356
+ content: '';
1357
+ position: absolute;
1358
+ left: 1.5rem;
1359
+ top: 1.5rem;
1360
+ width: 1rem;
1361
+ height: 1rem;
1362
+ background: var(--aft);
1363
+ border: 3px solid var(--icon-block);
1364
+ border-radius: 50%;
1365
+ box-shadow: var(--box-shadow-unselected);
1366
+ transition: all 0.3s ease;
1367
+ z-index: 1;
1368
+ }
1369
+
1370
+ .timeline-event:focus-within {
1371
+ margin-bottom: 2rem;
1372
+ }
1373
+
1374
+ .timeline-event:focus-within::before {
1375
+ background: var(--icon-block);
1376
+ box-shadow: var(--box-shadow);
1377
+ transform: scale(1.2);
1378
+ }
1379
+
1380
+ .timeline-event > button {
1381
+ width: 100%;
1382
+ text-align: left;
1383
+ background: var(--aft-block);
1384
+ color: var(--fore-block);
1385
+ border-radius: 0.5rem;
1386
+ padding: 1.5rem;
1387
+ cursor: pointer;
1388
+ transition: all 0.3s ease;
1389
+ box-shadow: var(--box-shadow-unselected);
1390
+ }
1391
+
1392
+ .timeline-event.event-today > button {
1393
+ border: 1px solid var(--icon-block);
1394
+ background: var(--aft);
1395
+ }
1396
+
1397
+ .timeline-event.event-past > button {
1398
+ opacity: 0.8;
1399
+ background: var(--aft);
1400
+ color: var(--fore);
1401
+ box-shadow: none;
1402
+ }
1403
+
1404
+ .timeline-event > button:hover,
1405
+ .timeline-event > button:focus {
1406
+ outline: none;
1407
+ box-shadow: var(--box-shadow);
1408
+ transform: translateX(4px);
1409
+ }
1410
+
1411
+ .timeline time {
1412
+ display: block;
1413
+ font-size: var(--font-size-meta);
1414
+ margin-bottom: 0.5rem;
1415
+ }
1416
+
1417
+ .timeline-location {
1418
+ display: block;
1419
+ font-size: var(--font-size-meta);
1420
+ }
1421
+
1422
+ .timeline-location::before {
1423
+ content: '📍 ';
1424
+ }
1425
+
1426
+ .timeline-details {
1427
+ max-height: 0;
1428
+ overflow: hidden;
1429
+ opacity: 0;
1430
+ font-size: var(--font-size-meta);
1431
+ transition: max-height 0.2s ease, opacity 0.2s ease;
1432
+ }
1433
+
1434
+ .timeline-event:focus-within .timeline-details {
1435
+ max-height: 500px;
1436
+ opacity: 1;
1437
+ }
1438
+
1439
+ .timeline-event.event-past::before {
1440
+ box-shadow: var(--box-shadow-unselected);
1441
+ }
1442
+
1326
1443
  /* Animation */
1327
1444
 
1328
1445
  @media (prefers-reduced-motion: no-preference) {
package/public/js/main.js CHANGED
@@ -19,6 +19,7 @@ import { setExternalLinkAttributes } from './modules/external-links.js';
19
19
  import { monitorInputType } from './modules/input-type.js';
20
20
  import { enableSharing } from './modules/share.js';
21
21
  import { highlightCurrentHeading } from './modules/toc.js';
22
+ import { setTimelineEvents } from './modules/event-timeline.js';
22
23
 
23
24
  const resizedEventName = addResizedEvent();
24
25
 
@@ -36,6 +37,7 @@ addListImageIntersectionObserver('.post-list img');
36
37
  monitorInputType();
37
38
  enableSharing();
38
39
  highlightCurrentHeading('.page-toc a');
40
+ setTimelineEvents();
39
41
 
40
42
  // @ts-ignore
41
43
  const f = site_features ?? {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * This javascript file comes from Astro Accelerator
3
+ * Edits will be overwritten if you change the file locally
4
+ *
5
+ * @format
6
+ */
7
+
8
+ // @ts-check
9
+
10
+ import { qsa } from './query.js';
11
+
12
+ const dataAttributeName = 'data-timeline';
13
+
14
+ /**
15
+ * Adds a class to past events to handle styling.
16
+ *
17
+ */
18
+ function setTimelineEvents() {
19
+ const today = new Date();
20
+ today.setHours(0, 0, 0, 0);
21
+ const todayTimestamp = today.getTime();
22
+
23
+ qsa('[' + dataAttributeName + '] time').forEach((timeEl) => {
24
+ const eventDate = new Date(timeEl.getAttribute('datetime'));
25
+ eventDate.setHours(0, 0, 0, 0);
26
+ const eventTimestamp = eventDate.getTime();
27
+
28
+ console.log(todayTimestamp, eventTimestamp);
29
+
30
+ if (eventTimestamp === todayTimestamp) {
31
+ timeEl.closest('.timeline-event').classList.add('event-today');
32
+ } else if (eventTimestamp < todayTimestamp) {
33
+ timeEl.closest('.timeline-event').classList.add('event-past');
34
+ }
35
+ });
36
+ }
37
+
38
+ export { setTimelineEvents };
@@ -0,0 +1,39 @@
1
+ ---
2
+ import { SITE } from "@config";
3
+
4
+ interface Props {
5
+ date: string;
6
+ title: string;
7
+ location: string;
8
+ description: string;
9
+ linkHref: string;
10
+ linkText: string;
11
+ }
12
+
13
+ const { date, title, location, description, linkHref, linkText } = Astro.props;
14
+
15
+ const dateObj = new Date(date);
16
+ const displayDate = dateObj.toLocaleDateString(
17
+ SITE.default.locale,
18
+ SITE.dateOptions as any,
19
+ );
20
+ ---
21
+
22
+ <div class="timeline-event">
23
+ <button aria-expanded="false">
24
+ <time datetime={date}>{displayDate}</time>
25
+ <h3>{title}</h3>
26
+ <span class="timeline-location">{location}</span>
27
+
28
+ <div class="timeline-details">
29
+ <p>{description}</p>
30
+ {
31
+ linkHref && (
32
+ <a href={linkHref} class="button">
33
+ {linkText}
34
+ </a>
35
+ )
36
+ }
37
+ </div>
38
+ </button>
39
+ </div>