Skip to content

Commit 3ce566e

Browse files
authored
Merge pull request #4 from oriverk/dev
perf: remove svg icon components and use css mask-image
2 parents 69c5839 + bec2a50 commit 3ce566e

25 files changed

+192
-292
lines changed

public/assets/algolia.svg

Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 5 additions & 31 deletions
Loading

public/assets/magnifyingGlass.svg

Lines changed: 3 additions & 0 deletions
Loading

public/assets/pencil.svg

Lines changed: 5 additions & 0 deletions
Loading

public/assets/repository.svg

Lines changed: 8 additions & 0 deletions
Loading

public/assets/star.svg

Lines changed: 5 additions & 0 deletions
Loading

public/assets/user.svg

Lines changed: 5 additions & 0 deletions
Loading

public/assets/x.svg

Lines changed: 6 additions & 0 deletions
Loading

public/assets/zenn.svg

Lines changed: 8 additions & 0 deletions
Loading

public/favicon.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/components/Hero.svelte

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<script lang="ts">
22
import urlJoin from 'url-join'
33
import siteConfig from '../../site.config'
4-
import GithubIcon from './ui/icons/GithubIcon.svelte'
5-
import ZennIcon from './ui/icons/ZennIcon.svelte'
6-
import XIcon from './ui/icons/X.svelte'
7-
import PencilIcon from './ui/icons/PencilIcon.svelte'
8-
import MagnifyingGlass from './ui/icons/MagnifyingGlass.svelte'
4+
import Icon from './ui/Icon.svelte'
95
import Search from './Search/index.svelte'
106
import Dialog from './ui/Dialog.svelte'
117
@@ -36,36 +32,39 @@
3632
<h1>Kawano Yudai</h1>
3733
<p><span class="text-gradient">Agr.</span> → ? / Bicycle</p>
3834
<div class="links">
39-
<button type="button" on:click={openDialog}>
40-
<MagnifyingGlass title="Search" />
35+
<button type="button" on:click={openDialog} title="Search">
36+
<Icon type="magnifyingGlass" size="medium" />
4137
<span class="sr-only">Search</span>
4238
</button>
4339
<a href={blogPath} title="Blog" target="_blank" rel="noopener noreferrer">
44-
<PencilIcon title="blog.oriverk.dev" />
40+
<Icon type="pencil" size="medium" />
4541
<span class="sr-only">Blog link</span>
4642
</a>
4743
<a
4844
href={urlJoin('https://github.com', github)}
4945
target="_blank"
5046
rel="noopener noreferrer"
47+
title={'@' + github}
5148
>
52-
<GithubIcon title={'@' + github} />
49+
<Icon type="github" size="medium" />
5350
<span class="sr-only">GitHub link</span>
5451
</a>
5552
<a
5653
href={urlJoin('https://twitter.com', x)}
5754
target="_blank"
5855
rel="noopener noreferrer"
56+
title={'@' + x}
5957
>
60-
<XIcon title={'@' + x} />
58+
<Icon type="x" size="medium" />
6159
<span class="sr-only">X link</span>
6260
</a>
6361
<a
6462
href={urlJoin('https://zenn.dev', zenn)}
6563
target="_blank"
6664
rel="noopener noreferrer"
65+
title={'@' + zenn}
6766
>
68-
<ZennIcon title={'@' + zenn} />
67+
<Icon type="zenn" size="medium" />
6968
<span class="sr-only">Zenn.dev link</span>
7069
</a>
7170
</div>
@@ -75,10 +74,6 @@
7574
</div>
7675

