jekyll-vitepress-theme 1.5.1 → 1.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad8a4ce4f47e3398f3a5ae269c9b73f92a8fd3d839d155047b49077eb9e059fc
4
- data.tar.gz: d2a15ef74ab0a239fa279e605217ed15aa51758d7dced81056042e92d336d888
3
+ metadata.gz: 79221302839a221725323b51efb743c397689ea249a98db44131318666d2a1ef
4
+ data.tar.gz: 8c68b1f40dc553be74b86104683dab0a114f7a6399018e7e2de41cf32316f67e
5
5
  SHA512:
6
- metadata.gz: 974c285c0f2b78177f48b7bdf80101bf56c9c03b09f0559594313ce082cca9c62e9c0a77bfb30dc78cdd69e8f140645e97c483e11e1ff1d5caa83f97ece9a7d1
7
- data.tar.gz: e640143aceba69d634ef67715c443b3508aa59a201132fa8f9c125c4215c80a7fdf88c8052c542d7a3ffe63e8b3d484b7e5d49d98dd875df0f5fe4600e3b36bf
6
+ metadata.gz: aa2cc4902e2bb21d7a692ed183942740007f45a6bd669dac3bce4565fcb963194ae4bb0fe41a72fdd4c6a3bfe61fa95ee1c0d61d9ff82b958f51d81826052bfc
7
+ data.tar.gz: 223b905e9c6212a2d60042b4baf988068c5d3df8d927ee9fb05b3783c161d133fcfce13beb23e050a96e6f96d123418ee264e621babe3e7f794dcb4b170cf492
@@ -4,13 +4,13 @@
4
4
  {% endif %}
5
5
  <div class="copy-md-group">
6
6
  <button class="copy-md-btn" type="button" title="Copy page as Markdown">
7
- <span class="vpi-copy"></span>
8
- <span class="copy-md-label">Copy page</span>
7
+ <span class="vpi-copy copy-md-icon" aria-hidden="true"></span>
8
+ <span class="copy-md-label" aria-live="polite">Copy page</span>
9
9
  </button>
10
10
  <button class="copy-md-toggle" type="button" aria-label="More options" aria-expanded="false">
11
11
  <span class="vpi-chevron-down copy-md-chevron"></span>
12
12
  </button>
13
- <div class="copy-md-dropdown" hidden>
13
+ <div class="copy-md-dropdown vp-menu-transition" aria-hidden="true">
14
14
  <button class="copy-md-dropdown-item" type="button" data-action="copy">
15
15
  <span class="vpi-copy copy-md-dropdown-icon"></span>
16
16
  <div class="copy-md-dropdown-text">
data/_includes/nav.html CHANGED
@@ -144,7 +144,7 @@
144
144
  <button type="button" class="button" id="vp-nav-extra-button" aria-haspopup="true" aria-expanded="false" aria-controls="vp-nav-extra-menu" aria-label="extra navigation">
145
145
  <span class="vpi-more-horizontal icon" aria-hidden="true"></span>
146
146
  </button>
147
- <div class="menu" id="vp-nav-extra-menu" aria-hidden="true">
147
+ <div class="menu vp-menu-transition" id="vp-nav-extra-menu" aria-hidden="true">
148
148
  <div class="VPMenu">
149
149
  <div class="group">
150
150
  <div class="item appearance">
@@ -46,6 +46,23 @@ body.vp-nav-screen-open .VPNav {
46
46
  pointer-events: auto;
47
47
  }
48
48
 
49
+ .vp-menu-transition {
50
+ opacity: 0;
51
+ visibility: hidden;
52
+ transform: translateY(-4px);
53
+ pointer-events: none;
54
+ transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
55
+ }
56
+
57
+ .vp-menu-transition[aria-hidden="false"],
58
+ .VPNavBarExtra:hover > .vp-menu-transition,
59
+ .VPNavBarExtra.open > .vp-menu-transition {
60
+ opacity: 1;
61
+ visibility: visible;
62
+ transform: translateY(0);
63
+ pointer-events: auto;
64
+ }
65
+
49
66
  .VPNavBar > .wrapper > .container > .title,
50
67
  .VPNavBar > .wrapper > .container > .content > .content-body,
51
68
  .vp-doc div[class*='language-'],
