Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement: WebPへの対応 #407

Merged
merged 7 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
<VPicture
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>
<VPicture
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>
<VPicture
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>
<VPicture
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 VPicture = () => import('@/components/VPicture.vue')

export default Vue.extend({
components: { VPicture },
props: {
title: {
type: String,
Expand Down
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" />
<VPicture
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"
<VPicture
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" />
<VPicture
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"
<VPicture
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"

<VPicture
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"
<VPicture
classname="sakura-internet-logo"
filename="sakura"
width="176px"
height="62px"
:alt="$t('さくらインターネット')"
Expand All @@ -155,8 +168,11 @@ import LanguageSelector from '@/components/LanguageSelector.vue'
import LogoAnimation from '@/components/Logo-Animation'
import LogoAnimationSp from '@/components/Logo-Animation-sp.vue'

const VPicture = () => import('@/components/VPicture.vue')

export default {
components: {
VPicture,
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
51 changes: 51 additions & 0 deletions components/VPicture.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
NEKOYASAN marked this conversation as resolved.
Show resolved Hide resolved
<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: 'VPicture',
props: {
filename: {
type: String,
default: ''
},
alt: {
type: String,
default: ''
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '100%'
},
classname: {
type: String,
default: ''
}
}
}
</script>
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" />
<VPicture
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 @@ -316,9 +320,11 @@
import Vue from 'vue'
import { MetaInfo } from 'vue-meta'
import TextCard from '@/components/TextCard.vue'
const VPicture = () => import('@/components/VPicture.vue')

export default Vue.extend({
components: {
VPicture,
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('北海道アイキャッチ画像')" />
<VPicture 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"
<VPicture
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"
<VPicture
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"
<VPicture
classname="sakura-internet-logo"
filename="sakura"
width="176px"
height="62px"
alt="$t('さくらインターネット')"
:alt="$t('さくらインターネット')"
/>
</li>
</ul>
</div>
</template>

<script>
const VPicture = () => import('@/components/VPicture')
export default {
components: { VPicture },
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