Skip to content

Commit 88ac017

Browse files
authored
rename styles, close with escape (#621)
1 parent ab45dc3 commit 88ac017

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

src/routes/tutorial/[slug]/Menu.svelte

+39-35
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
$: expanded_chapter = current.chapter.slug;
2424
</script>
2525

26+
<svelte:window on:keydown={(e) => e.key === 'Escape' && (is_open = false)} />
27+
2628
<div
2729
class="container"
2830
class:dark={$theme.current === 'dark'}
@@ -38,35 +40,33 @@
3840
<Icon name="arrow-left" size={16} />
3941
</a>
4042

41-
<button
42-
class="heading"
43-
on:click={() => ($is_mobile ? open_nav() : (is_open = !is_open))}
44-
class:open={is_open}
45-
>
46-
<h1>
47-
<div class="mobile">
48-
<div class="heading-row">
49-
<strong>{current.title}</strong>
50-
</div>
51-
<div class="heading-row">
52-
<span class="part-title">{current.part.label}</span>
53-
<span class="separator">/</span>
54-
<span class="chapter-title">{current.chapter.title}</span>
43+
<div class="menu" class:open={is_open}>
44+
<button on:click={() => ($is_mobile ? open_nav() : (is_open = !is_open))}>
45+
<h1>
46+
<div class="mobile">
47+
<div class="heading-row">
48+
<strong>{current.title}</strong>
49+
</div>
50+
<div class="heading-row">
51+
<span class="part-title">{current.part.label}</span>
52+
<span class="separator">/</span>
53+
<span class="chapter-title">{current.chapter.title}</span>
54+
</div>
5555
</div>
56-
</div>
5756

58-
<div class="desktop">
59-
<span class="part-title">{current.part.title}</span><span class="separator">/</span>
60-
<span class="chapter-title">{current.chapter.title}</span><span class="separator">/</span
61-
><strong>{current.title}</strong>
62-
</div>
57+
<div class="desktop">
58+
<span class="part-title">{current.part.title}</span><span class="separator">/</span>
59+
<span class="chapter-title">{current.chapter.title}</span><span class="separator">/</span
60+
><strong>{current.title}</strong>
61+
</div>
6362

64-
<span style="flex: 1 1 auto"></span>
65-
</h1>
63+
<span style="flex: 1 1 auto"></span>
64+
</h1>
6665

67-
<span class="expand-icon" class:inverted={is_open}>
68-
<Icon name="chevron-down" />
69-
</span>
66+
<span class="expand-icon" class:inverted={is_open}>
67+
<Icon name="chevron-down" />
68+
</span>
69+
</button>
7070

7171
{#if is_open}
7272
<nav
@@ -140,7 +140,7 @@
140140
</div>
141141
</nav>
142142
{/if}
143-
</button>
143+
</div>
144144

145145
<a
146146
class="next-button"
@@ -191,7 +191,7 @@
191191
width: 100%;
192192
}
193193
194-
.heading.open {
194+
.menu.open {
195195
border-radius: var(--sk-border-radius) var(--sk-border-radius) 0 0;
196196
}
197197
@@ -200,7 +200,7 @@
200200
font-size: var(--sk-text-xs);
201201
}
202202
203-
.heading {
203+
.menu {
204204
font-size: var(--sk-text-s);
205205
border: none;
206206
}
@@ -209,16 +209,11 @@
209209
color: var(--sk-theme-1);
210210
}
211211
212-
.heading {
212+
.menu {
213213
flex: 1;
214214
215215
position: relative;
216216
217-
display: flex;
218-
justify-content: center;
219-
align-items: center;
220-
gap: 0.4ch;
221-
222217
top: 0.15rem;
223218
height: 100%;
224219
min-width: 0;
@@ -238,6 +233,15 @@
238233
cursor: pointer;
239234
}
240235
236+
.menu > button {
237+
display: flex;
238+
justify-content: center;
239+
align-items: center;
240+
gap: 0.4ch;
241+
width: 100%;
242+
height: 100%;
243+
}
244+
241245
h1 {
242246
display: flex;
243247
@@ -414,7 +418,7 @@
414418
}
415419
416420
/* Remove all styles */
417-
.heading {
421+
.menu {
418422
box-shadow: none;
419423
background-color: transparent;
420424

0 commit comments

Comments
 (0)