-
Notifications
You must be signed in to change notification settings - Fork 0
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
Contestの詳細ページの作成 #51
Merged
Merged
Contestの詳細ページの作成 #51
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
24d3754
make contest detail page
mehm8128 8f6b417
add contest teams & fix fetcher
mehm8128 2532054
add userIcons
mehm8128 94f2e16
fix link & userIcons count
mehm8128 5d3c3ef
lint & impl search contestTeams
mehm8128 1e23302
add href
mehm8128 927f2c8
fix
mehm8128 4ef03e9
fix link design
mehm8128 00c440a
refactor useFetcher
mehm8128 39f6cda
use fetcherState
mehm8128 e599df3
Merge remote-tracking branch 'origin' into feat/contest_detail_page
mehm8128 545b07a
fix css
mehm8128 6b1c179
fix how to search teams
mehm8128 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script lang="ts" setup> | ||
import UserIcons from '/@/components/UI/UserIcons.vue' | ||
import type { ContestTeam } from '/@/lib/apis' | ||
|
||
interface Props { | ||
contestId: string | ||
contestTeam: ContestTeam | ||
} | ||
|
||
defineProps<Props>() | ||
/* todo:サーバーからmembersが返ってくるようになったらcontestTeam.members.map(member=>member.id)を使う */ | ||
const userIds = ['sapphi_red', 'toshi00', 'tesso', 'mehm8128'] | ||
</script> | ||
|
||
<template> | ||
<router-link | ||
:to="`/contests/${contestId}/teams/${contestTeam.id}/edit`" | ||
:class="$style.link" | ||
> | ||
<div :class="$style.container"> | ||
<div> | ||
<p :class="$style.name">{{ contestTeam.name }}</p> | ||
<p :class="$style.result">{{ contestTeam.result }}</p> | ||
</div> | ||
<user-icons :user-ids="userIds" /> | ||
</div> | ||
</router-link> | ||
</template> | ||
|
||
<style lang="scss" module> | ||
.link { | ||
color: inherit; | ||
text-decoration: none; | ||
} | ||
.container { | ||
padding: 0.5rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
.name { | ||
color: $color-primary; | ||
font-size: 1.125rem; | ||
} | ||
.result { | ||
margin-top: 2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<script lang="ts" setup> | ||
import BaseButton from '/@/components/UI/BaseButton.vue' | ||
|
||
import FormInput from '/@/components/UI/FormInput.vue' | ||
import ContestTeamItem from '/@/components/Contest/ContestTeamItem.vue' | ||
import { RouterLink } from 'vue-router' | ||
import { ContestTeam } from '/@/lib/apis' | ||
import { computed, ref } from 'vue' | ||
|
||
interface Props { | ||
contestId: string | ||
contestTeams: ContestTeam[] | ||
} | ||
|
||
const props = defineProps<Props>() | ||
|
||
const searchQuery = ref('') | ||
// todo: serverでやるかも | ||
const searchedContestTeams = computed( | ||
() => | ||
props.contestTeams.filter(contestTeam => { | ||
const regexp = new RegExp(searchQuery.value, 'i') | ||
return regexp.test(contestTeam.name) | ||
}) ?? [] | ||
) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div :class="$style.searchFormContainer"> | ||
<div :class="$style.searchForm"> | ||
<p :class="$style.searchFormDescriptionText">検索</p> | ||
<form-input | ||
v-model="searchQuery" | ||
placeholder="チーム名" | ||
icon="magnify" | ||
/> | ||
</div> | ||
<div :class="$style.newTeamLink"> | ||
<p :class="$style.searchFormDescriptionText">チーム作成</p> | ||
<router-link | ||
:to="`/contests/${contestId}/teams/new`" | ||
:class="$style.link" | ||
> | ||
<base-button type="primary" icon="mdi:plus">New</base-button> | ||
</router-link> | ||
</div> | ||
</div> | ||
<ul :class="$style.teamList"> | ||
<li v-for="contestTeam in searchedContestTeams" :key="contestTeam.id"> | ||
<contest-team-item | ||
:contest-id="contestId" | ||
:contest-team="contestTeam" | ||
/> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" module> | ||
.searchFormContainer { | ||
display: flex; | ||
align-items: center; | ||
margin-top: 0.5rem; | ||
} | ||
.searchFormDescriptionText { | ||
color: $color-secondary; | ||
font-size: 0.875rem; | ||
} | ||
.searchForm { | ||
flex-grow: 1; | ||
} | ||
.newTeamLink { | ||
margin-left: 0.5rem; | ||
} | ||
.link { | ||
text-decoration: none; | ||
color: inherit; | ||
} | ||
.teamList { | ||
list-style: none; | ||
padding: 0.5rem 0; | ||
li { | ||
border: 1px solid $color-primary-text; | ||
border-radius: 8px; | ||
margin-bottom: 0.5rem; | ||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
&:hover { | ||
background-color: $color-background-dim; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts" setup> | ||
import UserIcon from '/@/components/UI/UserIcon.vue' | ||
interface Props { | ||
userIds: string[] | ||
} | ||
|
||
defineProps<Props>() | ||
</script> | ||
|
||
<template> | ||
<div :class="$style.userIcons"> | ||
<user-icon | ||
v-for="(userId, i) in userIds.slice(0, 3)" | ||
:key="userId" | ||
:user-id="userId" | ||
:class="$style.userIcon" | ||
:style="{ left: `${i * 16}px` }" | ||
/> | ||
<span v-if="userIds.length > 3">+{{ userIds.length - 3 }}</span> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" module> | ||
.userIcons { | ||
width: 80px; | ||
position: relative; | ||
text-align: right; | ||
} | ||
.userIcon { | ||
position: absolute; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,123 @@ | ||
<script lang="ts" setup> | ||
import ContentHeader from '/@/components/Layout/ContentHeader.vue' | ||
import PageContainer from '/@/components/Layout/PageContainer.vue' | ||
import BaseButton from '/@/components/UI/BaseButton.vue' | ||
|
||
import apis, { ContestDetail, ContestTeam } from '/@/lib/apis' | ||
import { RouterLink } from 'vue-router' | ||
import { getDisplayDuration } from '/@/lib/date' | ||
import Icon from '/@/components/UI/Icon.vue' | ||
import useParam from '/@/use/param' | ||
import { useFetcher } from '/@/use/fetcher' | ||
import ContestTeamsComponent from '/@/components/Contest/ContestTeams.vue' | ||
|
||
const contestId = useParam('id') | ||
const { data: contest } = useFetcher<ContestDetail>(() => | ||
apis.getContest(contestId.value) | ||
) | ||
const { data: contestTeams, fetcherState } = useFetcher<ContestTeam[]>(() => | ||
apis.getContestTeams(contestId.value) | ||
) | ||
</script> | ||
|
||
<template> | ||
<page-container> | ||
<div>ContestDetail</div> | ||
<div :class="$style.headerContainer"> | ||
<content-header | ||
icon-name="mdi:trophy-outline" | ||
:header-texts="[ | ||
{ title: 'Contests', url: '/contests' }, | ||
{ title: contest?.name ?? '', url: `/contests/${contestId}` } | ||
]" | ||
detail="コンテストの詳細です。" | ||
:class="$style.header" | ||
/> | ||
<router-link :to="`/contests/${contestId}/edit`" :class="$style.link"> | ||
<base-button type="primary" icon="mdi:pencil">Edit</base-button> | ||
</router-link> | ||
</div> | ||
<div v-if="contest !== undefined && fetcherState === 'loaded'"> | ||
<section :class="$style.section"> | ||
<h2 :class="$style.h2">コンテスト名</h2> | ||
<p :class="$style.content">{{ contest.name }}</p> | ||
</section> | ||
<section :class="$style.section"> | ||
<h2 :class="$style.h2">日時</h2> | ||
<p :class="$style.content"> | ||
{{ getDisplayDuration(contest.duration) }} | ||
</p> | ||
</section> | ||
<section :class="$style.section"> | ||
<h2 :class="$style.h2">リンク</h2> | ||
<p :class="[$style.content, $style.contestLinkContainer]"> | ||
<icon name="mdi:open-in-new" /> | ||
<a :class="$style.contestLink" :href="contest.link"> | ||
{{ contest.link }} | ||
</a> | ||
</p> | ||
</section> | ||
<section :class="$style.section"> | ||
<h2 :class="$style.h2">説明</h2> | ||
<p :class="$style.content">{{ contest.description }}</p> | ||
</section> | ||
<section :class="$style.section"> | ||
<h2 :class="$style.h2">チーム</h2> | ||
<contest-teams-component | ||
v-if="contestTeams !== undefined" | ||
:class="$style.content" | ||
:contest-id="contestId" | ||
:contest-teams="contestTeams" | ||
/> | ||
</section> | ||
</div> | ||
<p v-else-if="fetcherState === 'loading'">ローディング中...</p> | ||
<p v-else-if="fetcherState === 'error'">エラーが発生しました</p> | ||
|
||
<router-link to="/contests" :class="$style.link"> | ||
<base-button | ||
:class="$style.backButton" | ||
type="secondary" | ||
icon="mdi:arrow-left" | ||
> | ||
Back | ||
</base-button> | ||
</router-link> | ||
</page-container> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import PageContainer from '/@/components/Layout/PageContainer.vue' | ||
|
||
export default defineComponent({ | ||
name: 'Contest', | ||
components: { | ||
PageContainer | ||
}, | ||
setup() { | ||
return {} | ||
} | ||
}) | ||
</script> | ||
<style lang="scss" module> | ||
.headerContainer { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
.header { | ||
margin: 4rem 0 2rem; | ||
} | ||
.link { | ||
text-decoration: none; | ||
color: inherit; | ||
} | ||
.section { | ||
margin-bottom: 2rem; | ||
} | ||
.h2 { | ||
font-weight: bold; | ||
font-size: 1.25rem; | ||
} | ||
.content { | ||
margin-top: 0.5rem; | ||
padding-left: 0.5rem; | ||
} | ||
.contestLinkContainer { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
} | ||
.contestLink { | ||
color: $color-text; | ||
} | ||
.backButton { | ||
margin-top: 2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:kansya: