Skip to content

Commit 8dcc4ab

Browse files
authored
More design tweaks (sveltejs#62)
* some WIP tweaks * selected file indicator * better fix
1 parent ce9156f commit 8dcc4ab

File tree

12 files changed

+111
-57
lines changed

12 files changed

+111
-57
lines changed

content/tutorial/03-advanced-svelte/05-bindings/06-component-bindings/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ title: Component bindings
55
Just as you can bind to properties of DOM elements, you can bind to component props. For example, we can bind to the `value` prop of this `<Keypad>` component as though it were a form element:
66

77
```svelte
8-
<Keypad bind:value={pin} on:submit={handleSubmit}/>
8+
<Keypad
9+
+++bind:value={pin}+++
10+
on:submit={handleSubmit}
11+
/>
912
```
1013

1114
Now, when the user interacts with the keypad, the value of `pin` in the parent component is immediately updated.

src/app.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ body {
66
/* --font-mono: Menlo, Monaco, 'Courier New', monospace; */
77
--font-mono: 'Roboto Mono', monospace;
88
--h4: 1.6rem;
9+
10+
--light-blue: #f4f8fb;
11+
}
12+
13+
input,
14+
button {
15+
border: 2px solid transparent;
16+
}
17+
18+
input:focus-visible,
19+
button:focus-visible {
20+
outline: none;
21+
border: 2px solid var(--flash);
922
}
1023

1124
/* this is duplicated with kit.svelte.dev */

src/lib/components/SplitPane.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
if (min_px < 0) min_px += size;
3636
if (max_px < 0) max_px += size;
3737
38-
pos_px = priority === 'min'
39-
? Math.max(min_px, Math.min(max_px, pos_px))
40-
: Math.min(max_px, Math.max(min_px, pos_px));
38+
pos_px =
39+
priority === 'min'
40+
? Math.max(min_px, Math.min(max_px, pos_px))
41+
: Math.min(max_px, Math.max(min_px, pos_px));
4142
4243
pos = pos.endsWith('%') ? `${(100 * pos_px) / size}%` : `${pos_px}px`;
4344
}
@@ -156,7 +157,8 @@
156157
<style>
157158
.container {
158159
--sp-thickness: var(--thickness, 8px);
159-
--sp-color: var(--color, #eee);
160+
/* --sp-color: var(--color, #eee); */
161+
--sp-color: transparent;
160162
display: grid;
161163
position: relative;
162164
width: 100%;

src/routes/tutorial/[slug]/_/Chrome.svelte

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
width: 100%;
2828
height: 4rem;
2929
display: flex;
30-
gap: 0.5rem;
31-
padding: 0.4rem;
3230
background: #f9f9f9;
31+
border-top: 1px solid var(--border-color);
3332
}
3433
3534
.chrome button {
36-
padding: 0.5rem;
35+
padding: 0.8rem;
36+
box-sizing: border-box;
37+
background: #f3f3f3;
3738
}
3839
3940
.chrome button img {
@@ -51,10 +52,19 @@
5152
.chrome input {
5253
flex: 1;
5354
padding: 0.5rem 1rem 0.4rem 1rem;
54-
border-radius: 0.5rem;
55-
border: 1px solid rgba(0, 0, 0, 0.1);
56-
box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.1);
55+
background-color: #fbfbfb;
5756
font-family: inherit;
5857
font-size: 1.6rem;
5958
}
59+
60+
.chrome button,
61+
.chrome input {
62+
border: 2px solid transparent;
63+
}
64+
65+
.chrome button:focus-visible,
66+
.chrome input:focus-visible {
67+
outline: none;
68+
border: 2px solid var(--flash);
69+
}
6070
</style>

src/routes/tutorial/[slug]/_/Editor.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
{ token: 'keyword', foreground: '0b69a8' }
4444
],
4545
colors: {
46+
'editor.background': '#f4f8fb',
4647
'token.keyword': '#ff0000'
4748
}
4849
});

src/routes/tutorial/[slug]/_/File.svelte

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,33 @@
1313

1414
<style>
1515
button {
16+
position: relative;
1617
padding: 0 0 0 0.2em;
1718
font-size: 1.6rem;
1819
font-family: inherit;
1920
color: var(--text);
21+
width: 100%;
22+
text-align: left;
23+
border: 2px solid transparent;
2024
}
2125
2226
button.selected {
2327
color: var(--prime);
2428
}
29+
30+
button.selected::after {
31+
content: '';
32+
position: absolute;
33+
width: 1rem;
34+
height: 1rem;
35+
right: calc(-2.6rem - 2px);
36+
background-color: var(--light-blue);
37+
border: 1px solid var(--border-color);
38+
transform: translate(0, 0.2rem) rotate(45deg);
39+
}
40+
41+
button:focus-visible {
42+
outline: none;
43+
border: 2px solid var(--flash);
44+
}
2545
</style>

