Skip to content

Commit

Permalink
Merge pull request #407 from Nekoya3/WebP-Support
Browse files Browse the repository at this point in the history
Performance improvement: WebPへの対応
  • Loading branch information
NEKOYASAN authored Apr 28, 2020
2 parents 4e30501 + 47a7cac commit 3e7e141
Show file tree
Hide file tree
Showing 21 changed files with 132 additions and 244 deletions.
43 changes: 23 additions & 20 deletions components/DataView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,44 +74,44 @@
:aria-label="$t('シェアリンクをコピー', { title })"
@click="copyLink"
>
<picture>
<img src="/link.png" alt="link" class="icon-resize link" />
</picture>
<PictureLoader
filename="link"
alt="link"
classname="icon-resize link"
/>
</button>

<button
:aria-label="$t('LINEで{title}のグラフをシェア', { title })"
@click="line"
>
<picture>
<img src="/line.png" alt="LINE" class="icon-resize line" />
</picture>
<PictureLoader
filename="line"
alt="LINE"
classname="icon-resize line"
/>
</button>

<button
:aria-label="$t('Twitterで{title}のグラフをシェア', { title })"
@click="twitter"
>
<picture>
<img
src="/twitter.png"
alt="Twitter"
class="icon-resize twitter"
/>
</picture>
<PictureLoader
filename="twitter"
alt="Twitter"
classname="icon-resize twitter"
/>
</button>

