Skip to content

Commit cf20720

Browse files
ryamakuchiinouetakuya
authored andcommitted
feat: スポンサー一覧ページを作成する (#170)
* wip * add pages/sponsors.vue * path は /sponsors で不変のため余分なロジックを消した * Contentful からスポンサー情報を取得できるようにした * Home と同じようにスポンサー一覧を表示した * sm サイズのコーディング * md サイズのコーディング * アンカー以外の lg サイズのコーディング * アンカーをつけた * smooth スクロールを実装した * スクロールしたときに意図した位置までいくように画像の lazyload を外した * /sponsors の中のみスクロールするように修正 * .active 以外の nav レイアウトを追加した(lg サイズ以上) * nav でもスポンサーのいないプランは非表示になるように * lg サイズ以上の全体の余白の調整 * -margin の中の計算を分かりやすく正しく直した * .nuxt-link-active のときのスタイルを追加 * lg サイズのアンカーにインタラクションをつける * 型をつけた * トップページののリンクを /sponsors に変更した * .nav の余計な要素を表示させないように修正 * yarn lint:fix * sponsors.spec.ts を追加 * TheSponsorListSection.spec.ts に出ていた warn を解消 * SponsorsPage のテストに sponsorListMock を追加 * SponsorsPage にテストケースを追加した * padding ではなく左右の余白は margin でとるように修正 * lg のローカルナビのフォントサイズやナビ同士の間隔を調整する * スムーズスクロールを window.scroll に切り替える * sm の .sponsor-name を line-height: 1; に修正する * トップに戻るボタンにスタイルを当てるためににクラスをつけた * bronze は PR 文掲載なしに修正 * トップに戻るボタンのスタイルの適用優先順位を変更した * fix: warning Attribute v-if should go before class * sm サイズの PR 文と URL のフォントサイズを微調整 * fix: margin の余分な指定を削除 * Update src/pages/sponsors.vue Co-Authored-By: INOUE Takuya <[email protected]> * Update src/components/TheSponsorListSection.vue Co-Authored-By: INOUE Takuya <[email protected]> * Update nuxt.config.ts Co-Authored-By: INOUE Takuya <[email protected]> * Fix: .sponsor-list -> .sponsor-group-list * Fix: .nav -> .index * Fix: Trailing Slash * lg サイズ以上のインタラクションに関係するコードを削除 * Fix 非推奨の書き方 ssr: false -> mode: client * アンカーを修正 * 余白の調整 * 余分な変数を削除 * スクロールするときにヘッダーの高さ分上部をあけるように修正 * ブロックが分かりやすいように改行を追加 * Contentful からスポンサー情報を取得する処理を Vuex に移動する * スポンサー情報は Vuex Store を利用するように修正する * TheSponsorListSection.vue のテストを修正 & 追加 * Vuex Store sponsors のテストを追加 * contentful の .getEntries({order: 'fields.appliedAt'}) でスポンサーをソートするように変更 * 分かりにくいテストにコメントを追加 * sponsors.vue のテストを追加する * .index のアンカーにも trailing slash がついていることをテストで確認した * アンカー移動時のヘッダーとの余白を微調整 * 使っていない SCSS 変数を削除した * header-logo の高さを調節するときのために変数をグローバルに移した * 余計な CSS の important を削除した * banner の定義を Asset に変更 * 余計なコメントを削除 * Contenful に登録された内容をそのまま表示するようにした * existSponsorPlans で sponsorPlans を絞り込んでおくように修正 * テストを修正 * メソッド名を変更 existSponsorPlans -> sponsorPlansToHaveSponsor * store/sponsors.spec.ts のテスト を修正 * fix: 'sponsorPlans を取得できる' -> 'sponsorPlan の一覧を取得できる' * .index のテストを修正 * platinumSponsorWrapper を使うように修正 * fix: 'const platinumSponsor: string = sponsorList[2]' -> 'const platinumSponsor: SponsorPlans = sponsorList[2]' * fix: sponsorPlansToHaveSponsor -> sponsorPlansHavingSponsors * getters をモックせず使うように変更 * Update src/types/sponsors.ts Co-Authored-By: INOUE Takuya <[email protected]> * SponsorPlans を SponsorPlan に名前変更してファイルに切り出した * sponsorsByPlan のテストを修正 * fix: SponsorList -> Sponsor * fix: .base-button に margin-top を設定した場合に development 環境では意図したとおりに余白が設定できるが production 環境では margin 0 auto に上書きされてしまう * スロット構文を Vue.js 2.6 以降の新しい書き方に変更した * テストの書き方をカイゼンした * renamed: test/fixtures/contentful/sponsorList.ts -> test/fixtures/contentful/sponsors.ts
1 parent 126d701 commit cf20720

File tree

17 files changed

+604
-71
lines changed

17 files changed

+604
-71
lines changed

nuxt.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ const config: NuxtConfiguration = {
8282
loading: { color: '#fff' },
8383
css: ['~/assets/stylesheets/main.scss'],
8484
plugins: [
85-
{ src: '~/plugins/typekit', ssr: false },
85+
{ src: '~/plugins/typekit', mode: 'client' },
8686
{ src: '~/plugins/vee-validate' },
87-
{ src: '~/plugins/vue-lazyload', ssr: false }
87+
{ src: '~/plugins/vue-lazyload', mode: 'client' },
88+
{ src: '~/plugins/sponsor-anchor', mode: 'client' }
8889
],
8990
modules: [
9091
'@nuxtjs/dotenv',

src/assets/stylesheets/foundation/variables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ $layout-column-width--is-small-up: calc(
1717

1818
$page-container-max-width: 1180px;
1919

20+
// md サイズ以上のときのヘッダーの高さ
21+
// FIXME: アンカーがあるページ(sponsors など)で使っているため、ヘッダーの高さを変える場合はこの変数を調整する
22+
$header-logo-height: 100px;
23+
2024
// transition のイージング
2125
$easeInOutCubic: cubic-bezier(0.215, 0.61, 0.355, 1);
2226

src/components/TheSponsorListSection.vue

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@
44
SPONSORS
55
</template>
66

7-
<ul v-for="sponsorPlan in sponsorPlans" :key="sponsorPlan.plan">
8-
<li
9-
v-if="sponsorsByPlan(sponsorPlan.plan).length > 0"
10-
class="sponsor-group"
11-
:class="sponsorPlan.plan"
12-
>
7+
<ul
8+
v-for="sponsorPlan in sponsorPlansHavingSponsors"
9+
:key="sponsorPlan.plan"
10+
>
11+
<li class="sponsor-group" :class="sponsorPlan.plan">
1312
<h3 class="sponsor-plan">
1413
{{ sponsorPlan.name }}
1514
</h3>
1615

1716
<ul>
1817
<li
19-
v-for="sponsor in sortSponsors(sponsorsByPlan(sponsorPlan.plan))"
18+
v-for="sponsor in sponsorsByPlan(sponsorPlan.plan)"
2019
:key="sponsor.sys.id"
2120
class="sponsor"
2221
>
23-
<a :href="sponsor.fields.url" target="_blank" rel="noopener">
22+
<nuxt-link :to="`/sponsors/#sponsor_${sponsor.sys.id}`">
2423
<div v-lazy-container="{ selector: 'img' }">
2524
<img
2625
class="sponsor-image"
2726
:data-src="sponsor.fields.banner.fields.file.url"
2827
:alt="sponsor.fields.name"
2928
/>
3029
</div>
31-
</a>
30+
</nuxt-link>
3231
</li>
3332
</ul>
3433
</li>
@@ -37,7 +36,9 @@
3736
</template>
3837

3938
<script lang="ts">
40-
import { Component, Prop, Vue } from 'nuxt-property-decorator'
39+
import { Component, Getter, Vue } from 'nuxt-property-decorator'
40+
import Sponsor from '~/types/sponsor'
41+
import SponsorPlan from '~/types/sponsorPlan'
4142
import BaseSection from '~/components/BaseSection.vue'
4243
4344
@Component({
@@ -46,43 +47,17 @@ import BaseSection from '~/components/BaseSection.vue'
4647
}
4748
})
4849
export default class TheSponsorListSection extends Vue {
49-
sponsorPlans: { plan: string; name: string }[] = [
50-
{ plan: 'platinum', name: 'PLATINUM' },
51-
{ plan: 'gold', name: 'GOLD' },
52-
{ plan: 'silver', name: 'SILVER' },
53-
{ plan: 'bronze', name: 'BRONZE' },
54-
{ plan: 'special', name: 'SPECIAL' },
55-
{ plan: 'room', name: 'ROOM' },
56-
{ plan: 'translation', name: '同時通訳' },
57-
{ plan: 'commercial', name: '幕間 CM' },
58-
{ plan: 'toast', name: 'カンパイ' },
59-
{ plan: 'lunch', name: 'LUNCH' },
60-
{ plan: 'refreshment', name: 'REFRESHMENT' },
61-
{ plan: 'video', name: 'VIDEO' },
62-
{ plan: 'media', name: 'MEDIA' }
63-
]
64-
65-
@Prop()
66-
readonly sponsorList!: any[]
67-
68-
sortSponsors(sponsors): any[] {
69-
return sponsors.sort((a, b) => {
70-
if (a.fields.appliedAt < b.fields.appliedAt) return -1
71-
if (a.fields.appliedAt > b.fields.appliedAt) return 1
72-
73-
return 0
74-
})
75-
}
50+
@Getter('sponsorsByPlan', { namespace: 'sponsors' })
51+
private sponsorsByPlan!: (plan: string) => Sponsor[]
7652
77-
sponsorsByPlan(plan): any[] {
78-
return this.sponsorList.filter(sponsor => sponsor.fields.plan === plan)
79-
}
53+
@Getter('sponsorPlansHavingSponsors', { namespace: 'sponsors' })
54+
private sponsorPlansHavingSponsors!: SponsorPlan[]
8055
}
8156
</script>
8257

8358
<style lang="scss" scoped>
8459
ul {
85-
margin: 0; // このコンポーネントでは ul 要素に margin を持たせない
60+
margin: 0;
8661
}
8762
8863
.the-sponsor-list-section {

src/components/TheStaffListSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<!-- prettier-ignore -->
8-
<template slot="heading-copy">
8+
<template v-slot:heading-copy>
99
Vue Fes Japan 2019 は、Vue.js 日本ユーザーグループのスタッフによって企画・運営されています。
1010
</template>
1111

src/pages/index.vue

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
<TheAccessSection />
77
<TheTimeTableSection />
88
<TheEventSection />
9-
<TheSponsorListSection :sponsor-list="sponsors || []" />
9+
<TheSponsorListSection />
1010
<TheStaffListSection />
1111
</div>
1212
</template>
1313

1414
<script lang="ts">
1515
import { Component, Vue } from 'nuxt-property-decorator'
16-
import { getSponsors } from '~/plugins/contentful.ts'
1716
import TheAccessSection from '~/components/TheAccessSection.vue'
1817
import TheEventSection from '~/components/TheEventSection.vue'
1918
import TheHeadSection from '~/components/TheHeadSection.vue'
@@ -33,17 +32,6 @@ import TheStaffListSection from '~/components/TheStaffListSection.vue'
3332
TheTimeTableSection,
3433
TheSponsorListSection,
3534
TheStaffListSection
36-
},
37-
async asyncData(): Promise<{
38-
sponsors: any[]
39-
} | void> {
40-
try {
41-
return {
42-
sponsors: await getSponsors()
43-
}
44-
} catch (error) {
45-
console.error(error)
46-
}
4735
}
4836
})
4937
export default class HomePage extends Vue {}

0 commit comments

Comments
 (0)