Skip to content

Commit

Permalink
chore: some rework (#205)
Browse files Browse the repository at this point in the history
* chore: some rework

* chore: testing server

* fix: removed action
  • Loading branch information
hmbanan666 authored Aug 21, 2024
1 parent 6a6f64c commit 707bd8c
Show file tree
Hide file tree
Showing 17 changed files with 288 additions and 75 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
node_modules
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
# - run: yarn nx-cloud record -- echo Hello World
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
- run: yarn nx affected -t lint test build e2e-ci
- run: yarn nx affected -t lint test build
49 changes: 0 additions & 49 deletions .github/workflows/test-and-lint.yml

This file was deleted.

8 changes: 7 additions & 1 deletion apps/website/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"projectType": "application",
"sourceRoot": "apps/website/src",
"// targets": "to see all targets run: nx show project website --web",
"targets": {}
"targets": {
"lint": {
"options": {
"fix": true
}
}
}
}
2 changes: 1 addition & 1 deletion apps/website/src/components/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { width } = useWindowSize()

<template>
<header>
<div class='left'>
<div class="left">
<MainLogo />

<!-- <Locale /> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ const randomCharUrl = `url(/units/${randomChar}/128.png)`

<template>
<div>
<div v-if="$route.path === '/'" class="logo" :style="{ backgroundImage: randomCharUrl }"/>
<NuxtLink v-else href='/'>
<div class="logo shake" :style="{ backgroundImage: randomCharUrl }"/>
<div
v-if="$route.path === '/'"
class="logo"
:style="{ backgroundImage: randomCharUrl }"
/>
<NuxtLink
v-else
href="/"
>
<div
class="logo shake"
:style="{ backgroundImage: randomCharUrl }"
/>
</NuxtLink>
</div>
</template>
Expand Down
26 changes: 19 additions & 7 deletions apps/website/src/components/MenuDesktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,34 @@ const route = useRoute()
<nav>
<ul>
<li :aria-current="route.path === `/` ? 'page' : undefined">
<NuxtLink to='/'>Главная</NuxtLink>
<NuxtLink to="/">
Главная
</NuxtLink>
</li>
<li :aria-current="route.path === `/about` ? 'page' : undefined">
<NuxtLink to='/about'>About</NuxtLink>
<NuxtLink to="/about">
About
</NuxtLink>
</li>
<li :aria-current="route.path === `/character` ? 'page' : undefined">
<NuxtLink to='/character'>Персонажи</NuxtLink>
<NuxtLink to="/character">
Персонажи
</NuxtLink>
</li>
<li :aria-current="route.path === `/quest` ? 'page' : undefined">
<NuxtLink href='/quest'>Задания</NuxtLink>
<NuxtLink href="/quest">
Задания
</NuxtLink>
</li>
<li :aria-current="route.path === `/trophy` ? 'page' : undefined">
<NuxtLink href='/trophy'>Трофеи</NuxtLink>
<NuxtLink href="/trophy">
Трофеи
</NuxtLink>
</li>
<li :aria-current="route.path === `/coupon` ? 'page' : undefined">
<NuxtLink href='/coupon'>Купон</NuxtLink>
<NuxtLink href="/coupon">
Купон
</NuxtLink>
</li>
<!--
{#if profile}
Expand All @@ -32,7 +44,7 @@ const route = useRoute()
</ul>
</nav>

<div class='right'>
<div class="right">
<div class="items">
<Profile />
</div>
Expand Down
35 changes: 30 additions & 5 deletions apps/website/src/components/MenuHamburger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,36 @@ const website = useWebsiteStore()
</script>

<template>
<button class='burger' :class="{open: website.isMobileMenuOpened}" @click="() => website.isMobileMenuOpened = !website.isMobileMenuOpened">
<svg width='32' height='24'>
<line id='top' x1='0' y1='2' x2='32' y2='2' />
<line id='middle' x1='0' y1='12' x2='32' y2='12' />
<line id='bottom' x1='0' y1='22' x2='32' y2='22' />
<button
class="burger"
:class="{open: website.isMobileMenuOpened}"
@click="() => website.isMobileMenuOpened = !website.isMobileMenuOpened"
>
<svg
width="32"
height="24"
>
<line
id="top"
x1="0"
y1="2"
x2="32"
y2="2"
/>
<line
id="middle"
x1="0"
y1="12"
x2="32"
y2="12"
/>
<line
id="bottom"
x1="0"
y1="22"
x2="32"
y2="22"
/>
</svg>
</button>
</template>
Expand Down
37 changes: 31 additions & 6 deletions apps/website/src/components/MenuSmartphone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,44 @@ function closeSidebar() {
<nav>
<ul>
<li :aria-current="route.path === `/` ? 'page' : undefined">
<NuxtLink to='/' @click="closeSidebar">Главная</NuxtLink>
<NuxtLink
to="/"
@click="closeSidebar"
>
Главная
</NuxtLink>
</li>
<li :aria-current="route.path === `/character` ? 'page' : undefined">
<NuxtLink to='/character' @click="closeSidebar">Персонажи</NuxtLink>
<NuxtLink
to="/character"
@click="closeSidebar"
>
Персонажи
</NuxtLink>
</li>
<li :aria-current="route.path === `/quest` ? 'page' : undefined">
<NuxtLink href='/quest' @click="closeSidebar">Задания</NuxtLink>
<NuxtLink
href="/quest"
@click="closeSidebar"
>
Задания
</NuxtLink>
</li>
<li :aria-current="route.path === `/trophy` ? 'page' : undefined">
<NuxtLink href='/trophy' @click="closeSidebar">Трофеи</NuxtLink>
<NuxtLink
href="/trophy"
@click="closeSidebar"
>
Трофеи
</NuxtLink>
</li>
<li :aria-current="route.path === `/coupon` ? 'page' : undefined">
<NuxtLink href='/coupon' @click="closeSidebar">Купон</NuxtLink>
<NuxtLink
href="/coupon"
@click="closeSidebar"
>
Купон
</NuxtLink>
</li>
<!--
{#if profile}
Expand All @@ -36,7 +61,7 @@ function closeSidebar() {
</nav>
</aside>

<div class='profile-block'>
<div class="profile-block">
<Profile />
</div>

Expand Down
7 changes: 5 additions & 2 deletions apps/website/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const profileCount = 1
<template>
<div>
<section class="hero">

<h1>Интерактивная чат-игра для Twitch</h1>
<h2>
Группа игроков сопровождает Машину из точки А в точку Б, не зная, доберутся
Expand All @@ -27,7 +26,11 @@ const profileCount = 1
зрители развлекаются или...
</p>
<p class="mt-2">
За все время {{ pluralizationRu(profileCount, ['создан','создано','создано']) }} {{profileCount}} {{ pluralizationRu(profileCount, ['профиль','профиля','профилей']) }}. Присоединяйся <a href={config.twitch.url} target="_blank" class="twitch-link">на активном стриме</a>!
За все время {{ pluralizationRu(profileCount, ['создан','создано','создано']) }} {{ profileCount }} {{ pluralizationRu(profileCount, ['профиль','профиля','профилей']) }}. Присоединяйся <a
href="{config.twitch.url}"
target="_blank"
class="twitch-link"
>на активном стриме</a>!
</p>
</section>
</div>
Expand Down
9 changes: 9 additions & 0 deletions apps/website/src/server/plugins/start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { log } from "../utils/logger"

export default defineNitroPlugin(() => {
log('Server started!')

setInterval(() => {
log('Server is OK...')
}, 60000)
})
12 changes: 12 additions & 0 deletions apps/website/src/server/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export function log(...args: string[]) {
console.log(`[${new Date().toLocaleString('en-US', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
timeZone: 'UTC',
hour12: false,
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})}]`, ...args)
}
68 changes: 68 additions & 0 deletions apps/website/src/utils/__tests__/date.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {getDateMinusMinutes,getDatePlusMinutes,getDatePlusSeconds} from '../date'
import { describe, expect, it } from 'vitest'

describe('getDatePlusMinutes()', () => {
it('returns the current date and time plus the specified minutes', () => {
const minutesToAdd = 5
const result = getDatePlusMinutes(minutesToAdd)
const expected = new Date(Date.now() + minutesToAdd * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero minutes', () => {
const result = getDatePlusMinutes(0)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative minutes', () => {
const minutesToAdd = -5
const result = getDatePlusMinutes(minutesToAdd)
const expected = new Date(Date.now() + minutesToAdd * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})

describe('getDateMinusMinutes()', () => {
it('returns the current date and time minus the specified minutes', () => {
const minutesToSubtract = 5
const result = getDateMinusMinutes(minutesToSubtract)
const expected = new Date(Date.now() - minutesToSubtract * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero minutes', () => {
const result = getDateMinusMinutes(0)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative minutes', () => {
const minutesToSubtract = -5
const result = getDateMinusMinutes(minutesToSubtract)
const expected = new Date(Date.now() - minutesToSubtract * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})

describe('getDatePlusSeconds()', () => {
it('returns the current date and time plus the specified seconds', () => {
const secondsToAdd = 5
const result = getDatePlusSeconds(secondsToAdd)
const expected = new Date(Date.now() + secondsToAdd * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero seconds', () => {
const result = getDatePlusSeconds(0)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative seconds', () => {
const secondsToAdd = -5
const result = getDatePlusSeconds(secondsToAdd)
const expected = new Date(Date.now() + secondsToAdd * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})
Loading

0 comments on commit 707bd8c

Please sign in to comment.