ts @types. React hooks

This commit is contained in:
grinikita 2025-04-27 19:56:23 +03:00
parent a621b0f6ab
commit 330e4c0d74
13 changed files with 238 additions and 146 deletions

4
@types/assets/index.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module '*.png' {
const path: string;
export default path;
}

View File

@ -5,7 +5,8 @@
"scripts": {
"start": "webpack serve --mode=development",
"build": "webpack --mode=development",
"dev": "webpack --mode=development --watch"
"dev": "webpack --mode=development --watch",
"lint": "eslint"
},
"author": "",
"license": "ISC",

View File

@ -0,0 +1,33 @@
import React from 'react';
const Arrow = () => {
return (
<svg
className="cub1-arrow"
width="131"
height="136"
viewBox="0 0 131 136"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.6507 43.2949C32.4339 30.7255 51.9743 23.0115 72.683 28.6293C91.3749 33.7001 103.143 49.6308 90.5396 69.3323C84.5735 78.6586 71.8706 85.1866 61.8852 79.874C50.7606 73.9554 59.5288 59.017 66.6505 54.7089C83.2839 44.6468 106.696 49.3237 118.212 68.8676C131.849 92.0121 108.785 103.532 108.769 103.344"
stroke="black"
strokeWidth="3.37884"
strokeMiterlimit="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M19.2682 18.3819C19.8774 20.8064 19.5256 23.2335 19.2862 25.677C18.5006 33.7006 15.3552 42.0307 9.71151 47.2931C17.1379 44.0369 27.7921 42.6188 34.5374 48.3345"
stroke="black"
strokeWidth="3.37884"
strokeMiterlimit="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
};
export default Arrow;

View File

@ -0,0 +1,61 @@
import React, { useEffect, useState } from 'react';
import Arrow from '../arrow';
import LrButton from '../lr-button/lrButton';
import './styles.css';
import FirstImg from '../../../../../images/img.png';
import SecondImg from '../../../../../images/img_1.png';
enum CubItem {
FIRST = 0,
SECOND = 1,
}
const getBackGround = (item: CubItem) => {
return item === CubItem.FIRST
? `center / cover no-repeat url(${FirstImg}), #F8F8F8`
: `center / cover no-repeat url(${SecondImg}), #F8F8F8`;
};
let prevTime = new Date().getTime();
const Cubs = () => {
const [curIndex, setCurIndex] = useState<CubItem>(CubItem.FIRST);
useEffect(() => {
const interval = setInterval(() => {
const newTime = new Date().getTime();
console.log(`+${newTime - prevTime}`);
prevTime = newTime;
setCurIndex((prevIndex) => {
return prevIndex === CubItem.FIRST ? CubItem.SECOND : CubItem.FIRST;
});
}, 3000);
return () => {
clearInterval(interval);
};
}, [curIndex]);
const setFirst = () => setCurIndex(CubItem.FIRST);
const setSecond = () => setCurIndex(CubItem.SECOND);
return (
<div className="hero-cubs">
<div className="hero-cub1" style={{ background: getBackGround(curIndex) }}>
<Arrow />
<div
className="hero-cub2"
style={{
background: getBackGround(curIndex === CubItem.FIRST ? CubItem.SECOND : CubItem.FIRST),
}}
></div>
</div>
<LrButton
onLeftClick={curIndex === CubItem.SECOND ? setFirst : undefined}
onRightClick={curIndex === CubItem.FIRST ? setSecond : undefined}
/>
</div>
);
};
export default Cubs;

View File

@ -0,0 +1,52 @@
.hero-cubs {
display: flex;
flex-direction: column;
align-items: center;
justify-self: start;
}
.hero-cubs .lr-button {
margin-top: 71px;
}
.hero-cub1 {
position: relative;
width: 391px;
height: 394px;
border-radius: 25px;
background: center / cover no-repeat url('../../../../../images/img.png'), #F8F8F8;
}
.hero-cub1::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 25px;
background: center / cover no-repeat url('../../../../../images/img.png'), #F8F8F8;
transform: translateY(25px);
filter: blur(83.7px);
}
.hero-cub2 {
position: absolute;
top: 181px;
left: calc(100% + 38px);
width: 320px;
height: 322px;
border-radius: 25px;
background: center / cover no-repeat url('../../../../../images/img_1.png'), #F8F8F8;
}
.hero-cub2::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 25px;
background: center / cover no-repeat url('../../../../../images/img_1.png'), #F8F8F8;
transform: translateY(25px);
filter: blur(83.7px);
}

