Skip to content

feat: スポンサー一覧ページを作成する #170

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

Merged
merged 85 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
3b994c4
wip
ryamakuchi Sep 1, 2019
2a87625
add pages/sponsors.vue
ryamakuchi Sep 1, 2019
45014e6
path は /sponsors で不変のため余分なロジックを消した
ryamakuchi Sep 1, 2019
fb1cc1b
Contentful からスポンサー情報を取得できるようにした
ryamakuchi Sep 1, 2019
90900c7
Home と同じようにスポンサー一覧を表示した
ryamakuchi Sep 1, 2019
c486419
sm サイズのコーディング
ryamakuchi Sep 4, 2019
e4229eb
md サイズのコーディング
ryamakuchi Sep 4, 2019
a639a6f
アンカー以外の lg サイズのコーディング
ryamakuchi Sep 4, 2019
c5b824c
アンカーをつけた
ryamakuchi Sep 5, 2019
2f16dfb
smooth スクロールを実装した
ryamakuchi Sep 5, 2019
277eb07
スクロールしたときに意図した位置までいくように画像の lazyload を外した
ryamakuchi Sep 5, 2019
e4f8cb3
/sponsors の中のみスクロールするように修正
ryamakuchi Sep 5, 2019
5b55351
.active 以外の nav レイアウトを追加した(lg サイズ以上)
ryamakuchi Sep 6, 2019
fdc75ed
nav でもスポンサーのいないプランは非表示になるように
ryamakuchi Sep 6, 2019
24179e7
lg サイズ以上の全体の余白の調整
ryamakuchi Sep 6, 2019
79caba9
-margin の中の計算を分かりやすく正しく直した
ryamakuchi Sep 6, 2019
349a418
.nuxt-link-active のときのスタイルを追加
ryamakuchi Sep 6, 2019
7fbd178
lg サイズのアンカーにインタラクションをつける
ryamakuchi Sep 8, 2019
1059133
型をつけた
ryamakuchi Sep 8, 2019
9ec0bf2
トップページののリンクを /sponsors に変更した
ryamakuchi Sep 8, 2019
add7405
.nav の余計な要素を表示させないように修正
ryamakuchi Sep 8, 2019
79e3ef7
yarn lint:fix
ryamakuchi Sep 8, 2019
667a390
Merge branch 'master' into add-sponsor-details
ryamakuchi Sep 8, 2019
e09a1d1
sponsors.spec.ts を追加
ryamakuchi Sep 8, 2019
f0e051a
TheSponsorListSection.spec.ts に出ていた warn を解消
ryamakuchi Sep 8, 2019
82e9292
SponsorsPage のテストに sponsorListMock を追加
ryamakuchi Sep 8, 2019
5fdad4d
SponsorsPage にテストケースを追加した
ryamakuchi Sep 8, 2019
0e1b15c
padding ではなく左右の余白は margin でとるように修正
ryamakuchi Sep 8, 2019
ba9ed6c
lg のローカルナビのフォントサイズやナビ同士の間隔を調整する
ryamakuchi Sep 9, 2019
08c51ac
スムーズスクロールを window.scroll に切り替える
ryamakuchi Sep 9, 2019
3bf1e8e
sm の .sponsor-name を line-height: 1; に修正する
ryamakuchi Sep 9, 2019
af8a1e7
トップに戻るボタンにスタイルを当てるためににクラスをつけた
ryamakuchi Sep 9, 2019
d0f7c1f
bronze は PR 文掲載なしに修正
ryamakuchi Sep 9, 2019
c23bf3f
トップに戻るボタンのスタイルの適用優先順位を変更した
ryamakuchi Sep 9, 2019
817a535
fix: warning Attribute v-if should go before class
ryamakuchi Sep 9, 2019
f5f1583
sm サイズの PR 文と URL のフォントサイズを微調整
ryamakuchi Sep 9, 2019
6f43c54
fix: margin の余分な指定を削除
ryamakuchi Sep 9, 2019
4d758e6
Update src/pages/sponsors.vue
ryamakuchi Sep 11, 2019
f42d877
Update src/components/TheSponsorListSection.vue
ryamakuchi Sep 11, 2019
f283354
Update nuxt.config.ts
ryamakuchi Sep 11, 2019
4ee4d38
Fix: .sponsor-list -> .sponsor-group-list
ryamakuchi Sep 12, 2019
952a2c6
Fix: .nav -> .index
ryamakuchi Sep 12, 2019
8705de8
Fix: Trailing Slash
ryamakuchi Sep 12, 2019
09e634e
lg サイズ以上のインタラクションに関係するコードを削除
ryamakuchi Sep 12, 2019
dc0b4e9
Fix 非推奨の書き方 ssr: false -> mode: client
ryamakuchi Sep 12, 2019
e8fa7c7
アンカーを修正
ryamakuchi Sep 14, 2019
c4f4212
余白の調整
ryamakuchi Sep 14, 2019
9325372
余分な変数を削除
ryamakuchi Sep 14, 2019
67237fa
スクロールするときにヘッダーの高さ分上部をあけるように修正
ryamakuchi Sep 15, 2019
b6a0319
Merge branch 'master' into add-sponsor-details
ryamakuchi Sep 22, 2019
9bb14af
ブロックが分かりやすいように改行を追加
ryamakuchi Sep 22, 2019
bfd7d9f
Contentful からスポンサー情報を取得する処理を Vuex に移動する
ryamakuchi Sep 22, 2019
0002a80
スポンサー情報は Vuex Store を利用するように修正する
ryamakuchi Sep 22, 2019
bc5609b
TheSponsorListSection.vue のテストを修正 & 追加
ryamakuchi Sep 22, 2019
b02c7af
Vuex Store sponsors のテストを追加
ryamakuchi Sep 22, 2019
650c2c3
contentful の .getEntries({order: 'fields.appliedAt'}) でスポンサーをソートするように変更
ryamakuchi Sep 22, 2019
5f982dd
分かりにくいテストにコメントを追加
ryamakuchi Sep 22, 2019
75f20eb
sponsors.vue のテストを追加する
ryamakuchi Sep 23, 2019
b602271
.index のアンカーにも trailing slash がついていることをテストで確認した
ryamakuchi Sep 23, 2019
655824d
アンカー移動時のヘッダーとの余白を微調整
ryamakuchi Sep 23, 2019
348dc7b
使っていない SCSS 変数を削除した
ryamakuchi Sep 23, 2019
ffeeb88
header-logo の高さを調節するときのために変数をグローバルに移した
ryamakuchi Sep 23, 2019
ef8012a
余計な CSS の important を削除した
ryamakuchi Sep 23, 2019
5d0beec
banner の定義を Asset に変更
ryamakuchi Sep 23, 2019
89ef943
余計なコメントを削除
ryamakuchi Sep 23, 2019
b05c192
Contenful に登録された内容をそのまま表示するようにした
ryamakuchi Sep 24, 2019
b896ec9
existSponsorPlans で sponsorPlans を絞り込んでおくように修正
ryamakuchi Sep 26, 2019
9413e18
テストを修正
ryamakuchi Sep 28, 2019
d3fa102
メソッド名を変更 existSponsorPlans -> sponsorPlansToHaveSponsor
ryamakuchi Sep 28, 2019
d31af67
store/sponsors.spec.ts のテスト を修正
ryamakuchi Sep 28, 2019
e8da82f
fix: 'sponsorPlans を取得できる' -> 'sponsorPlan の一覧を取得できる'
ryamakuchi Sep 28, 2019
166480f
.index のテストを修正
ryamakuchi Sep 28, 2019
51e8eeb
platinumSponsorWrapper を使うように修正
ryamakuchi Sep 28, 2019
340092f
fix: 'const platinumSponsor: string = sponsorList[2]' -> 'const plati…
ryamakuchi Sep 28, 2019
f07da6f
fix: sponsorPlansToHaveSponsor -> sponsorPlansHavingSponsors
ryamakuchi Sep 28, 2019
d17e4a5
getters をモックせず使うように変更
ryamakuchi Sep 28, 2019
2b9adf2
Update src/types/sponsors.ts
ryamakuchi Sep 28, 2019
dc54f27
Merge branch 'add-sponsor-details' of github.com:kazupon/vuefes-2019 …
ryamakuchi Sep 28, 2019
1b9e897
SponsorPlans を SponsorPlan に名前変更してファイルに切り出した
ryamakuchi Sep 28, 2019
496e1b0
sponsorsByPlan のテストを修正
ryamakuchi Sep 28, 2019
60e9470
fix: SponsorList -> Sponsor
ryamakuchi Sep 28, 2019
46eb930
fix: .base-button に margin-top を設定した場合に development 環境では意図したとおりに余白が設定…
inouetakuya Sep 29, 2019
8e8e69a
スロット構文を Vue.js 2.6 以降の新しい書き方に変更した
inouetakuya Sep 29, 2019
c88cc68
テストの書き方をカイゼンした
inouetakuya Sep 29, 2019
44c88e0
renamed: test/fixtures/contentful/sponsorList.ts -> test/fixtures/con…
inouetakuya Sep 29, 2019
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
5 changes: 3 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ const config: NuxtConfiguration = {
loading: { color: '#fff' },
css: ['~/assets/stylesheets/main.scss'],
plugins: [
{ src: '~/plugins/typekit', ssr: false },
{ src: '~/plugins/typekit', mode: 'client' },
{ src: '~/plugins/vee-validate' },
{ src: '~/plugins/vue-lazyload', ssr: false }
{ src: '~/plugins/vue-lazyload', mode: 'client' },
{ src: '~/plugins/sponsor-anchor', mode: 'client' }
],
modules: [
'@nuxtjs/dotenv',
Expand Down
4 changes: 4 additions & 0 deletions src/assets/stylesheets/foundation/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ $layout-column-width--is-small-up: calc(

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

// md サイズ以上のときのヘッダーの高さ
// FIXME: アンカーがあるページ(sponsors など)で使っているため、ヘッダーの高さを変える場合はこの変数を調整する
$header-logo-height: 100px;

// transition のイージング
$easeInOutCubic: cubic-bezier(0.215, 0.61, 0.355, 1);

Expand Down
57 changes: 16 additions & 41 deletions src/components/TheSponsorListSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,30 @@
SPONSORS
</template>

<ul v-for="sponsorPlan in sponsorPlans" :key="sponsorPlan.plan">
<li
v-if="sponsorsByPlan(sponsorPlan.plan).length > 0"
class="sponsor-group"
:class="sponsorPlan.plan"
>
<ul
v-for="sponsorPlan in sponsorPlansHavingSponsors"
:key="sponsorPlan.plan"
>
<li class="sponsor-group" :class="sponsorPlan.plan">
<h3 class="sponsor-plan">
{{ sponsorPlan.name }}
</h3>

<ul>
<li
v-for="sponsor in sortSponsors(sponsorsByPlan(sponsorPlan.plan))"
v-for="sponsor in sponsorsByPlan(sponsorPlan.plan)"
:key="sponsor.sys.id"
class="sponsor"
>
<a :href="sponsor.fields.url" target="_blank" rel="noopener">
<nuxt-link :to="`/sponsors/#sponsor_${sponsor.sys.id}`">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スポンサー配下であり、スポンサー情報であることは自明なので、下記でどうでしょう?

Suggested change
<nuxt-link :to="`/sponsors/#sponsor_${sponsor.sys.id}`">
<nuxt-link :to="`/sponsors/#${sponsor.sys.id}`">

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML の id 属性が数字から始まる場合、アンカーがうまく動作しないことがあったため sponsor_ プレフィックスを入れました。

ちなみに数字で始まる sponsor.sys.id もあるため、プレフィックスを外すとうまく動作しないことが分かるかと思います。

確か HTML の仕様で id や class 属性の先頭に数字をつけられなかったと思うのですが、W3C や WHATWG や MDN の仕様書を探しても一次ソースを見つけることができず 😢(すみません...)
もし一次情報の記事を知っていたら教えていただけるとうれしいです! 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML の id 属性が数字から始まる場合、アンカーがうまく動作しないことがあったため sponsor_ プレフィックスを入れました。

あー、なるほど 👍

そすねー、自分もどうやって知ったんだっけなあ 🤔

結論

分かんない。途中まで調べたけど結局最後まで辿り着けませんでした。

後日、分かったら共有しますね〜

以下調べたログ

RFC3986

URI については RFC 3986 で定義されていますね。

RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax
https://tools.ietf.org/html/rfc3986

RFC3986 で fragment あるいは fragment identifier と表記されているので、そちらの用語で調べた方がほしい情報に辿り着きやすそうです。

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

RFC2046

The fragment's format and resolution is therefore
dependent on the media type [RFC2046] of a potentially retrieved
representation, even though such a retrieval is only performed if the
URI is dereferenced.

という記述があり、つまり、fragment の format は RFC2046 に依存しているよ、と。

で、RFC2046 の中から、フラグメント識別子のフォーマットに関する記述を探してみたのですが、全然わからねえ...

<div v-lazy-container="{ selector: 'img' }">
<img
class="sponsor-image"
:data-src="sponsor.fields.banner.fields.file.url"
:alt="sponsor.fields.name"
/>
</div>
</a>
</nuxt-link>
</li>
</ul>
</li>
Expand All @@ -37,7 +36,9 @@
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'nuxt-property-decorator'
import { Component, Getter, Vue } from 'nuxt-property-decorator'
import Sponsor from '~/types/sponsor'
import SponsorPlan from '~/types/sponsorPlan'
import BaseSection from '~/components/BaseSection.vue'

@Component({
Expand All @@ -46,43 +47,17 @@ import BaseSection from '~/components/BaseSection.vue'
}
})
export default class TheSponsorListSection extends Vue {
sponsorPlans: { plan: string; name: string }[] = [
{ plan: 'platinum', name: 'PLATINUM' },
{ plan: 'gold', name: 'GOLD' },
{ plan: 'silver', name: 'SILVER' },
{ plan: 'bronze', name: 'BRONZE' },
{ plan: 'special', name: 'SPECIAL' },
{ plan: 'room', name: 'ROOM' },
{ plan: 'translation', name: '同時通訳' },
{ plan: 'commercial', name: '幕間 CM' },
{ plan: 'toast', name: 'カンパイ' },
{ plan: 'lunch', name: 'LUNCH' },
{ plan: 'refreshment', name: 'REFRESHMENT' },
{ plan: 'video', name: 'VIDEO' },
{ plan: 'media', name: 'MEDIA' }
]

@Prop()
readonly sponsorList!: any[]

sortSponsors(sponsors): any[] {
return sponsors.sort((a, b) => {
if (a.fields.appliedAt < b.fields.appliedAt) return -1
if (a.fields.appliedAt > b.fields.appliedAt) return 1

return 0
})
}
@Getter('sponsorsByPlan', { namespace: 'sponsors' })
private sponsorsByPlan!: (plan: string) => Sponsor[]

sponsorsByPlan(plan): any[] {
return this.sponsorList.filter(sponsor => sponsor.fields.plan === plan)
}
@Getter('sponsorPlansHavingSponsors', { namespace: 'sponsors' })
private sponsorPlansHavingSponsors!: SponsorPlan[]
}
</script>

<style lang="scss" scoped>
ul {
margin: 0; // このコンポーネントでは ul 要素に margin を持たせない
margin: 0;
}

.the-sponsor-list-section {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TheStaffListSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

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

Expand Down
14 changes: 1 addition & 13 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<TheAccessSection />
<TheTimeTableSection />
<TheEventSection />
<TheSponsorListSection :sponsor-list="sponsors || []" />
<TheSponsorListSection />
<TheStaffListSection />
</div>
</template>

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import { getSponsors } from '~/plugins/contentful.ts'
import TheAccessSection from '~/components/TheAccessSection.vue'
import TheEventSection from '~/components/TheEventSection.vue'
import TheHeadSection from '~/components/TheHeadSection.vue'
Expand All @@ -33,17 +32,6 @@ import TheStaffListSection from '~/components/TheStaffListSection.vue'
TheTimeTableSection,
TheSponsorListSection,
TheStaffListSection
},
async asyncData(): Promise<{
sponsors: any[]
} | void> {
try {
return {
sponsors: await getSponsors()
}
} catch (error) {
console.error(error)
}
}
})
export default class HomePage extends Vue {}
Expand Down
Loading