Skip to content

Commit 06a3c9a

Browse files
Use full-width course layout and visible copy controls
1 parent 9b53b74 commit 06a3c9a

3 files changed

Lines changed: 132 additions & 10 deletions

File tree

_config.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ aux_links_new_tab: true
3232
footer_content: "Python Basic · Learn slowly, practise often, build confidently."
3333
last_edit_timestamp: false
3434

35-
gh_edit_link: true
36-
gh_edit_link_text: Edit this page on GitHub
37-
gh_edit_repository: https://github.com/iBalajiShanmugam/python-basic
38-
gh_edit_branch: main
39-
gh_edit_view_mode: edit
35+
gh_edit_link: false
4036

4137
plugins:
4238
- jekyll-relative-links

_sass/custom/custom.scss

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
--course-purple: #6941c6;
1111
--course-purple-soft: #f4f3ff;
1212
--course-line: #e4e7ec;
13+
--course-page-gutter: clamp(1.5rem, 3vw, 3.5rem);
1314
}
1415

1516
body {
@@ -19,15 +20,20 @@ body {
1920
}
2021

2122
.site-header {
22-
min-height: 76px;
23+
height: 84px;
24+
min-height: 84px;
2325
border-bottom-color: var(--course-line);
26+
box-sizing: border-box;
2427
}
2528

2629
.site-title {
2730
position: relative;
2831
display: flex;
2932
align-items: center;
30-
min-height: 76px;
33+
height: 84px;
34+
min-height: 84px;
35+
padding-top: 0;
36+
padding-bottom: 0;
3137
padding-left: 54px;
3238
color: #101828;
3339
font-size: 1.05rem !important;
@@ -127,7 +133,7 @@ body {
127133

128134
.main-content div.highlight pre.highlight {
129135
margin: 0;
130-
padding: 1rem 1.15rem;
136+
padding: 1rem 6.25rem 1rem 1.15rem;
131137
overflow: visible;
132138
background: transparent;
133139
border: 0;
@@ -147,6 +153,60 @@ body {
147153
white-space: pre;
148154
}
149155

156+
.main-content div.highlighter-rouge {
157+
position: relative;
158+
margin: 1.1rem 0;
159+
overflow: visible;
160+
background: transparent;
161+
}
162+
163+
.main-content div.highlighter-rouge div.highlight {
164+
margin: 0;
165+
}
166+
167+
.main-content div.highlighter-rouge > button {
168+
z-index: 3;
169+
top: 0.65rem;
170+
right: 0.65rem;
171+
display: inline-flex;
172+
gap: 0.35rem;
173+
align-items: center;
174+
width: auto;
175+
min-width: 4.4rem;
176+
padding: 0.42rem 0.6rem;
177+
color: #e2e8f0;
178+
background: #1e293b;
179+
border: 1px solid #475569;
180+
border-radius: 7px;
181+
box-sizing: border-box;
182+
opacity: 1;
183+
}
184+
185+
.main-content div.highlighter-rouge > button:hover {
186+
color: #ffffff;
187+
background: #334155;
188+
cursor: pointer;
189+
}
190+
191+
.main-content div.highlighter-rouge > button:focus {
192+
outline: 3px solid #93c5fd;
193+
outline-offset: 2px;
194+
opacity: 1;
195+
}
196+
197+
.main-content div.highlighter-rouge > button svg {
198+
width: 1rem;
199+
height: 1rem;
200+
fill: currentColor;
201+
}
202+
203+
.copy-button-label {
204+
color: inherit;
205+
font-size: 0.72rem;
206+
font-weight: 750;
207+
line-height: 1;
208+
}
209+
150210
// Rouge syntax colors chosen for the dark code surface.
151211
.main-content .highlight .c,
152212
.main-content .highlight .c1,
@@ -179,6 +239,18 @@ body {
179239
color: #ffa657;
180240
}
181241

242+
.main-content .highlight .n {
243+
color: #d2a8ff;
244+
}
245+
246+
.main-content .highlight .p {
247+
color: #c9d1d9;
248+
}
249+
250+
.main-content .highlight .sh {
251+
color: #a5d6ff;
252+
}
253+
182254
.main-content blockquote {
183255
position: relative;
184256
margin: 1.5rem 0;
@@ -389,8 +461,9 @@ body {
389461
align-items: center;
390462
justify-content: space-between;
391463
width: 100%;
392-
min-height: 45px;
393-
padding: 7px 0;
464+
min-height: 84px;
465+
padding: 12px 0 12px var(--course-page-gutter);
466+
box-sizing: border-box;
394467
}
395468

396469
.lesson-status > div {
@@ -526,6 +599,40 @@ body {
526599
background: linear-gradient(90deg, var(--course-blue), var(--course-yellow));
527600
}
528601

602+
@media (min-width: 50rem) {
603+
.side-bar {
604+
width: 17rem;
605+
min-width: 17rem;
606+
align-items: stretch;
607+
}
608+
609+
.side-bar + .main {
610+
max-width: none;
611+
margin-right: 0;
612+
margin-left: 17rem;
613+
}
614+
615+
.site-nav,
616+
.site-header,
617+
.site-footer {
618+
width: 100%;
619+
}
620+
621+
.main-header {
622+
height: 84px;
623+
min-height: 84px;
624+
}
625+
626+
.main-content-wrap {
627+
padding-right: var(--course-page-gutter);
628+
padding-left: var(--course-page-gutter);
629+
}
630+
631+
.main-content {
632+
max-width: none;
633+
}
634+
}
635+
529636
@media (max-width: 800px) {
530637
.feature-grid {
531638
grid-template-columns: 1fr;

assets/js/course.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,28 @@
100100
if (navigation && lesson) lesson.append(navigation);
101101
}
102102

103+
function enhanceCopyButtons() {
104+
document.querySelectorAll("div.highlighter-rouge > button").forEach((button) => {
105+
if (button.querySelector(".copy-button-label")) return;
106+
107+
const label = document.createElement("span");
108+
label.className = "copy-button-label";
109+
label.textContent = "Copy";
110+
button.append(label);
111+
112+
button.addEventListener("click", () => {
113+
label.textContent = "Copied";
114+
window.setTimeout(() => {
115+
label.textContent = "Copy";
116+
}, 4000);
117+
});
118+
});
119+
}
120+
103121
document.addEventListener("DOMContentLoaded", () => {
104122
classifyDetails();
105123
placeLessonNavigation();
124+
window.requestAnimationFrame(enhanceCopyButtons);
106125
setupCompletion();
107126
setupReadingProgress();
108127
updateProgress();

0 commit comments

Comments
 (0)