Skip to content

Commit 00ae1a8

Browse files
committed
Enhance citation functionality with improved copy button UI and accessibility features; update styles for better layout and responsiveness.
1 parent 00ddfd3 commit 00ae1a8

4 files changed

Lines changed: 83 additions & 16 deletions

File tree

css/components.css

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,8 @@
837837
color: var(--ink);
838838
font-family: var(--mono);
839839
margin: 0;
840-
overflow-x: auto;
841-
padding: 28px 30px;
840+
overflow: hidden;
841+
padding: 0;
842842
position: relative;
843843
}
844844

@@ -853,6 +853,12 @@
853853
background: #0b0d0b;
854854
}
855855

856+
.citation-scroll {
857+
overflow-x: auto;
858+
padding: 28px 74px 28px 30px;
859+
-webkit-overflow-scrolling: touch;
860+
}
861+
856862
.citation-container pre {
857863
background: transparent;
858864
border: 0;
@@ -905,20 +911,34 @@
905911
}
906912

907913
.citation-container .copy-btn {
914+
align-items: center;
908915
background: var(--accent);
909916
border: 1px solid var(--accent);
910917
color: #071008;
911918
cursor: pointer;
912-
font-family: var(--mono);
913-
font-size: 11px;
914-
font-weight: 800;
915-
letter-spacing: 0.1em;
916-
line-height: 1;
917-
padding: 12px 16px;
919+
display: inline-flex;
920+
height: 38px;
921+
justify-content: center;
922+
padding: 0;
918923
position: absolute;
919924
right: 16px;
920-
text-transform: uppercase;
921925
top: 16px;
926+
width: 38px;
927+
z-index: 2;
928+
}
929+
930+
.citation-container .copy-icon {
931+
fill: none;
932+
height: 18px;
933+
stroke: currentColor;
934+
stroke-linecap: round;
935+
stroke-linejoin: round;
936+
stroke-width: 2;
937+
width: 18px;
938+
}
939+
940+
.citation-container .copy-icon-check {
941+
display: none;
922942
}
923943

924944
.citation-container .copy-btn:hover,
@@ -939,6 +959,26 @@
939959
border-color: var(--success);
940960
}
941961

962+
.citation-container .copy-btn.copy-success .copy-icon-copy {
963+
display: none;
964+
}
965+
966+
.citation-container .copy-btn.copy-success .copy-icon-check {
967+
display: block;
968+
}
969+
970+
.sr-only {
971+
clip: rect(0 0 0 0);
972+
border: 0;
973+
height: 1px;
974+
margin: -1px;
975+
overflow: hidden;
976+
padding: 0;
977+
position: absolute;
978+
white-space: nowrap;
979+
width: 1px;
980+
}
981+
942982
.display-none {
943983
display: none !important;
944984
}
@@ -1049,11 +1089,17 @@
10491089
}
10501090

10511091
.citation-container {
1052-
padding: 68px 16px 20px;
1092+
padding: 0;
1093+
}
1094+
1095+
.citation-scroll {
1096+
padding: 58px 16px 20px;
10531097
}
10541098

10551099
.citation-container .copy-btn {
1100+
height: 34px;
10561101
right: 12px;
10571102
top: 12px;
1103+
width: 34px;
10581104
}
10591105
}

js/citation.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,22 @@ function fallbackCopy(text, btn) {
4343
}
4444

4545
function showCopySuccess(btn) {
46+
const status = btn.querySelector('.copy-status');
47+
4648
btn.classList.add('copy-success');
47-
btn.textContent = 'COPIED';
49+
btn.setAttribute('aria-label', 'Citation copied');
50+
btn.setAttribute('title', 'Citation copied');
51+
if (status) {
52+
status.textContent = 'Citation copied';
53+
}
4854

4955
setTimeout(function () {
5056
btn.classList.remove('copy-success');
51-
btn.textContent = 'COPY';
57+
btn.setAttribute('aria-label', 'Copy citation');
58+
btn.setAttribute('title', 'Copy citation');
59+
if (status) {
60+
status.textContent = 'Copy citation';
61+
}
5262
}, 2000);
5363
}
5464

templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<link rel="stylesheet" href="{{ asset_prefix }}css/core.css?v=6">
1616
<link rel="stylesheet" href="{{ asset_prefix }}css/layout.css?v=13">
17-
<link rel="stylesheet" href="{{ asset_prefix }}css/components.css?v=14">
17+
<link rel="stylesheet" href="{{ asset_prefix }}css/components.css?v=15">
1818
<link rel="stylesheet" href="{{ asset_prefix }}css/filters.css?v=3">
1919
<link rel="stylesheet" href="{{ asset_prefix }}css/sidebar.css?v=5">
2020

templates/pages/citations.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ <h2>{{ citation.heading }}</h2>
5555
id="{{ citation.id }}-citation-{{ format.id }}"
5656
data-citation-target="{{ citation.id }}-citation"
5757
data-format="{{ format.id }}">
58-
<button class="copy-btn" type="button">COPY</button>
59-
<pre><code class="language-{{ format.id }}">{{ format.text|highlight_citation(format.id)|safe }}</code></pre>
58+
<button class="copy-btn" type="button" aria-label="Copy citation" title="Copy citation">
59+
<svg class="copy-icon copy-icon-copy" aria-hidden="true" viewBox="0 0 24 24">
60+
<rect x="9" y="9" width="10" height="10" rx="1.5"></rect>
61+
<path d="M5 15V6.5A1.5 1.5 0 0 1 6.5 5H15"></path>
62+
</svg>
63+
<svg class="copy-icon copy-icon-check" aria-hidden="true" viewBox="0 0 24 24">
64+
<path d="M5 12.5 10 17l9-10"></path>
65+
</svg>
66+
<span class="sr-only copy-status" aria-live="polite">Copy citation</span>
67+
</button>
68+
<div class="citation-scroll">
69+
<pre><code class="language-{{ format.id }}">{{ format.text|highlight_citation(format.id)|safe }}</code></pre>
70+
</div>
6071
</div>
6172
{% endfor %}
6273
</section>
@@ -75,5 +86,5 @@ <h2>Citations unavailable</h2>
7586
{% endblock %}
7687

7788
{% block scripts_extra %}
78-
<script src="js/citation.js"></script>
89+
<script src="js/citation.js?v=2"></script>
7990
{% endblock %}

0 commit comments

Comments
 (0)