Skip to content

Commit 9583776

Browse files
authored
Merge pull request #12 from python-chile/feat/personalize-stations
Feat/personalize stations
2 parents d166343 + dd6b893 commit 9583776

38 files changed

Lines changed: 2502 additions & 581 deletions
42.6 KB
Loading

‎src/components/auth/GitHubAuth.astro‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,28 @@ const accountHref = withBase("/cuenta");
2727
<a
2828
hidden
2929
href={accountHref}
30-
class="text-ink hover:border-accent hover:text-brand focus-visible:outline-brand inline-flex items-center gap-2 border-b-2 border-transparent px-1 py-1.5 font-mono text-xs font-bold transition-colors focus-visible:outline-2 focus-visible:outline-offset-2"
30+
class="group focus-visible:outline-brand inline-flex items-center gap-2.5 rounded-md px-1 py-2 focus-visible:outline-2 focus-visible:outline-offset-4"
3131
data-github-account
3232
>
3333
<img
3434
src=""
3535
alt=""
36-
width="28"
37-
height="28"
38-
class="border-ink/10 size-7 rounded-full border object-cover"
36+
width="32"
37+
height="32"
38+
class="border-ink/10 size-8 rounded-full border object-cover transition-transform duration-200 motion-safe:group-hover:scale-105"
3939
data-github-avatar
4040
/>
4141

42-
<span class="hidden max-w-28 truncate sm:block" data-github-name></span>
42+
<span class="relative hidden pb-1 sm:block">
43+
<span
44+
class="text-ink group-hover:text-brand block max-w-28 truncate text-sm font-bold transition-colors"
45+
data-github-name></span>
4346

44-
<span aria-hidden="true" class="text-brand">→</span>
47+
<span
48+
aria-hidden="true"
49+
class="bg-accent absolute right-0 bottom-0 left-0 h-0.5 origin-left scale-x-0 rounded-full transition-transform duration-300 group-hover:scale-x-100"
50+
></span>
51+
</span>
4552
</a>
4653

4754
<script>
Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,12 @@
11
---
22
import GitHubAuth from "@/components/auth/GitHubAuth.astro";
3-
import { withBase } from "@/lib/paths";
4-
5-
const homeUrl = withBase("/");
6-
const logoUrl = withBase("/brand/pythonchile.png");
3+
import PythonChileBrand from "@/components/ui/PythonChileBrand.astro";
74
---
85

96
<header class="relative z-30 flex items-center justify-between py-5">
10-
<a
11-
href={homeUrl}
12-
aria-label="Ir al inicio de PySchool"
13-
class="logo-link focus-visible:outline-brand inline-flex focus-visible:outline-2 focus-visible:outline-offset-4"
14-
>
15-
<img
16-
src={logoUrl}
17-
alt="Python Chile"
18-
width="1920"
19-
height="611"
20-
decoding="async"
21-
class="h-9 w-auto object-contain sm:h-10"
22-
/>
23-
</a>
7+
<PythonChileBrand />
248

259
<div class="relative pt-3">
2610
<GitHubAuth />
2711
</div>
28-
29-
<style>
30-
.logo-link {
31-
transition: transform 250ms cubic-bezier(0.34, 1.4, 0.64, 1);
32-
}
33-
34-
.logo-underline path {
35-
fill: none;
36-
stroke: var(--color-brand);
37-
stroke-width: 2;
38-
stroke-linecap: round;
39-
stroke-dasharray: 180;
40-
stroke-dashoffset: 180;
41-
transition: stroke-dashoffset 400ms ease;
42-
}
43-
44-
.logo-link:hover,
45-
.logo-link:focus-visible {
46-
transform: scale(1.04) rotate(-1deg);
47-
}
48-
49-
.logo-link:hover .logo-underline path,
50-
.logo-link:focus-visible .logo-underline path {
51-
stroke-dashoffset: 0;
52-
}
53-
54-
@media (prefers-reduced-motion: reduce) {
55-
.logo-link,
56-
.logo-underline path {
57-
transition: none;
58-
}
59-
}
60-
</style>
6112
</header>