@@ -394,16 +411,6 @@ body.vp-nav-screen-open .VPNav {
394
411
  top: calc(var(--vp-nav-height) / 2 + 20px);
395
412
  right: 0;
396
413
  z-index: calc(var(--vp-z-index-nav) + 1);
397
- opacity: 0;
398
- visibility: hidden;
399
- transform: translateY(0);
400
- transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
401
- }
402
-
403
- .VPNavBarExtra:hover .menu,
404
- .VPNavBarExtra.open .menu {
405
- opacity: 1;
406
- visibility: visible;
407
414
  }
408
415
 
409
416
  .VPNavBarExtra .VPMenu {
@@ -1117,6 +1124,10 @@ body.vp-search-open {
1117
1124
  font-variant-numeric: tabular-nums;
1118
1125
  }
1119
1126
 
1127
+ .VPButton.VPMetricButton .VPMetricButtonCount {
1128
+ color: inherit;
1129
+ }
1130
+
1120
1131
  .VPMetricButtonText[hidden],
1121
1132
  .VPMetricButtonCount[hidden] {
1122
1133
  display: none !important;
@@ -1927,8 +1938,7 @@ html.dark .only-light {
1927
1938
  }
1928
1939
 
1929
1940
  /* Copy as Markdown button group */
1930
- .vp-doc-header,
1931
- .vp-doc-title-row {
1941
+ .vp-doc-header {
1932
1942
  display: flex;
1933
1943
  align-items: center;
1934
1944
  justify-content: space-between;
@@ -1936,16 +1946,26 @@ html.dark .only-light {
1936
1946
  flex-wrap: wrap;
1937
1947
  }
1938
1948
 
1939
- .vp-doc-header h1,
1940
- .vp-doc-title-row h1 {
1949
+ .vp-doc-header:not(:has(> h1)) {
1950
+ position: relative;
1951
+ z-index: 1;
1952
+ float: right;
1953
+ justify-content: flex-end;
1954
+ margin: 0 0 16px 24px;
1955
+ }
1956
+
1957
+ .vp-doc-header h1 {
1941
1958
  margin-top: 0;
1942
1959
  margin-bottom: 0;
1943
1960
  flex: 1 1 320px;
1944
1961
  min-width: 0;
1945
1962
  }
1946
1963
 
1947
- .vp-doc-header .copy-md-group,
1948
- .vp-doc-title-row .copy-md-group {
1964
+ .vp-doc-header:not(:has(> h1)) .copy-md-group {
1965
+ margin-left: 0;
1966
+ }
1967
+
1968
+ .vp-doc-header .copy-md-group {
1949
1969
  margin-left: auto;
1950
1970
  }
1951
1971
 
@@ -1954,6 +1974,10 @@ html.dark .only-light {
1954
1974
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/g%3E%3C/svg%3E");
1955
1975
  }
1956
1976
 
1977
+ .vpi-check {
1978
+ --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m20 6l-11 11l-5-5'/%3E%3C/svg%3E");
1979
+ }
1980
+
1957
1981
  .vpi-file-text {
1958
1982
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cpolyline points='10 9 9 9 8 9'/%3E%3C/g%3E%3C/svg%3E");
1959
1983
  }
@@ -1967,11 +1991,12 @@ html.dark .only-light {
1967
1991
  border: 1px solid var(--vp-c-divider);
1968
1992
  border-radius: 6px;
1969
1993
  background: var(--vp-c-bg-soft);
1970
- transition: color 0.25s, border-color 0.25s, background-color 0.25s;
1994
+ transition: border-color 0.25s, background-color 0.25s;
1971
1995
  }
1972
1996
 
1973
1997
  .copy-md-group:hover {
1974
1998
  border-color: var(--vp-c-brand-1);
1999
+ background: var(--vp-c-bg-elv);
1975
2000
  }
1976
2001
 
1977
2002
  .copy-md-btn {
@@ -1990,7 +2015,7 @@ html.dark .only-light {
1990
2015
  white-space: nowrap;
1991
2016
  }
1992
2017
 
1993
- .copy-md-btn .vpi-copy {
2018
+ .copy-md-icon {
1994
2019
  width: 14px;
1995
2020
  height: 14px;
1996
2021
  }
@@ -2000,10 +2025,6 @@ html.dark .only-light {
2000
2025
  background: var(--vp-c-bg-elv);
2001
2026
  }
2002
2027
 
2003
- .copy-md-btn.copied {
2004
- color: var(--vp-c-green-1, #42b883);
2005
- }
2006
-
2007
2028
  .copy-md-toggle {
2008
2029
  display: inline-flex;
2009
2030
  align-items: center;
@@ -302,7 +302,8 @@
302
302
  return;
303
303
  }
304
304
 
305
- var formatted = formatGitHubStarCount(value);
305
+ var metricButton = button.classList.contains('VPMetricButton');
306
+ var formatted = metricButton ? formatExactCount(value) : formatGitHubStarCount(value);
306
307
  if (!formatted) {
307
308
  return;
308
309
  }
@@ -310,12 +311,11 @@
310
311
  countElement.textContent = formatted;
311
312
  countElement.hidden = false;
312
313
 
313
- if (button.classList.contains('VPMetricButton')) {
314
+ if (metricButton) {
314
315
  var repository = button.getAttribute('data-github-star-repo');
315
- var exactCount = formatExactCount(value);
316
- button.title = exactCount + ' GitHub stars';
316
+ button.title = formatted + ' GitHub stars';
317
317
  if (repository) {
318
- button.setAttribute('aria-label', 'Star ' + repository + ' on GitHub: ' + exactCount + ' stars');
318
+ button.setAttribute('aria-label', 'Star ' + repository + ' on GitHub: ' + formatted + ' stars');
319
319
  }
320
320
  }
321
321
  }
@@ -1403,35 +1403,6 @@
1403
1403
  return null;
1404
1404
  }
1405
1405
 
1406
- function alignCopyPageButtonWithHeading() {
1407
- var header = document.querySelector('.vp-doc-header');
1408
- var group = header && header.querySelector('.copy-md-group');
1409
- if (!header || !group || header.querySelector('h1')) {
1410
- return;
1411
- }
1412
-
1413
- var titleHeading = resolveCopyPageTitleHeading();
1414
- if (!titleHeading) {
1415
- return;
1416
- }
1417
-
1418
- var titleRow = titleHeading.closest('.vp-doc-title-row');
1419
- if (!titleRow) {
1420
- titleRow = document.createElement('div');
1421
- titleRow.className = 'vp-doc-title-row';
1422
- titleHeading.parentNode.insertBefore(titleRow, titleHeading);
1423
- titleRow.appendChild(titleHeading);
1424
- }
1425
-
1426
- titleRow.appendChild(group);
1427
-
1428
- if (!header.querySelector('*')) {
1429
- header.hidden = true;
1430
- }
1431
- }
1432
-
1433
- alignCopyPageButtonWithHeading();
1434
-
1435
1406
  function copyPageMarkdown(btn) {
1436
1407
  if (!btn) return;
1437
1408
 
@@ -1449,15 +1420,23 @@
1449
1420
  }
1450
1421
  }
1451
1422
 
1423
+ var icon = btn.querySelector('.copy-md-icon');
1452
1424
  var label = btn.querySelector('.copy-md-label');
1425
+ function setCopied(copied) {
1426
+ btn.classList.toggle('copied', copied);
1427
+ if (icon) {
1428
+ icon.classList.toggle('vpi-copy', !copied);
1429
+ icon.classList.toggle('vpi-check', copied);
1430
+ }
1431
+ if (label) label.textContent = copied ? 'Copied' : 'Copy page';
1432
+ }
1433
+
1453
1434
  writeToClipboard(md)
1454
1435
  .then(function () {
1455
- btn.classList.add('copied');
1456
- if (label) label.textContent = 'Copied';
1436
+ setCopied(true);
1457
1437
  if (btn._copyTimeout) window.clearTimeout(btn._copyTimeout);
1458
1438
  btn._copyTimeout = window.setTimeout(function () {
1459
- btn.classList.remove('copied');
1460
- if (label) label.textContent = 'Copy page';
1439
+ setCopied(false);
1461
1440
  }, 2000);
1462
1441
  })
1463
1442
  .catch(function () {});
@@ -1468,7 +1447,33 @@
1468
1447
  var dropdown = document.querySelector('.copy-md-dropdown');
1469
1448
  var dropdownCopy = dropdown ? dropdown.querySelector('[data-action="copy"]') : null;
1470
1449
 
1450
+ function setCopyPageDropdownOpen(open) {
1451
+ if (!dropdown || !toggle) {
1452
+ return;
1453
+ }
1454
+
1455
+ if (dropdown.hidden) {
1456
+ dropdown.hidden = false;
1457
+ }
1458
+
1459
+ dropdown.setAttribute('aria-hidden', String(!open));
1460
+ toggle.setAttribute('aria-expanded', String(open));
1461
+ }
1462
+
1463
+ function isCopyPageDropdownOpen() {
1464
+ return !!(dropdown && dropdown.getAttribute('aria-hidden') === 'false');
1465
+ }
1466
+
1471
1467
  function bindCopyPageControls() {
1468
+ if (dropdown) {
1469
+ if (dropdown.hidden) {
1470
+ dropdown.hidden = false;
1471
+ }
1472
+ if (!dropdown.hasAttribute('aria-hidden')) {
1473
+ dropdown.setAttribute('aria-hidden', 'true');
1474
+ }
1475
+ }
1476
+
1472
1477
  if (copyMdBtn && !copyMdBtn.hasAttribute('data-vp-bound')) {
1473
1478
  copyMdBtn.setAttribute('data-vp-bound', 'true');
1474
1479
  copyMdBtn.addEventListener('click', function () {
@@ -1480,9 +1485,7 @@
1480
1485
  toggle.setAttribute('data-vp-bound', 'true');
1481
1486
  toggle.addEventListener('click', function (e) {
1482
1487
  e.stopPropagation();
1483
- var open = !dropdown.hidden;
1484
- dropdown.hidden = !dropdown.hidden;
1485
- toggle.setAttribute('aria-expanded', String(!open));
1488
+ setCopyPageDropdownOpen(!isCopyPageDropdownOpen());
1486
1489
  });
1487
1490
  }
1488
1491
 
@@ -1490,10 +1493,7 @@
1490
1493
  if (dropdownCopy && !dropdownCopy.hasAttribute('data-vp-bound')) {
1491
1494
  dropdownCopy.setAttribute('data-vp-bound', 'true');
1492
1495
  dropdownCopy.addEventListener('click', function () {
1493
- dropdown.hidden = true;
1494
- if (toggle) {
1495
- toggle.setAttribute('aria-expanded', 'false');
1496
- }
1496
+ setCopyPageDropdownOpen(false);
1497
1497
  copyPageMarkdown(copyMdBtn);
1498
1498
  });
1499
1499
  }
@@ -1502,19 +1502,17 @@
1502
1502
  bindCopyPageControls();
1503
1503
 
1504
1504
  document.addEventListener('click', function (e) {
1505
- if (!dropdown || !toggle || dropdown.hidden) {
1505
+ if (!dropdown || !toggle || !isCopyPageDropdownOpen()) {
1506
1506
  return;
1507
1507
  }
1508
1508
  if (!dropdown.contains(e.target) && !toggle.contains(e.target)) {
1509
- dropdown.hidden = true;
1510
- toggle.setAttribute('aria-expanded', 'false');
1509
+ setCopyPageDropdownOpen(false);
1511
1510
  }
1512
1511
  });
1513
1512
 
1514
1513
  document.addEventListener('keydown', function (e) {
1515
- if (e.key === 'Escape' && dropdown && toggle && !dropdown.hidden) {
1516
- dropdown.hidden = true;
1517
- toggle.setAttribute('aria-expanded', 'false');
1514
+ if (e.key === 'Escape' && dropdown && toggle && isCopyPageDropdownOpen()) {
1515
+ setCopyPageDropdownOpen(false);
1518
1516
  toggle.focus();
1519
1517
  }
1520
1518
  });
@@ -2256,7 +2254,6 @@
2256
2254
  bindCopyPageControls();
2257
2255
 
2258
2256
  addCopyButtons();
2259
- alignCopyPageButtonWithHeading();
2260
2257
  enhanceDocFrameLinks();
2261
2258
 
2262
2259
  content = document.querySelector('.vp-doc');
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module VitePressTheme
3
- VERSION = "1.5.1".freeze
3
+ VERSION = "1.5.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-vitepress-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carmine Paolino