добавлен репозиторий

This commit is contained in:
DmitriyB
2022-08-24 19:13:36 +05:00
commit 4843d7fb5c
27 changed files with 43635 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
.App {
}
.block {
width: 100%;
height: 100vh;
background-color: rgb(104, 104, 104);
display: flex;
justify-content: space-evenly;
}
.block:nth-child(even) {
background-color: #333333;
}
.block-item {
width: 200px;
height: 200px;
background-color: rgb(60, 65, 216);
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
font-weight: 600;
color: #FFFFFF;
}
+9
View File
@@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
+77
View File
@@ -0,0 +1,77 @@
import { motion, useScroll, Variants } from 'framer-motion';
import React, { useEffect, useState } from 'react';
import './App.css';
import { TestAnim } from './components/testAnimation';
import { TestAnimeJs } from './components/testAnimeJs/testAnimeJs';
import { TestAnimWithSvg } from './components/testAnimWithSvg';
const blockItemAnim: Variants = {
hidden: {
y: 100,
opacity: 0
},
visible: custom => ({
y: 0,
opacity: 1,
transition: {
delay: custom * 0.2,
type: 'just'
},
})
}
const TestBlock:React.FC<{isShow: boolean}> = (props) => {
return <motion.div
className='block'
initial='hidden'
whileInView='visible'
viewport={
{
// amount: .2,
margin: '0px 0px -200px 0px',
// once: true
}
}
transition={{type: 'tween'}}
>
{
!props.isShow
? null
: <>
<motion.div
className='block-item'
variants={blockItemAnim}
custom={1}
>
Пошел
</motion.div>
<motion.div
className='block-item'
variants={blockItemAnim}
custom={2}
>
нахуй
</motion.div>
</>
}
</motion.div>
}
function App() {
return (
<div className="App">
<TestAnimeJs />
{/* <TestAnimWithSvg /> */}
{/* <TestAnim /> */}
{/* <TestBlock isShow={false}></TestBlock>
<TestBlock isShow={true}/>
<TestBlock isShow={true}/>
<TestBlock isShow={true}/> */}
</div>
);
}
export default App;
+3
View File
@@ -0,0 +1,3 @@
<svg width="119" height="211" viewBox="0 0 119 211" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.14234 24.4267C1.14234 -53.2107 117.599 78.4637 117.599 210.757" stroke="#567ECE" stroke-width="2"/>
</svg>

After

Width:  |  Height:  |  Size: 219 B