‎src/components/station/content/CodeBlocks.astro‎

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<style is:global>
22
.station-content pre:not([data-python-output]) {
33
position: relative;
4+
width: 100%;
5+
max-width: 100%;
6+
min-width: 0;
47
margin-top: 1.5rem;
58
overflow: hidden;
69
border: 1px solid rgb(16 29 39 / 18%);
@@ -10,42 +13,68 @@
1013

1114
.station-content pre:not([data-python-output]) .code-header {
1215
display: flex;
16+
min-width: 0;
1317
align-items: center;
1418
justify-content: space-between;
19+
gap: 1rem;
1520
min-height: 2.5rem;
1621
padding: 0.4rem 0.75rem;
1722
border-bottom: 1px solid rgb(16 29 39 / 10%);
1823
background: var(--color-paper);
1924
}
2025

2126
.station-content pre:not([data-python-output]) .code-lang {
27+
overflow: hidden;
28+
color: var(--color-brand);
2229
font-family: var(--font-mono);
2330
font-size: 0.65rem;
2431
font-weight: 700;
2532
letter-spacing: 0.12em;
26-
color: var(--color-brand);
33+
text-overflow: ellipsis;
2734
text-transform: uppercase;
35+
white-space: nowrap;
2836
}
2937

3038
.station-content pre:not([data-python-output]) code {
3139
display: block;
32-
min-width: max-content;
40+
width: 100%;
41+
max-width: 100%;
42+
min-width: 0;
3343
overflow-x: auto;
3444
padding: 1rem 1.1rem;
3545
background: transparent !important;
3646
font-family: var(--font-mono);
3747
font-size: 0.9rem;
3848
line-height: 1.8;
49+
white-space: pre;
50+
overscroll-behavior-x: contain;
51+
scrollbar-width: thin;
52+
-webkit-overflow-scrolling: touch;
53+
}
54+
55+
.station-content pre:not([data-python-output]) code::-webkit-scrollbar {
56+
height: 0.45rem;
57+
}
58+
59+
.station-content pre:not([data-python-output]) code::-webkit-scrollbar-track {
60+
background: transparent;
61+
}
62+
63+
.station-content pre:not([data-python-output]) code::-webkit-scrollbar-thumb {
64+
border-radius: 999px;
65+
background: rgb(100 116 139 / 35%);
3966
}
4067

4168
.station-content :not(pre) > code {
69+
max-width: 100%;
4270
border-bottom: 2px solid var(--color-accent);
4371
background: #edf4ff;
4472
padding: 0.1rem 0.3rem;
4573
color: var(--color-ink);
4674
font-family: var(--font-mono);
4775
font-size: 0.9em;
4876
font-weight: 600;
77+
overflow-wrap: anywhere;
4978
}
5079

5180
.station-content pre:not([data-python-output]) + p,
@@ -59,6 +88,7 @@
5988
display: grid;
6089
width: 1.75rem;
6190
height: 1.75rem;
91+
flex-shrink: 0;
6292
place-items: center;
6393
border: 1px solid rgb(16 29 39 / 15%);
6494
border-radius: 0.35rem;
@@ -115,6 +145,30 @@
115145
opacity: 1;
116146
transform: scale(1);
117147
}
148+
149+
@media (max-width: 39.999rem) {
150+
.station-content pre:not([data-python-output]) {
151+
border-radius: 0.4rem;
152+
}
153+
154+
.station-content pre:not([data-python-output]) code {
155+
padding: 0.9rem;
156+
font-size: 0.8rem;
157+
line-height: 1.7;
158+
}
159+
160+
.station-content pre:not([data-python-output]) .code-header {
161+
padding-right: 0.6rem;
162+
padding-left: 0.6rem;
163+
}
164+
}
165+
166+
@media (prefers-reduced-motion: reduce) {
167+
.copy-btn,
168+
.copy-btn svg {
169+
transition: none;
170+
}
171+
}
118172
</style>
119173

120174
<script>
@@ -149,32 +203,68 @@
149203
header.className = "code-header";
150204

