This commit is contained in:
Виктор Батищев 2023-10-11 15:34:00 +03:00
parent a49f48c166
commit de5bae42f2
10 changed files with 97 additions and 27230 deletions

27146
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,15 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@capacitor/android": "^3.3.4",
"@capacitor/cli": "^3.3.4",
"@capacitor/core": "^3.3.4",
"@testing-library/jest-dom": "^5.16.1", "@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2", "@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"cors": "^2.8.5",
"react": "^17.0.2", "react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.4",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",
"web-vitals": "^2.1.3" "web-vitals": "^2.1.3"
@ -34,5 +39,8 @@
"last 1 firefox version", "last 1 firefox version",
"last 1 safari version" "last 1 safari version"
] ]
},
"devDependencies": {
"typescript": "^4.5.4"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,38 +1,51 @@
.App { .App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex; display: flex;
flex: 1;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: space-between;
font-size: calc(10px + 2vmin); height: 100vh;
}
.title {
font-size: 20px;
color: blue;
font-family: 'Roboto', sans-serif;
text-align: center;
flex-wrap: wrap;
margin-top: 30px;
}
.button-avatar {
background-color: black;
color: white; color: white;
font-size: 30px;
border-radius: 40px;
padding: 10px;
cursor: pointer;
margin: 30px;
} }
.App-link { .text-copy {
color: #61dafb; font-size: 25px;
color: blue;
cursor: pointer;
} }
@keyframes App-logo-spin { .copyImage {
from { width: 45px;
transform: rotate(0deg); height: 51px;
} margin: 15px;
to { cursor: pointer;
transform: rotate(360deg); }
}
.avatar {
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.avatarContainer {
display: flex;
justify-content: center;
} }

View File

@ -1,25 +1,49 @@
import logo from './logo.svg'; import React, { useState, useRef } from 'react'
import './App.css'; import copy from './copy.png'
import './App.css'
function App() { function App() {
const [avatarLink, setAvatarLink] = useState(null)
const textAreaRef = useRef(null)
function copyToClipboard(e) {
alert('Текст скопирован в буфер обмена')
textAreaRef.current.select()
document.execCommand('copy')
}
const getPhoto = () => {
fetch('http://192.168.88.31:5002/api/generate')
.then((response) => response.json())
.then((responseJson) => setAvatarLink(responseJson.url))
}
return ( return (
<div className="App"> <div className='App'>
<header className="App-header"> {!avatarLink ? (
<img src={logo} className="App-logo" alt="logo" /> <h1 className='title'> Нажмите Сгенерировать аватарку ! </h1>
<p> ) : (
Edit <code>src/App.js</code> and save to reload. <div>
</p> <div className='avatar'>
<a <img src={avatarLink} alt='avatar' />
className="App-link" </div>
href="https://reactjs.org" <div className='avatarContainer'>
target="_blank" <textarea ref={textAreaRef} value={avatarLink} readOnly />
rel="noopener noreferrer" <img
> onClick={() => copyToClipboard()}
Learn React className='copyImage'
</a> src={copy}
</header> alt=''
/>
</div>
</div>
)}
<button className='button-avatar' onClick={() => getPhoto()}>
Сгенерировать аватарку
</button>
</div> </div>
); )
} }
export default App; export default App

View File

@ -1,8 +0,0 @@
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();
});

BIN
src/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -1,17 +1,11 @@
import React from 'react'; import React from 'react'
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom'
import './index.css'; import './index.css'
import App from './App'; import App from './App'
import reportWebVitals from './reportWebVitals';
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<App /> <App />
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById('root')
); )
// 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();

View File

@ -1,13 +0,0 @@
const reportWebVitals = onPerfEntry => {
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;

View File

@ -1,5 +0,0 @@
// 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';