View File

@ -0,0 +1,54 @@
import React from 'react';
import './styles.css';
interface LrButtonProps {
/**
* События нажатия на левую кнопку
*/
onLeftClick?: () => void;
onRightClick?: () => void;
}
const getColor = (enabled?: boolean) => (enabled ? '#23262F' : '#929292');
const LrButton = ({ onLeftClick, onRightClick }: LrButtonProps) => {
return (
<div className="lr-button">
<button className="lr-button-left" onClick={onLeftClick}>
<svg
width="27"
height="27"
viewBox="0 0 27 27"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M11.2397 8.39036C10.8023 7.98657 10.1203 8.01384 9.71654 8.45128L6.23402 12.224C5.85287 12.6369 5.85287 13.2733 6.23401 13.6862L9.71653 17.459C10.1203 17.8965 10.8023 17.9237 11.2397 17.5199C11.6772 17.1161 11.7045 16.4342 11.3007 15.9967L9.48802 14.033L19.9611 14.033C20.5565 14.033 21.0391 13.5504 21.0391 12.9551C21.0391 12.3598 20.5565 11.8772 19.9611 11.8772L9.48805 11.8772L11.3007 9.91356C11.7044 9.47612 11.6772 8.79416 11.2397 8.39036Z"
fill={getColor(Boolean(onLeftClick))}
/>
</svg>
</button>
<div className="lr-button-delimiter"></div>
<button className="lr-button-right" onClick={onRightClick}>
<svg
width="27"
height="27"
viewBox="0 0 27 27"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M15.7603 8.39036C16.1977 7.98657 16.8797 8.01384 17.2835 8.45128L20.766 12.224C21.1471 12.6369 21.1471 13.2733 20.766 13.6862L17.2835 17.459C16.8797 17.8965 16.1977 17.9237 15.7603 17.5199C15.3228 17.1161 15.2955 16.4342 15.6993 15.9967L17.512 14.033L7.03886 14.033C6.44354 14.033 5.96094 13.5504 5.96094 12.9551C5.96094 12.3598 6.44354 11.8772 7.03886 11.8772L17.5119 11.8772L15.6993 9.91356C15.2956 9.47612 15.3228 8.79416 15.7603 8.39036Z"
fill={getColor(Boolean(onRightClick))}
/>
</svg>
</button>
</div>
);
};
export default LrButton;

View File

@ -0,0 +1,20 @@
.lr-button {
width: 166px;
height: 69px;
box-shadow: 0px 43.12px 34.49px -25.87px #0F0F0F1F;
display: flex;
align-items: center;
background: #FCFCFD;
border-radius: 17.25px;
}
.lr-button button {
width: 100%;
border: none;
background: none;
}
.lr-button-delimiter {
width: 2px;
height: 25px;
background: #E6E8EC;
flex-shrink: 0;
}

View File

