-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
891db0f
commit b872fb6
Showing
5 changed files
with
200 additions
and
18 deletions.
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
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,13 @@ | ||
import { error } from '@sveltejs/kit' | ||
import { api } from '$lib/server/api' | ||
|
||
export async function load({ params }) { | ||
const trophy = await api.trophy.getById(params.id) | ||
if (!trophy || trophy instanceof Error) { | ||
error(404, 'Not found') | ||
} | ||
|
||
return { | ||
trophy, | ||
} | ||
} |
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,156 @@ | ||
<script> | ||
import TimeAgo from 'javascript-time-ago' | ||
import ru from 'javascript-time-ago/locale/ru' | ||
import trophyImage from '$lib/assets/website/trophy-128.png' | ||
import { page } from '$app/stores' | ||
import unit from '$lib/assets/website/unit-64.png' | ||
export let data | ||
TimeAgo.addLocale(ru) | ||
const timeAgo = new TimeAgo('ru-RU') | ||
const latestProfiles = data.trophy.progress.filter((t) => t.status === 'COMPLETED').slice(0, 12) | ||
</script> | ||
|
||
<section class='hero'> | ||
<h1>{data.trophy.name}</h1> | ||
<h2>Трофей, созданный <a href='/{$page.data.locale}/p/hmbanan666'>hmbanan666</a></h2> | ||
</section> | ||
|
||
<section class='trophies'> | ||
<div class='trophy-block'> | ||
<div class='info'> | ||
<p class='description'>{data.trophy.description}</p> | ||
</div> | ||
<div class='completion'> | ||
<div class='trophy'> | ||
<img src={trophyImage} alt="" width='64' height='64' /> | ||
</div> | ||
<div> | ||
<p class='points'>{data.trophy.points}</p> | ||
<p>Очков</p> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class='progress'> | ||
<h2 class='title'>Кто получил этот трофей</h2> | ||
<p class='desc'>Показаны последние профили, которые получили этот трофей.</p> | ||
|
||
<div class='block'> | ||
{#each latestProfiles as progress} | ||
<div class='card'> | ||
<div> | ||
<img src={unit} alt="" /> | ||
</div> | ||
<div> | ||
<a href='/{$page.data.locale}/p/{progress.profile.userName}'>{progress.profile.userName}</a> | ||
</div> | ||
<time>{timeAgo.format(new Date(progress.completedAt))}</time> | ||
</div> | ||
{/each} | ||
</div> | ||
</section> | ||
|
||
<style> | ||
.hero { | ||
padding-top: 4em; | ||
padding-bottom: 4em; | ||
max-width: 64em; | ||
} | ||
.hero h1 { | ||
margin-bottom: 0.25em; | ||
} | ||
section { | ||
text-align: center; | ||
padding: 2em 1em; | ||
margin: 0 auto; | ||
max-width: 42em; | ||
} | ||
.trophy-block { | ||
background-color: #FFEFD6; | ||
border: 2px solid var(--color-border); | ||
display: grid; | ||
grid-template-columns: 2fr 1fr; | ||
margin-bottom: 0.5em; | ||
} | ||
.trophy-block .info { | ||
position: relative; | ||
padding: 1em 1em; | ||
} | ||
.trophy-block .info .description { | ||
font-size: 0.9rem; | ||
} | ||
.trophy-block .completion { | ||
position: relative; | ||
padding: 0.5em 1em; | ||
color: #F76B15; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 0.5em; | ||
} | ||
.trophy-block .completion .points { | ||
font-size: 1.5rem; | ||
font-weight: 600; | ||
line-height: 1.2; | ||
} | ||
.trophy-block .completion .trophy { | ||
opacity: 1; | ||
} | ||
.progress { | ||
padding-top: 2em; | ||
padding-bottom: 4em; | ||
max-width: 64em; | ||
} | ||
.progress .title { | ||
margin-bottom: 0.25em; | ||
} | ||
.progress .desc { | ||
margin-bottom: 1em; | ||
} | ||
.progress .block { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
gap: 0.5em; | ||
} | ||
@media (min-width: 768px) { | ||
.progress .block { | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
} | ||
@media (min-width: 1200px) { | ||
.progress .block { | ||
grid-template-columns: repeat(6, 1fr); | ||
} | ||
} | ||
.progress .block .card { | ||
background-color: var(--color-background-2); | ||
border: 2px solid var(--color-border-2); | ||
padding: 1em; | ||
} | ||
.progress .block .card time { | ||
font-size: 0.8rem; | ||
} | ||
</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