fetch(`https://api.site.ru/?token=4w5sf4b678ec86b8b&post=${document.querySelector('#GoLink').dataset.post}`)
const Component = () => {
const fileReader = (e) => {
let reader = new FileReader();
const file = e.target.files[0]
reader.readAsDataURL(file);
reader.onload = () => {
console.log(reader.result)
// здесь инициализируем отправку изображения на сервер
};
}
return (
<div>
<input type="file" accept='image/*' onChange={fileReader} />
</div>
)
}
s = '##########\n####0##0##\n00##0###00\n0123456789'
sArray = s.split('\n') # делим исходную строку по строкам
arr = [[0 for j in range(len(sArray))] for i in range(len(sArray[0]))] # создаём двумерный массив, где количество элементов в arr = длине 1 строки
countMax = 1 # максимум '0' в столбце
countBMin = len(sArray[0]) # минимум '#' в столбце
column = -1 # столбец
for i in range(len(sArray)):
for j in range(len(sArray[0])):
arr[j][i] = sArray[i][j] # создаём массив из массивов столбцов
for i in range(len(arr)):
count = arr[i].count('0') # считаем кол-во '0' в столбце
countB = arr[i].count('#') # считаем кол-во '#' в столбце
if (count >= countMax and countB < countBMin): # кол-во '0' должно быть наибольшим, а кол-во '#' - наименьшим
countMax = count
countBMin = countB
column = i
print(column)
const webpack = require('webpack');
const path = require('path');
const config = {
entry: [
'react-hot-loader/patch',
path.resolve(__dirname, 'src', 'index.js')
],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.svg$/,
use: 'file-loader'
},
{
test: /\.png$/,
use: [
{
loader: 'url-loader',
options: {
mimetype: 'image/png'
}
}
]
}
]
},
resolve: {
extensions: [
'.js',
'.jsx'
],
alias: {
'react-dom': '@hot-loader/react-dom'
}
},
devServer: {
historyApiFallback: true,
contentBase: path.resolve(__dirname, './dist'),
open: true,
hot: true,
compress: true,
}
};
module.exports = config;
<!DOCTYPE html>
<html>
<head>
<title>example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="app"></div>
<script src='../bundle.js'></script>
</body>
</html>
<div class="portfolio__item mix slug paint">
<a class="portfolio__item-link" href="product-page.html" aria-label="Portfolio photo">
<img class="portfolio__item-img lazyload" data-src="images/content/portfolio-3.jpg" alt="portfolio-img">
<div class="portfolio__item-hover">
<div class="portfolio__item-info">
<h3 class="portfolio__item-title">Кухня Модерн</h3>
<h4 class="portfolio__item-subtitle">пластик-шпон</h4>
</div>
<p class="portfolio__item-code">артикул 13428</p>
</div>
</a>
</div>
<div class="portfolio-item mix slug paint">
<a class="portfolio-item__link" href="product-page.html" aria-label="Portfolio photo">
<img class="portfolio-item__img lazyload" data-src="images/content/portfolio-3.jpg" alt="portfolio-img">
<div class="portfolio-item__wrapper_hover">
<div class="portfolio-item__info">
<h3 class="portfolio-item__title">Кухня Модерн</h3>
<h4 class="portfolio-item__subtitle">пластик-шпон</h4>
</div>
<p class="portfolio-item__code">артикул 13428</p>
</div>
</a>
</div>
import React, { useState } from "react";
export default function App() {
const [state, setState] = useState([
{ id: 0, status: true },
{ id: 1, status: false }
]);
const chooseItem = (id) => {
const newArr = state.map((item) =>
item.id === id ? { ...item, status: true } : { ...item, status: false }
);
setState(newArr);
};
return (
<div className="App">
{state.map((item) => (
<div style={{ border: item.status ? "3px solid tomato" : "none" }}>
<div>TABLE {item.id}</div>
<button onClick={() => chooseItem(item.id)}>CLICK</button>
</div>
))}
</div>
);
}
- const onMouseKidsEnter = () => {
- setIsOpen('kids')
- }
- const onMouseWomenEnter = () => {
- setIsOpen('women')
- }
- const onMouseMenEnter = () => {
- setIsOpen('men')
- }
+ const onMouseParamEnter = (param) => {
+ setIsOpen(param);
+ }
<LeftBar>
- <LeftBarItem onMouseEnter={onMouseKidsEnter} onMouseLeave={onMouseLeave} isOpen={isOpen === 'kids'}>
+ <LeftBarItem onMouseEnter={() => onMouseParamEnter('kids')} onMouseLeave={onMouseLeave} isOpen={isOpen === 'kids'}>
<span>Kids</span>
<IoIosArrowBack />
</LeftBarItem>
- <LeftBarItem onMouseEnter={onMouseWomenEnter} onMouseLeave={onMouseLeave} isOpen={isOpen === 'women'}>
+ <LeftBarItem onMouseEnter={() => onMouseParamEnter('women')} onMouseLeave={onMouseLeave} isOpen={isOpen === 'women'}>
<span>Women</span>
<IoIosArrowBack />
</LeftBarItem>
- <LeftBarItem onMouseEnter={onMouseMenEnter} onMouseLeave={onMouseLeave} isOpen={isOpen === 'men'}>
+ <LeftBarItem onMouseEnter={() => onMouseParamEnter('men')} onMouseLeave={onMouseLeave} isOpen={isOpen === 'men'}>
<span>Men</span>
<IoIosArrowBack />
</LeftBarItem>
</LeftBar>
<LeftBarItem>
вынести в отдельный компонент и передавать туда нужный props с параметром kids/women/men import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Home from './pages/Home';
const App = () => {
const dispatch = useDispatch();
const { data } = useSelector((store) => store);
const [allowScroll, setAllowScroll] = useState(true);
const scrolling = () => {
const height = Math.max(
document.body.clientHeight,
document.documentElement.clientHeight
);
if (
window.pageYOffset > height * 0.75 ||
window.pageYOffset > height - 2000
) {
if (allowScroll) {
setAllowScroll(() => false);
setTimeout(() => {
setAllowScroll(() => true);
}, 2000);
dispatch({
type: 'DISPATCH',
});
}
}
};
return (
<div onWheel={scrolling}>
<Home />
</div>
);
};
export default App;
curl 'https://identitytoolkit.googleapis.com/v1/accounts:update?key=[API_KEY]' \
-H 'Content-Type: application/json' \
--data-binary '{"idToken":"[FIREBASE_ID_TOKEN]","deleteProvider":["[facebook.com]"]}'