Skip to content

Commit da52861

Browse files
committed
docs: increase text contrast and refactor js tabs functions
1 parent 9b2896e commit da52861

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

docs/_sass/custom/custom.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ h2,
3434
h3,
3535
h4,
3636
h5,
37-
h6,
38-
h7 {
37+
h6 {
3938
font-family: 'Source Serif Pro', serif !important;
4039
color: #002676 !important;
4140
line-height: 1.15;
@@ -69,13 +68,13 @@ aside {
6968

7069
&:hover {
7170
background-color: rgba(0, 38, 118, 0.05);
72-
color: #C41230;
71+
color: #941120;
7372
text-decoration: none;
7473
}
7574

7675
&.active {
7776
font-weight: 600;
78-
color: #C41230;
77+
color: #941120;
7978
background-color: rgba(196, 18, 48, 0.03);
8079
}
8180
}
@@ -177,10 +176,10 @@ pre code {
177176
.note {
178177
background-color: rgba(0, 123, 192, 0.05);
179178
border-left-color: #007BC0;
180-
color: #007BC0;
179+
color: #005F95;
181180

182181
>p:first-child strong:first-child {
183-
color: #007BC0;
182+
color: #005F95;
184183
}
185184
}
186185

@@ -201,10 +200,11 @@ pre code {
201200
color: #941120;
202201

203202
>p:first-child strong:first-child {
204-
color: #C41230;
203+
color: #941120;
205204
}
206205
}
207206

207+
208208
.tip {
209209
background-color: rgba(54, 143, 51, 0.05);
210210
border-left-color: #368f33;

docs/_sass/custom/tabs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
transition: all 0.2s ease;
2424

2525
&:hover {
26-
color: #007BC0;
26+
color: #005F95;
2727
background-color: rgba(0, 123, 192, 0.05);
2828
}
2929

docs/assets/js/tabs.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
// Simple Tab Switching Logic
2-
document.addEventListener('DOMContentLoaded', function () {
3-
const tabContainers = document.querySelectorAll('.code-tabs');
2+
function activateTab(clickedButton, container) {
3+
const buttons = container.querySelectorAll('.tab-header button');
4+
const contents = container.querySelectorAll('.tab-content');
45

5-
tabContainers.forEach(container => {
6-
const headers = container.querySelector('.tab-header');
7-
const buttons = headers.querySelectorAll('button');
8-
const contents = container.querySelectorAll('.tab-content');
6+
// Deactivate all
7+
buttons.forEach(btn => btn.classList.remove('active'));
8+
contents.forEach(content => content.classList.remove('active'));
99

10-
buttons.forEach(button => {
11-
button.addEventListener('click', () => {
12-
buttons.forEach(btn => btn.classList.remove('active'));
13-
contents.forEach(content => content.classList.remove('active'));
10+
// Activate clicked button
11+
clickedButton.classList.add('active');
1412

15-
button.classList.add('active');
13+
// Activate corresponding content
14+
const tabId = clickedButton.getAttribute('data-tab');
15+
const content = container.querySelector(`.tab-content[data-tab="${tabId}"]`);
16+
if (content) {
17+
content.classList.add('active');
18+
}
19+
}
1620

17-
const tabId = button.getAttribute('data-tab');
18-
const content = container.querySelector(`.tab-content[data-tab="${tabId}"]`);
19-
if (content) {
20-
content.classList.add('active');
21-
}
22-
});
23-
});
21+
function initTabContainer(container) {
22+
const buttons = container.querySelectorAll('.tab-header button');
23+
buttons.forEach(button => {
24+
button.addEventListener('click', () => activateTab(button, container));
2425
});
26+
}
27+
28+
document.addEventListener('DOMContentLoaded', () => {
29+
const tabContainers = document.querySelectorAll('.code-tabs');
30+
tabContainers.forEach(initTabContainer);
2531
});

0 commit comments

Comments
 (0)