151205
const languageLabel = document.createElement("span");
206+
152207
languageLabel.className = "code-lang";
153208
languageLabel.textContent = language;
154209

155210
const copyButton = document.createElement("button");
211+
156212
copyButton.type = "button";
157213
copyButton.className = "copy-btn";
214+
158215
copyButton.setAttribute("aria-label", "Copiar código");
216+
159217
copyButton.setAttribute("title", "Copiar código");
218+
160219
copyButton.innerHTML = `
161-
<svg class="icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
162-
<rect x="9" y="9" width="12" height="12" rx="2"></rect>
163-
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
220+
<svg
221+
class="icon"
222+
aria-hidden="true"
223+
viewBox="0 0 24 24"
224+
fill="none"
225+
stroke-width="2"
226+
stroke-linecap="round"
227+
stroke-linejoin="round"
228+
>
229+
<rect
230+
x="9"
231+
y="9"
232+
width="12"
233+
height="12"
234+
rx="2"
235+
></rect>
236+
237+
<path
238+
d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
239+
></path>
164240
</svg>
165-
<svg class="check" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
166-
<polyline points="20 6 9 17 4 12"></polyline>
241+
242+
<svg
243+
class="check"
244+
aria-hidden="true"
245+
viewBox="0 0 24 24"
246+
fill="none"
247+
stroke-width="2.5"
248+
stroke-linecap="round"
249+
stroke-linejoin="round"
250+
>
251+
<polyline
252+
points="20 6 9 17 4 12"
253+
></polyline>
167254
</svg>
168255
`;
169256

170257
copyButton.addEventListener("click", async () => {
171258
try {
172259
await copyText(code.textContent ?? "");
260+
173261
copyButton.classList.add("is-copied");
262+
174263
copyButton.setAttribute("aria-label", "Código copiado");
175264

176265
window.setTimeout(() => {
177266
copyButton.classList.remove("is-copied");
267+
178268
copyButton.setAttribute("aria-label", "Copiar código");
179269
}, 1_400);
180270
} catch {
@@ -191,5 +281,6 @@
191281
}
192282

193283
setupCodeBlocks();
284+
194285
document.addEventListener("astro:page-load", setupCodeBlocks);
195286
</script>

‎src/components/station/content/Disclosure.astro‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,37 @@ interface Props {
66
const { title } = Astro.props;
77
---
88

9-
<details class="group relative" data-station-hint>
9+
<details
10+
class="group border-line-soft overflow-hidden border bg-white"
11+
data-station-hint
12+
>
1013
<summary
11-
class="text-muted hover:bg-accent/25 hover:text-ink flex h-10 cursor-pointer list-none items-center gap-2 px-3 font-mono text-xs font-bold tracking-widest uppercase transition-colors"
14+
class="text-muted hover:bg-accent/20 hover:text-ink flex min-h-12 cursor-pointer list-none items-center gap-2 px-4 font-mono text-xs font-bold tracking-widest uppercase transition-colors"
1215
>
13-
<span class="text-brand" aria-hidden="true">✦</span>
16+
<span class="text-brand" aria-hidden="true"> ✦ </span>
1417

15-
{title}
18+
<span>{title}</span>
1619

1720
<span
18-
class="ml-1 text-base font-normal transition-transform group-open:rotate-45"
21+
class="ml-auto text-base font-normal transition-transform group-open:rotate-45"
1922
aria-hidden="true"
2023
>
2124
+
2225
</span>
2326
</summary>
2427

2528
<div
26-
class="border-ink/20 text-muted shadow-action absolute bottom-full left-0 z-20 mb-3 w-64 border bg-white p-4 text-base leading-7 sm:w-80"
29+
class="hint-content border-line-soft text-muted border-t px-4 py-4 text-sm leading-7"
30+
data-station-hint-content
2731
>
2832
<slot />
2933
</div>
3034
</details>
35+
36+
<style>
37+
.hint-content[data-embedded="true"] {
38+
padding: 0;
39+
border: 0;
40+
background: transparent;
41+
}
42+
</style>

0 commit comments

Comments
 (0)