Skip to content

Commit badf5bf

Browse files
committed
neumorphic buttons
1 parent 960c2c1 commit badf5bf

File tree

3 files changed

+78
-16
lines changed

3 files changed

+78
-16
lines changed

apps/svelte.dev/src/routes/(authed)/playground/[id]/AppControls.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,27 +215,27 @@ export default app;`
215215
/>
216216

217217
<div class="buttons">
218-
<button class="icon" onclick={() => (zen_mode = !zen_mode)} title="fullscreen editor">
218+
<button class="raised icon" onclick={() => (zen_mode = !zen_mode)} title="fullscreen editor">
219219
{#if zen_mode}
220220
<Icon name="close" />
221221
{:else}
222222
<Icon name="maximize" />
223223
{/if}
224224
</button>
225225

226-
<button class="icon" disabled={downloading} onclick={download} title="download zip file">
226+
<button class="raised icon" disabled={downloading} onclick={download} title="download zip file">
227227
<Icon name="download" />
228228
</button>
229229

230-
<button class="icon" disabled={saving || !user} onclick={() => fork(false)} title="fork">
230+
<button class="raised icon" disabled={saving || !user} onclick={() => fork(false)} title="fork">
231231
{#if justForked}
232232
<Icon name="check" />
233233
{:else}
234234
<Icon name="git-branch" />
235235
{/if}
236236
</button>
237237

238-
<button class="icon" disabled={saving || !user} onclick={save} title="save">
238+
<button class="raised icon" disabled={saving || !user} onclick={save} title="save">
239239
{#if justSaved}
240240
<Icon name="check" />
241241
{:else}
@@ -249,7 +249,7 @@ export default app;`
249249
{#if user}
250250
<UserMenu {user} />
251251
{:else}
252-
<button class="icon" onclick={(e) => (e.preventDefault(), login())}>
252+
<button class="raised icon" onclick={(e) => (e.preventDefault(), login())}>
253253
<Icon name="log-in" />
254254
<span>&nbsp;Log in to save</span>
255255
</button>
@@ -285,7 +285,7 @@ export default app;`
285285
.icon {
286286
transform: translateY(0.1rem);
287287
display: inline-block;
288-
padding: 0.2em;
288+
padding: 0.4em;
289289
opacity: 0.7;
290290
transition: opacity 0.3s;
291291
font-family: var(--sk-font-ui);

packages/site-kit/src/lib/components/ThemeToggle.svelte

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,56 @@
3838
onDestroy(() => query?.removeEventListener('change', cb));
3939
</script>
4040

41-
<button
42-
onclick={toggle}
43-
type="button"
44-
aria-pressed={$theme.current === 'dark' ? 'true' : 'false'}
45-
aria-label={label}
46-
></button>
41+
<div class="appearance">
42+
<span class="caption">Theme</span>
43+
<button
44+
onclick={toggle}
45+
class="raised"
46+
type="button"
47+
aria-pressed={$theme.current === 'dark' ? 'true' : 'false'}
48+
aria-label={label}
49+
></button>
50+
</div>
4751

4852
<style>
4953
button {
50-
width: 2.3rem;
51-
height: 2.3rem;
54+
width: 4rem;
55+
height: 4rem;
5256
background: red;
53-
background: url($lib/icons/theme-light.svg) no-repeat 50% 50% / contain;
57+
background: url($lib/icons/theme-light.svg) no-repeat 50% 50% / 2.3rem 2.3rem;
5458
opacity: 0.6;
5559
5660
:global(.dark) & {
57-
background: url($lib/icons/theme-dark.svg);
61+
background-image: url($lib/icons/theme-dark.svg);
5862
opacity: 0.8;
5963
}
6064
}
65+
66+
.appearance {
67+
display: flex;
68+
align-items: center;
69+
margin-left: 1.5rem;
70+
71+
.caption {
72+
display: none;
73+
font-size: var(--sk-text-xs);
74+
line-height: 1;
75+
margin-right: 0rem;
76+
}
77+
}
78+
79+
@media (max-width: 799px) {
80+
.appearance {
81+
position: relative;
82+
display: flex;
83+
padding: 1.5rem 0;
84+
justify-content: space-between;
85+
}
86+
87+
.appearance .caption {
88+
display: block;
89+
90+
font-size: var(--sk-text-s);
91+
}
92+
}
6193
</style>

packages/site-kit/src/lib/styles/base.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,36 @@ button > svg {
171171
stroke: currentColor !important;
172172
}
173173

174+
.raised {
175+
--highlight: hsl(0 0 100 / 0.8);
176+
--highlight-active: hsl(0 0 100 / 1);
177+
--shadow: hsl(0 0 0 / 0.1);
178+
--shadow-active: hsl(0 0 0 / 0.15);
179+
180+
.dark & {
181+
--highlight: hsl(0 0 100 / 0.15);
182+
--highlight-active: hsl(0 0 100 / 0.15);
183+
--shadow: hsl(0 0 0 / 0.2);
184+
--shadow-active: hsl(0 0 0 / 0.3);
185+
}
186+
187+
188+
border-radius: var(--sk-border-radius);
189+
box-shadow: 2px 2px 4px var(--shadow), -1px -1px 3px var(--highlight);
190+
191+
&:hover {
192+
box-shadow: 2px 2px 5px var(--shadow-active), -1px -1px 4px var(--highlight-active);
193+
}
194+
195+
&:active {
196+
box-shadow: inset -1px -1px 3px var(--highlight-active), inset 1px 1px 3px var(--shadow-active);
197+
}
198+
199+
&:disabled {
200+
box-shadow: none;
201+
}
202+
}
203+
174204
/* links ------------------------------------- */
175205
a {
176206
color: var(--sk-theme-1);

0 commit comments

Comments
 (0)