@ -1,6 +1,6 @@
import React from 'react';
export const arrowEl = (
export const dots = (
<svg
className="hero-dots"
width="120"

View File

@ -1,9 +1,9 @@
import React, { useState } from 'react';
import { arrowEl } from './arrow';
import React from 'react';
import { dots } from './dots';
import './style.css';
import Cubs from './components/cubs/cubs';
const Banner = () => {
return (
<div className="container hero">
<div className="hero-main">
@ -19,72 +19,8 @@ const Banner = () => {
</div>
</div>
<div>
<div className="hero-cubs">
<div className="hero-cub1">
<svg
className="cub1-arrow"
width="131"
height="136"
viewBox="0 0 131 136"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.6507 43.2949C32.4339 30.7255 51.9743 23.0115 72.683 28.6293C91.3749 33.7001 103.143 49.6308 90.5396 69.3323C84.5735 78.6586 71.8706 85.1866 61.8852 79.874C50.7606 73.9554 59.5288 59.017 66.6505 54.7089C83.2839 44.6468 106.696 49.3237 118.212 68.8676C131.849 92.0121 108.785 103.532 108.769 103.344"
stroke="black"
strokeWidth="3.37884"
strokeMiterlimit="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M19.2682 18.3819C19.8774 20.8064 19.5256 23.2335 19.2862 25.677C18.5006 33.7006 15.3552 42.0307 9.71151 47.2931C17.1379 44.0369 27.7921 42.6188 34.5374 48.3345"
stroke="black"
strokeWidth="3.37884"
strokeMiterlimit="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
<div className="hero-cub2"></div>
</div>
<div className="lr-button">
<button className="lr-button-left">
<svg
width="27"
height="27"
viewBox="0 0 27 27"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M11.2397 8.39036C10.8023 7.98657 10.1203 8.01384 9.71654 8.45128L6.23402 12.224C5.85287 12.6369 5.85287 13.2733 6.23401 13.6862L9.71653 17.459C10.1203 17.8965 10.8023 17.9237 11.2397 17.5199C11.6772 17.1161 11.7045 16.4342 11.3007 15.9967L9.48802 14.033L19.9611 14.033C20.5565 14.033 21.0391 13.5504 21.0391 12.9551C21.0391 12.3598 20.5565 11.8772 19.9611 11.8772L9.48805 11.8772L11.3007 9.91356C11.7044 9.47612 11.6772 8.79416 11.2397 8.39036Z"
fill="#929292"
/>
</svg>
</button>
<div className="lr-button-delimiter"></div>
<button className="lr-button-right">
<svg
width="27"
height="27"
viewBox="0 0 27 27"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M15.7603 8.39036C16.1977 7.98657 16.8797 8.01384 17.2835 8.45128L20.766 12.224C21.1471 12.6369 21.1471 13.2733 20.766 13.6862L17.2835 17.459C16.8797 17.8965 16.1977 17.9237 15.7603 17.5199C15.3228 17.1161 15.2955 16.4342 15.6993 15.9967L17.512 14.033L7.03886 14.033C6.44354 14.033 5.96094 13.5504 5.96094 12.9551C5.96094 12.3598 6.44354 11.8772 7.03886 11.8772L17.5119 11.8772L15.6993 9.91356C15.2956 9.47612 15.3228 8.79416 15.7603 8.39036Z"
fill="#23262F"
/>
</svg>
</button>
</div>
</div>
{arrowEl}
<Cubs />
{dots}
</div>
</div>
);

View File

@ -47,48 +47,6 @@
gap: 23px;
}
.hero-cub1 {
position: relative;
width: 391px;
height: 394px;
border-radius: 25px;
background: center / cover no-repeat url('../../../images/img.png'), #F8F8F8;
}
.hero-cub1::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 25px;
background: center / cover no-repeat url('../../../images/img.png'), #F8F8F8;
transform: translateY(25px);
filter: blur(83.7px);
}
.hero-cub2 {
position: absolute;
top: 181px;
left: calc(100% + 38px);
width: 320px;
height: 322px;
border-radius: 25px;
background: center / cover no-repeat url('../../../images/img_1.png'), #F8F8F8;
}
.hero-cub2::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 25px;
background: center / cover no-repeat url('../../../images/img_1.png'), #F8F8F8;
transform: translateY(25px);
filter: blur(83.7px);
}
.cub1-arrow {
position: absolute;
left: calc(100% + 23px);
@ -102,14 +60,3 @@
right: 0;
z-index: -1;
}
.hero-cubs {
display: flex;
flex-direction: column;
align-items: center;
justify-self: start;
}
.hero-cubs .lr-button {
margin-top: 71px;
}

View File

@ -189,23 +189,4 @@ html {
flex-shrink: 0;
}
.lr-button {
width: 166px;
height: 69px;
box-shadow: 0px 43.12px 34.49px -25.87px #0F0F0F1F;
display: flex;
align-items: center;
background: #FCFCFD;
border-radius: 17.25px;
}
.lr-button button {
width: 100%;
border: none;
background: none;
}
.lr-button-delimiter {
width: 2px;
height: 25px;
background: #E6E8EC;
flex-shrink: 0;
}

View File

@ -32,7 +32,7 @@
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
"typeRoots": ["./node_modules/@types", "@types"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */

View File

@ -1,4 +1,3 @@
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
@ -19,6 +18,10 @@ module.exports = {
},
module: {
rules: [
{
test: /\.png/,
type: 'asset/resource',
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,