Skip to content

Commit 27f46c3

Browse files
authored
Icon css (#344)
* centralise icon CSS * fix some stuff
1 parent 9389a37 commit 27f46c3

File tree

7 files changed

+25
-45
lines changed

7 files changed

+25
-45
lines changed

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

-3
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ export default app;`
357357
display: flex;
358358
align-items: center;
359359
justify-content: center;
360-
width: 3.2rem;
361-
height: 3.2rem;
362360
user-select: none;
363361
}
364362
@@ -368,7 +366,6 @@ export default app;`
368366
font-size: var(--sk-font-size-ui-small);
369367
color: var(--sk-text-3);
370368
line-height: 1;
371-
background: 50% 50% no-repeat;
372369
background-size: 1.8rem;
373370
z-index: 999;
374371

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use an svg icon that was provided through `Icons.svelte` from
1313
} = $props();
1414
</script>
1515

16-
<svg class="icon" width={size} height={size}>
16+
<svg width={size} height={size}>
1717
<use xlink:href="#{name}" />
1818
</svg>
1919

2020
<style>
21-
.icon {
21+
svg {
2222
position: relative;
2323
overflow: hidden;
2424
vertical-align: middle;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
content: none;
405405
}
406406
407-
background: url($lib/icons/lightbulb.svg) no-repeat 0.5rem 0 / 3rem;
407+
background: url($lib/icons/lightbulb.svg) no-repeat 0.5rem 0 / 2.6rem;
408408
}
409409
410410
&:first-child {

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@
2323

2424
<button
2525
onclick={toggle}
26-
class="raised"
26+
class="raised icon"
2727
type="button"
2828
aria-pressed={$theme.current === 'dark'}
2929
aria-label="Toggle dark mode"
3030
></button>
3131

3232
<style>
3333
button {
34-
width: 3.2rem;
35-
aspect-ratio: 1;
36-
background: red;
37-
background: url($lib/icons/theme-light.svg) no-repeat 50% 50% / 2.3rem 2.3rem;
34+
background-image: url($lib/icons/theme-light.svg);
3835
margin-left: 1rem;
3936
4037
:global(.dark) & {

packages/site-kit/src/lib/nav/Menu.svelte

+2-8
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@
118118
<button
119119
aria-label="Toggle menu"
120120
aria-expanded={$open_store}
121-
class="menu-toggle"
121+
class="menu-toggle raised icon"
122122
class:open
123123
bind:this={menu_button}
124124
onclick={open_nav}
125125
>
126-
<Icon name={$open_store ? 'close' : 'menu'} size="1em" />
126+
<Icon name={$open_store ? 'close' : 'menu'} size={16} />
127127
</button>
128128
129129
{#if $open_store}
@@ -267,14 +267,8 @@
267267
display: flex;
268268
align-items: center;
269269
justify-content: center;
270-
271-
height: 100%;
272-
width: var(--sk-nav-height);
273-
274270
display: flex;
275271
gap: 1.5rem;
276-
277-
line-height: 1;
278272
}
279273
280274
.menu-background {

packages/site-kit/src/lib/nav/Nav.svelte

+10-26
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ Top navigation bar for the application. It provides a slot for the left side, th
105105
<div class="mobile mobile-menu">
106106
<button
107107
aria-label="Search"
108-
class="search"
108+
class="raised icon search"
109109
onclick={() => {
110110
$searching = true;
111111
}}
112112
>
113-
<Icon name="search" size=".6em" />
113+
<Icon name="search" size={16} />
114114
</button>
115115

116116
<Menu bind:open={$nav_open} {links}>
@@ -137,6 +137,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
137137
width: 100vw;
138138
height: var(--sk-nav-height);
139139
margin: 0 auto;
140+
padding: 0 var(--sk-page-padding-side);
140141
background-color: var(--sk-back-2);
141142
font-family: var(--sk-font-body);
142143
user-select: none;
@@ -208,10 +209,9 @@ Top navigation bar for the application. It provides a slot for the left side, th
208209
209210
.home-link {
210211
--padding-right: 1rem;
211-
width: 16rem;
212+
width: 11.2rem;
212213
height: 100%;
213-
background: url(../branding/svelte.svg) no-repeat var(--sk-page-padding-side) 50% /
214-
calc(100% - var(--sk-page-padding-side) - var(--padding-right)) auto;
214+
background: url(../branding/svelte.svg) no-repeat 0 50% / calc(100% - var(--padding-right)) auto;
215215
padding: 0 var(--padding-right) 0 calc(var(--sk-page-padding-side) + 0rem);
216216
217217
:global(.dark) & {
@@ -221,10 +221,10 @@ Top navigation bar for the application. It provides a slot for the left side, th
221221
222222
.mobile-menu {
223223
display: flex;
224-
position: absolute;
225-
bottom: 0;
226-
right: 0;
227-
height: 100%;
224+
flex: 1;
225+
justify-content: end;
226+
align-items: center;
227+
gap: 0.5rem; /* TODO tokenize */
228228
}
229229
230230
.desktop {
@@ -235,21 +235,6 @@ Top navigation bar for the application. It provides a slot for the left side, th
235235
display: block;
236236
}
237237
238-
button {
239-
display: flex;
240-
align-items: center;
241-
justify-content: center;
242-
height: 100%;
243-
display: flex;
244-
gap: 1.5rem;
245-
padding: 0 1rem;
246-
line-height: 1;
247-
}
248-
249-
.search {
250-
padding-left: 2rem;
251-
}
252-
253238
.appearance {
254239
display: flex;
255240
align-items: center;
@@ -297,7 +282,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
297282
@media (min-width: 800px) {
298283
.home-link {
299284
--padding-right: 2rem;
300-
width: 18rem;
285+
width: 13.2rem;
301286
}
302287
303288
nav {
@@ -316,7 +301,6 @@ Top navigation bar for the application. It provides a slot for the left side, th
316301
width: auto;
317302
height: 100%;
318303
align-items: center;
319-
padding: 0 var(--sk-page-padding-side) 0 0;
320304
}
321305
322306
.menu:last-child {

packages/site-kit/src/lib/styles/utils/buttons.css

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@
1818
border-width: 1px;
1919
}
2020
}
21+
22+
.icon {
23+
width: 3.2rem;
24+
height: 3.2rem;
25+
background-repeat: no-repeat;
26+
background-position: 50% 50%;
27+
background-size: 2.3rem 2.3rem;
28+
}

0 commit comments

Comments
 (0)