Skip to content

Commit

Permalink
Правки ревью k0ndratov
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur233 committed Sep 30, 2024
1 parent 0768737 commit 9daba7e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
21 changes: 9 additions & 12 deletions packages/client/src/components/common/Modal/Modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,27 @@ $border-color: #70842f;
inset: 0;
z-index: -1;

&::before {
@mixin borderDecorSettings($top, $bottom) {
content: '';
position: absolute;
height: 8px;
top: $top;
bottom: $bottom;
left: 0;
top: 0;
right: 0;
height: 8px;

background: url('@/assets/images/svg/title-decor.svg') no-repeat center
center;
background-size: contain;
}

&::before {
@include borderDecorSettings(0, auto);
}

&::after {
content: '';
position: absolute;
height: 8px;
left: 0;
bottom: 0;
right: 0;
@include borderDecorSettings(auto, 0);

background: url('@/assets/images/svg/title-decor.svg') no-repeat center
center;
background-size: contain;
transform: rotate(180deg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/common/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Icon } from '@/components/ui/Icon/Icon'
import './Modal.scss'

type ModalPropsType = {
show?: boolean
show: boolean
onClose: () => void
width?: number | null
height?: number | null
Expand Down
19 changes: 19 additions & 0 deletions packages/client/src/components/ui/Loader/Loader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ $road-color: #2c414c;
&__image {
width: 60px;
}

&__close-btn {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, 100px);
cursor: pointer;

background: none;
border: none;
outline: none;

color: $text-color;
font-size: 14px;

&:hover {
text-decoration: underline;
}
}
}

@keyframes moveRoad {
Expand Down
26 changes: 24 additions & 2 deletions packages/client/src/components/ui/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import './Loader.scss'
import { useEffect, useState } from 'react'
import LoaderGif from '@/assets/images/loader.png'

type LoaderPropsType = {
show?: boolean
show: boolean
onClose?: () => void
}

export const Loader = (props: LoaderPropsType) => {
const { show } = props
const { show, onClose } = props
const [showCloseButton, setShowCloseButton] = useState(false)

useEffect(() => {
let timer: NodeJS.Timeout

if (show) {
timer = setTimeout(() => {
setShowCloseButton(true)
}, 5000)
} else {
setShowCloseButton(false)
}

return () => clearTimeout(timer)
}, [show])

return (
<div className={`preloader ${show ? 'preloader_show' : ''}`}>
<div className="preloader__road">
<img className="preloader__image" src={LoaderGif} alt="loader" />
</div>
{showCloseButton && (
<button className="preloader__close-btn" onClick={onClose}>
Закрыть
</button>
)}
</div>
)
}
2 changes: 1 addition & 1 deletion packages/client/src/pages/Game/Game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $border-color: #70842f;
position: absolute;
height: 8px;

@include customPosition(auto, 0, 0, 0);
@include customPosition(0, auto, 0, 0);

background: url('@/assets/images/svg/title-decor.svg') no-repeat center
center;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/pages/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useEffect, useState } from 'react'
import { Modal } from '@/components/common/Modal/Modal'
import GameInfo from '@/assets/images/game-info.jpg'
import { Button } from '@/components/ui/Button/Button'
import { Loader } from '@/components/ui/Loader/Loader'

export const Game = () => {
const [isInfoModalOpen, setIsInfoModalOpen] = useState(false)
Expand Down Expand Up @@ -37,6 +38,7 @@ export const Game = () => {
setButtonsState({ ...buttonsState, [buttonName]: state })
}

// TODO: Заменить на финальное решение для отслеживания кнопок
useEffect(() => {
const handleKey = (event: KeyboardEvent) => {
const isKeydown = event.type === 'keydown'
Expand Down

0 comments on commit 9daba7e

Please sign in to comment.