+143
View File
@@ -0,0 +1,143 @@
import Tween from 'rc-tween-one';
import React, { useEffect, useState } from 'react';
import PathPlugin from 'rc-tween-one/es/plugin/PathMotionPlugin';
import TweenOne from 'rc-tween-one';
import SvgDrawPlugin from 'rc-tween-one/lib/plugin/SvgDrawPlugin';
import testLine from './Vector 160.svg';
// Tween.plugins.push(PathPlugin);
Tween.plugins.push(SvgDrawPlugin);
const pathLine = [
'M208.346 237.619C208.346 193.366 182.727 55.946 182.727 132.808',
'M208.35 237.618C208.35 106.41 428.066 -73.7111 428.066 35.7604',
'M208.349 237.621C208.348 136.692 1.83302 239.948 1.83302 342.43',
'M208.35 237.619C208.349 130.477 595.762 -81.4732 595.762 58.2759',
'M208.351 237.625C208.351 143.68 556.945 24.7433 556.945 170.08',
'M208.35 237.619C208.35 159.981 570.143 152.215 570.143 312.151',
'M208.349 237.621C208.349 159.984 324.805 291.658 324.805 423.952'
]
export const TestAnimWithSvg = () => {
const [activeDot, setActiveDot] = useState<number>(-1);
const [show, setShow] = useState<boolean>(false);
const dotStyle: React.CSSProperties = {
position: 'absolute',
width: '200px',
height: '210px',
// backgroundColor: '#0E0E0E',
backgroundColor: 'red',
// rotate: ('90deg'),
}
function changeActiveDot(index: number) {
setActiveDot(index);
}
function fuck() {
setShow(true)
}
useEffect(() => {
setActiveDot(0);
}, []);
//чтобы сделать имитацию рисования дуги, можно сделать маску(блок), который будет при движении открывать эту дугу. Для этого движение маски сделать не по дуге, а просто от точки A до B
return <div style={{display: 'flex', justifyContent:'center'}}>
<div
style={{
padding: '20px',
width: 1000,
height: 700,
// background: '#0E0E0E',
position: 'relative',
boxSizing: 'border-box'
}}
>
{/* <svg width="100%" height="100%" style={{position: 'absolute', }}>
<path d={pathLine.join(' ')} fill="none" stroke="#567ECE"/>
</svg> */}
<TweenOne
animation={{SVGDraw: 'start end'}}
path={`<svg width="119" height="211" viewBox="0 0 119 211" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.14234 24.4267C1.14234 -53.2107 117.599 78.4637 117.599 210.757" stroke="#567ECE" stroke-width="2"/>
</svg>`
}
/>
{/* <TweenOne
animation={[
{ left: '-40%' },
{ left: '40%' },
{ top: '60px' },
{ scale: 0.7 },
{ scale: 1 },
{ top: 0 },
{ left: '0%' },
]}
// animation={{
// duration: 6000,
// PathMotion: {
// path: pathLine[6],
// // path: pathLine.join(' '),
// pathVars: { type: 'cubic', curviness: .5 },
// // center: ['15px', '15px'],
// center: ['0px', '0px'],
// },
// onComplete: (e) => {
// fuck();
// },
// rotateX: 0,
// rotateY: 0
// }}
style={dotStyle}
// paused={i !== activeDot}
repeat={-1}
>
<img
src={testLine}
alt=''
style={{rotate: ('180deg')}}
/>
</TweenOne> */}
{/* {
show &&
<TweenOne
animation={{
duration: 6000,
PathMotion: {
path: pathLine[1],
pathVars: { type: 'cubic', curviness: .5 },
// center: ['15px', '15px'],
},
}}
style={dotStyle}
// paused={i !== activeDot}
/>
} */}
{/* {pathLine.map((path, i) => {
// if(i === activeDot)
return <TweenOne
key={path + i}
animation={{
duration: 6000,
PathMotion: {
path: path,
pathVars: { type: 'cubic', curviness: .5 },
// center: ['15px', '15px'],
},
onComplete: (e) => {
// changeActiveDot(i+1);
},
}}
yoyo
repeat={-1}
style={dotStyle}
// paused={i !== activeDot}
/>
})} */}
</div>
</div>
}
+109
View File
@@ -0,0 +1,109 @@
import Tween from 'rc-tween-one';
import React, { useEffect, useState } from 'react';
import PathPlugin from 'rc-tween-one/es/plugin/PathMotionPlugin';
import TweenOneGroup from 'rc-tween-one';
import PathMotionPlugin from 'rc-tween-one';
Tween.plugins.push(PathPlugin);
const array = [
{ x: 500, y: 250 },//start
{ x: 250, y: 150, color: 'red' },// 1 help
{ x: 200, y: 350 },// 1 finish
{ x: 650, y: 320, color: 'red' },// 2 help
{ x: 600, y: 550 }, // 2 finish
{ x: 800, y: 200, color: 'red' }, // 3 help
{ x: 900, y: 350 } , // 3 finish
{ x: 800, y: 150, color: 'red' }, // 4 help
{ x: 900, y: 210 }, // 4 finish
{ x: 820, y: 80, color: 'red' }, // 5 help
{ x: 950, y: 130 }, // 5 finish
{ x: 600, y: 80, color: 'red' }, // 6 help
{ x: 700, y: 100 }, // 6 finish
{ x: 480, y: 120, color: 'red' }, // 7 help
{ x: 430, y: 140 }, // 7 finish
];
export const TestAnim:React.FC = () => {
const [activeDot, setActiveDot] = useState<number>(0);
const dotStyle: React.CSSProperties = {
opacity: 1,
position: 'absolute',
width: '30px',
height: '30px',
borderRadius: '50px',
background: '#1890ff',
}
function changeActiveDot() {
setActiveDot(activeDot + 2 >= array.length ? 1 : activeDot + 2);
}
useEffect(() => {
setActiveDot(1);
}, []);
return <div style={{display: 'flex', justifyContent:'center'}}>
<div
style={{
width: 1000,
height: 700,
background: '#D375FF',
position: 'relative',
}}
>
{array.map((item, i) => {
return (
<div key={`${item.x} ${item.y} i`}>
<div
style={{
background: item?.color ? 'red' : '#000',// || '#000',
margin: 0,
width: 8,
height: 8,
position: 'absolute',
left: item.x - 4,
top: item.y - 4,
borderRadius: '100%',
}}
/>
{/* добавить мб канвас сюда и апдейтить */}
{
i % 2 !== 0 ?
<>
<Tween
animation={{
duration: 3000,
PathMotion: {
path: [array[0], array[i], array[i + 1]],
pathVars: { type: 'cubic', curviness: .5 },
center: ['15px', '15px'],
},
onUpdate: e => {
let el = e?.targets as HTMLElement;
// console.log(el.getBoundingClientRect().left)
// drawTail(el.getBoundingClientRect().left, el.getBoundingClientRect().top)
},
onComplete: (e) => {
changeActiveDot();
},
}}
repeat={0}
style={dotStyle}
paused={!(activeDot === i)}
// paused={isPaused}
>
</Tween>
</>
: null
}
</div>
);
})}
</div>
</div>
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,88 @@
import React, { useEffect, useState } from "react";
import { animated, config, useSpring } from "react-spring";
import './testSpringAnimate.css';
// function useAnimatedPath({ toggle, delay }) {
// const [length, setLength] = useState(null);
// const animatedStyle = useSpring({
// strokeDashoffset: toggle ? 0 : length,
// strokeDasharray: length,
// delay,
// config: config.slow
// });
// return {
// style: animatedStyle,
// ref: (ref) => {
// if (ref) {
// setLength(ref.getTotalLength());
// }
// }
// };
// }
// //@ts-ignore
// function Checkmark({ toggle }) {
// const animatedProps = useAnimatedPath({ toggle, delay: 500 });
// return (
// //@ts-ignore
// <animated.path
// stroke="#4ADE80"
// strokeWidth="24"
// d="M75 153.5l68.081 77.5L235 97"
// {...animatedProps}
// />
// );
// }
// //@ts-ignore
// function ShieldPart({ toggle, d, color }) {
// const animatedStrokeProps = useAnimatedPath({ toggle });
// const animatedFillStyle = useSpring({
// fill: toggle ? color : "#fff",
// delay: 250
// });
// return (
// <animated.path
// stroke="#A78BFA"
// strokeWidth="2"
// d={d}
// {...animatedStrokeProps}
// style={{ ...animatedStrokeProps.style, ...animatedFillStyle }}
// />
// );
// }
export const TestSpringAnimate:React.FC = React.memo(() => {
const [toggle, setToggle] = useState(false);
useEffect(() => {
setImmediate(() => {
setToggle(true);
});
}, []);
return <div className="test-anim">
<svg
xmlns="http://www.w3.org/2000/svg"
width="286"
height="334"
fill="none"
viewBox="0 0 286 334"
>
{/* <ShieldPart
toggle={toggle}
color="#A78BFA"
d="M 143, 333 C 31.09 261.823 1 73.61 1 73.61 L 143 1 v 332 z"
/>
<ShieldPart
toggle={toggle}
color="#8B5CF6"
d="M 143, 333 C 254.911 261.823 285 73.61 285 73.61 L 143 1 v 332 z"
/>
<Checkmark toggle={toggle} /> */}
</svg>
</div>
})
+15
View File
@@ -0,0 +1,15 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: #0E0E0E;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+19
View File
@@ -0,0 +1,19 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
// <React.StrictMode>
<App />
// </React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

+1
View File
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
+15
View File
@@ -0,0 +1,15 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
+5
View File
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';