7776
<style>
78-
:global(.links svg) {
79-
width: 2rem;
80-
aspect-ratio: 1;
81-
}
8277
.hero {
8378
display: flex;
8479
flex-direction: column;
@@ -114,7 +109,8 @@
114109
gap: 0.5rem;
115110
}
116111
117-
.links > * {
112+
.links > a,
113+
.links > button {
118114
width: 3rem;
119115
display: flex;
120116
justify-content: center;
@@ -125,7 +121,8 @@
125121
background-color: rgb(var(--color-hover));
126122
}
127123
128-
.links > *:hover {
124+
.links > a:hover,
125+
.links > button:hover {
129126
background-color: rgba(0 0 0 / 0.3);
130127
}
131128
</style>

src/components/RepositoryCard.svelte

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<script lang="ts">
22
import type { Repository, Language } from '@octokit/graphql-schema'
33
import Card from './ui/Card.svelte'
4-
import StarIcon from './ui/icons/StarIcon.svelte'
5-
import RepoIcon from './ui/icons/RepoIcon.svelte'
4+
import Icon from './ui/Icon.svelte'
65
76
interface $$Props
87
extends Pick<
@@ -27,7 +26,7 @@
2726
<Card>
2827
<div class="repository">
2928
<div class="title">
30-
<RepoIcon />
29+
<Icon type="repository" size="small" />
3130
<span>{name}</span>
3231
{#if isArchived}
3332
<span class="public archived">Public archive</span>
@@ -48,7 +47,7 @@
4847
{/if}
4948
{#if !!stargazerCount}
5049
<span class="stargazerCount">
51-
<StarIcon />
50+
<Icon type="star" size="small" />
5251
{stargazerCount}
5352
</span>
5453
{/if}
@@ -58,11 +57,6 @@
5857
</a>
5958

6059
<style>
61-
:global(.repository svg) {
62-
width: 1rem;
63-
aspect-ratio: 1;
64-
color: rgb(var(--color-lightgray));
65-
}
6660
.repository {
6761
height: 100%;
6862
display: flex;

src/components/ui/icons/AlgoliaIcon.svelte renamed to src/components/Search/AlgoliaIcon.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
44
export let className: string = ''
55
export let title: string = ''
6+
export let height: string = ''
67
</script>
78

89
<svg
910
viewBox="0 0 572 64"
1011
xmlns="http://www.w3.org/2000/svg"
1112
class={clsx('ais-PoweredBy-log', className)}
13+
{height}
1214
>
1315
{#if title}
1416
<title>{title}</title>

src/components/Search/SearchInput.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import type { HTMLInputAttributes } from 'svelte/elements'
33
import clsx from 'clsx'
4-
import MagnifyingGlass from '../ui/icons/MagnifyingGlass.svelte'
4+
import Icon from '../ui/Icon.svelte'
55
66
interface $$Props extends Omit<HTMLInputAttributes, 'class'> {
77
className?: string
@@ -15,7 +15,7 @@
1515
<label for="search" class="sr-only">検索</label>
1616
<div class="search-input-wrapper">
1717
<div class="search-icon">
18-
<MagnifyingGlass />
18+
<Icon type="magnifyingGlass" size="small" />
1919
</div>
2020
<input class="search-input" {placeholder} bind:value {...$$restProps} />
2121
</div>
@@ -43,11 +43,6 @@
4343
align-items: center;
4444
}
4545
46-
.search-icon :global(svg) {
47-
height: 1.25rem;
48-
width: 1.25rem;
49-
}
50-
5146
.search-input {
5247
color: rbg(var(--color-white));
5348
font-size: 1rem;

src/components/Search/index.svelte

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { searchAlgolia } from '../../utils/algolia'
66
import SearchInput from './SearchInput.svelte'
77
import BlogHit from './BlogHit.svelte'
8-
import AlgoliaIcon from '../ui/icons/AlgoliaIcon.svelte'
8+
import AlgoliaIcon from './AlgoliaIcon.svelte'
99
1010
let results: SearchResponse<AlgoliaBlog>
1111
let hits: Hit<AlgoliaBlog>[] = []
@@ -88,7 +88,7 @@
8888
target="_blank"
8989
rel="noopener noreferrer"
9090
>
91-
<AlgoliaIcon />
91+
<AlgoliaIcon height="1.25rem" />
9292
</a>
9393
</div>
9494
{#if !results?.nbHits}
@@ -123,10 +123,6 @@
123123
justify-content: flex-end;
124124
}
125125
126-
.search-icon-wrapper :global(svg) {
127-
height: 1.25rem;
128-
}
129-
130126
.search-results-wrapper {
131127
height: calc(100% - 9rem);
132128
overflow-y: auto;

0 commit comments

Comments
 (0)