<button
:aria-label="$t('facebookで{title}のグラフをシェア', { title })"
@click="facebook"
>
<picture>
<img
src="/facebook.png"
alt="facebook"
class="icon-resize facebook"
/>
</picture>
<PictureLoader
filename="facebook"
alt="facebook"
classname="icon-resize facebook"
/>
</button>
</div>
</div>
Expand All @@ -133,7 +133,10 @@
<script lang="ts">
import Vue from 'vue'
const PictureLoader = () => import('~/components/PictureLoader.vue')
export default Vue.extend({
components: { PictureLoader },
props: {
title: {
type: String,
Expand Down
51 changes: 51 additions & 0 deletions components/PictureLoader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<picture>
<source
:srcset="'/' + filename + '.webp'"
:width="width"
:height="height"
:alt="alt"
:class="classname"
decoding="async"
loading="lazy"
type="image/webp"
/>
<img
:src="'/' + filename + '.png'"
:width="width"
:height="height"
:class="classname"
:alt="alt"
loading="lazy"
decoding="async"
/>
</picture>
</template>

<script>
export default {
name: 'PictureLoader',
props: {
filename: {
type: String,
default: ''
},
alt: {
type: String,
default: ''
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '100%'
},
classname: {
type: String,
default: ''
}
}
}
</script>
58 changes: 36 additions & 22 deletions components/SideNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@
target="_blank"
rel="noopener"
>
<img src="/twitter.png" width="90px" height="90px" alt="Twitter" />
<PictureLoader
filename="twitter"
width="30px"
height="30px"
alt="Twitter"
/>
</a>
<a
href="https://www.facebook.com/Justdouit19/"
target="_blank"
rel="noopener"
>
<img
src="/facebook.png"
width="90px"
height="90px"
<PictureLoader
filename="facebook"
width="30px"
height="30px"
alt="Facebook"
/>
</a>
Expand All @@ -86,7 +91,12 @@
target="_blank"
rel="noopener"
>
<img src="/github.png" width="90px" height="90px" alt="GitHub" />
<PictureLoader
filename="github"
width="30px"
height="30px"
alt="Github"
/>
</a>
</div>
<div class="SideNavigation-SponsorLinkContainer">
Expand All @@ -109,35 +119,38 @@
<span class="image-title">{{ $t('CC BY 4.0') }}</span>
</template>
<template #ccByImage>
<img
class="cc-by-logo"
src="/cc-by-mini.svg"
<PictureLoader
classname="cc-by-logo"
filename="cc-by-mini"
width="85.3px"
height="16px"
:alt="$t('CC BY 4.0')"
/>
</template>
</i18n> </a
><br />
<br />
{{ $t('Operations by:') }}<br />
<nuxt-link :to="{ path: localePath('/about/') }">
<span class="image-title">{{ $t('JUST道IT') }}</span>
<img
class="justdoit-logo"
src="/justdouit.png"

<PictureLoader
classname="justdoit-logo"
filename="justdouit"
width="132px"
height="46.6px"
:alt="$t('JUST道IT')"
/>
</nuxt-link>

<br />
<br />
{{ $t('Powered by:') }}<br />
<a href="https://www.sakura.ad.jp/" target="_blank" rel="noopener">
<span class="image-title">{{ $t('さくらインターネット') }}</span>
<img
class="sakura-internet-logo"
src="/sakura.svg"
<PictureLoader
classname="sakura-internet-logo"
filename="sakura"
width="176px"
height="62px"
:alt="$t('さくらインターネット')"
Expand All @@ -155,8 +168,11 @@ import LogoAnimation from '@/components/Logo-Animation'
import LogoAnimationSp from '@/components/Logo-Animation-sp.vue'
const LanguageSelector = () => import('@/components/LanguageSelector.vue')
const PictureLoader = () => import('~/components/PictureLoader.vue')
export default {
components: {
PictureLoader,
LogoAnimationSp,
LogoAnimation,
ListItem,
Expand Down Expand Up @@ -363,14 +379,14 @@ export default {
& a:hover {
opacity: 0.6;
}
& img {
& picture {
padding-bottom: 0.9rem;
}
& img.justdouit-logo {
& picture.justdouit-logo {
margin: 0 0 0 -3px;
width: 132px;
}
& img.sakura-internet-logo {
& picture.sakura-internet-logo {
margin: -6px 0 0 -14px;
width: 176px;
}
Expand Down Expand Up @@ -407,11 +423,9 @@ export default {
}
&-SocialLinkContainer {
display: flex;
& img {
& picture {
width: 30px;
&:first-of-type {
margin-right: 10px;
}
margin-right: 10px;
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion pages/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@
</TextCard>

<TextCard title="">
<img src="/ogp.png" />
<PictureLoader
filename="ogp"
classname="img"
:alt="$t('北海道アイキャッチ画像')"
/>
<i18n path="Illustration by {LITTLEKIT} under {ccBy}">
<template #LITTLEKIT>
<a href="https://twitter.com/LITTLEKIT">{{ $t('LITTLEKIT') }}</a>
Expand All @@ -315,10 +319,12 @@
<script lang="ts">
import Vue from 'vue'
import { MetaInfo } from 'vue-meta'
const PictureLoader = () => import('~/components/PictureLoader.vue')
const TextCard = () => import('@/components/TextCard.vue')
export default Vue.extend({
components: {
PictureLoader,
TextCard
},
head(): MetaInfo {
Expand Down
28 changes: 15 additions & 13 deletions pages/print/info.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<img src="/ogp.png" alt="{{ $t('北海道アイキャッチ画像')" />
<PictureLoader filename="ogp" :alt="$t('北海道アイキャッチ画像')" />
<br />
<br />
<h1 class="sitename">
Expand Down Expand Up @@ -39,44 +39,46 @@
<span class="image-title">{{ $t('CC BY 4.0') }}</span>
</template>
<template #ccByImage>
<img
class="cc-by-logo"
src="/cc-by-mini.svg"
<PictureLoader
classname="cc-by-logo"
src="cc-by-mini"
width="85.3px"
height="16px"
alt="$t('CC BY 4.0')"
:alt="$t('CC BY 4.0')"
/>
</template>
</i18n>
</li>
<li class="supplementHeader2">
{{ $t('Operations by:') }}<br />
<span class="image-title">{{ $t('JUST道IT') }}</span>
<img
class="justdoit-logo"
src="/justdouit.png"
<PictureLoader
filename="justdouit"
classname="justdoit-logo"
width="132px"
height="46.6px"
alt="$t('JUST道IT')"
:alt="$t('JUST道IT')"
/>
</li>
<li class="supplementHeader3">
{{ $t('Powered by:') }}<br />
<span class="image-title">{{ $t('さくらインターネット') }}</span>
<img
class="sakura-internet-logo"
src="/sakura.svg"
<PictureLoader
classname="sakura-internet-logo"
filename="sakura"
width="176px"
height="62px"
alt="$t('さくらインターネット')"
:alt="$t('さくらインターネット')"
/>
</li>
</ul>
</div>
</template>

<script>
const PictureLoader = () => import('@/components/PictureLoader')
export default {
components: { PictureLoader },
layout: 'print',
head() {
return {
Expand Down
Binary file added static/cc-by-mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions static/cc-by-mini.svg

This file was deleted.

Binary file added static/cc-by-mini.webp
Binary file not shown.
Binary file added static/cc-by.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3e7e141

Please sign in to comment.