src/routes/tutorial/[slug]/_/Folder.svelte

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,29 @@
6060
font-family: inherit;
6161
color: var(--text);
6262
padding: 0 0 0 1.2em;
63-
background: url(/tutorial/icons/folder.svg) 0 0.25rem no-repeat;
63+
width: 100%;
64+
text-align: left;
65+
background: url(./folder.svg) 0 45% no-repeat;
6466
background-size: 1.4rem 1.4rem;
6567
user-select: none;
6668
cursor: pointer;
69+
border: 2px solid transparent;
70+
}
71+
72+
button:focus-visible {
73+
outline: none;
74+
border: 2px solid var(--flash);
6775
}
6876
6977
.expanded {
70-
background-image: url(/tutorial/icons/folder-open.svg);
78+
background-image: url(./folder-open.svg);
7179
}
7280
7381
ul {
74-
padding: 0 0 0 0.2em;
75-
margin: 0 0 0 0.2em;
82+
padding: 0 0 0 0.3em;
83+
margin: 0 0 0 0.5em;
7684
list-style: none;
77-
border-left: 1px solid #eee;
85+
/* border-left: 1px solid #eee; */
7886
line-height: 1.3;
7987
}
8088

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
height: 100%;
132132
transition: transform 0.2s;
133133
transform: translate(calc(var(--menu-width) - 100%), 0);
134-
background: var(--back-api);
134+
background: var(--light-blue);
135135
z-index: 2;
136136
/* filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.1)); */
137137
border-right: 1px solid var(--border-color);
@@ -180,7 +180,7 @@
180180
.menu-toggle {
181181
width: 100%;
182182
height: 100%;
183-
background: var(--back-api);
183+
background: var(--light-blue);
184184
border: 2px solid transparent;
185185
box-sizing: border-box;
186186
}

src/routes/tutorial/[slug]/_/Sidebar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
justify-content: center;
216216
border: 1.5px solid var(--flash);
217217
background: var(--flash);
218-
color: var(--back-api);
218+
color: var(--light-blue);
219219
border-radius: 50%;
220220
text-align: center;
221221
font-size: 1.2rem;
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import ImageViewer from './_/ImageViewer.svelte';
2222
import Sidebar from './_/Sidebar.svelte';
2323
import Chrome from './_/Chrome.svelte';
24+
import { Icon } from '@sveltejs/site-kit';
2425
2526
/** @type {import('$lib/types').PartStub[]} */
2627
export let index;
@@ -283,6 +284,14 @@
283284
<section slot="a">
284285
<SplitPane type="horizontal" min="80px" max="300px" pos="200px">
285286
<section class="navigator" slot="a">
287+
<div class="filetree">
288+
<Folder
289+
{...section.scope}
290+
files={Object.values(section.a).filter((stub) => !hidden.has(stub.basename))}
291+
expanded
292+
/>
293+
</div>
294+
286295
<button
287296
class:completed
288297
disabled={Object.keys(section.b).length === 0}
@@ -326,16 +335,12 @@
326335
completing = false;
327336
}}
328337
>
329-
{completed && Object.keys(section.b).length > 0 ? 'reset' : 'solve'}
338+
{#if completed && Object.keys(section.b).length > 0}
339+
reset
340+
{:else}
341+
solve <Icon name="arrow-right" />
342+
{/if}
330343
</button>
331-
332-
<div class="filetree">
333-
<Folder
334-
{...section.scope}
335-
files={Object.values(section.a).filter((stub) => !hidden.has(stub.basename))}
336-
expanded
337-
/>
338-
</div>
339344
</section>
340345
341346
<section class="editor-container" slot="b">
@@ -358,27 +363,6 @@
358363
set_iframe_src(adapter.base + path);
359364
}}
360365
/>
361-
<!-- <div class="chrome">
362-
<button
363-
on:click={() => {
364-
set_iframe_src('/loading.html');
365-
set_iframe_src(adapter.base + path);
366-
}}
367-
aria-label="reload"
368-
>
369-
<img src={refresh} alt="Reload icon" />
370-
</button>
371-
372-
<input
373-
aria-label="URL"
374-
value={path}
375-
on:change={(e) => {
376-
const url = new URL(e.currentTarget.value, adapter.base);
377-
path = url.pathname + url.search + url.hash;
378-
set_iframe_src(adapter.base + path);
379-
}}
380-
/>
381-
</div> -->
382366
383367
<iframe bind:this={iframe} title="Output" src="/loading.html" />
384368
</section>
@@ -389,7 +373,7 @@
389373
390374
<style>
391375
.container {
392-
--border-color: hsl(206, 44%, 85%);
376+
--border-color: hsl(206, 44%, 90%);
393377
height: 100%;
394378
max-height: 100%;
395379
}
@@ -400,23 +384,23 @@
400384
min-height: 0;
401385
height: 100%;
402386
max-height: 100%;
403-
background: var(--back-api);
387+
background: var(--light-blue);
404388
--menu-width: 5.4rem;
405389
}
406390
407391
.navigator {
408392
background: white;
409393
display: flex;
410394
flex-direction: column;
411-
padding: 1rem;
412-
gap: 1rem;
413395
}
414396
415397
.navigator button {
398+
position: relative;
416399
background: #ddd;
417400
padding: 0.5rem;
418-
border-radius: 0.5rem;
419-
width: 100%;
401+
width: calc(100% + 1px);
402+
height: 4rem;
403+
opacity: 1;
420404
}
421405
422406
.navigator button:not(:disabled) {
@@ -431,6 +415,18 @@
431415
.filetree {
432416
flex: 1;
433417
overflow-y: auto;
418+
overflow-x: hidden;
419+
padding: 2rem;
420+
}
421+
422+
.filetree::before {
423+
content: '';
424+
position: absolute;
425+
width: 0;
426+
height: 100%;
427+
top: 0;
428+
right: 0;
429+
border-right: 1px solid var(--border-color);
434430
}
435431
436432
.preview {
@@ -449,5 +445,6 @@
449445
450446
.editor-container {
451447
padding: 0.5rem;
448+
background-color: var(--light-blue);
452449
}
453450
</style>

0 commit comments

Comments
 (0)