Skip to content

Instantly share code, notes, and snippets.

@DZuz14
DZuz14 / index.jsx
Last active February 10, 2021 17:13
filler
const StatRow = ({ stat }) => {
const { away, home } = stat;
return (
<div>
<Stat>
<div>
<TeamRank marginRight={10}>#{away.team_rank}</TeamRank>
<StatValue>{away.stat_value}</StatValue>
</div>
@DZuz14
DZuz14 / index.jsx
Created February 10, 2021 17:19
handlebarwidth
const StatRow = ({ stat }) => {
const { away, home } = stat;
const handleBarWidth = (value, high) => {
return Math.floor((value / high) * 100);
};
return (
<div>
<Stat>
@DZuz14
DZuz14 / index.jsx
Created February 10, 2021 17:23
rotate
const Bar = styled.div`
position: relative;
height: 8px;
width: 49%;
background-color: #eeeeee;
border-radius: 50px;
margin-top: 2.5px;
transform: rotate(${(props) => props.rotate || 0}deg);
`;
<BarGroup>
<Bar rotate={180}>
<Filler
color="#F5B947"
width={handleBarWidth(away.stat_value, away.league_high)}
/>
</Bar>
<Bar>
<Filler
[
{
"away":{
"stat_name":"score",
"stat_value":395,
"league_high":509,
"team_rank":17
},
"home":{
"stat_name":"score",
@DZuz14
DZuz14 / App.js
Created June 9, 2021 18:39
useFileUpload1
import React, { useRef } from 'react'
const App = () => {
const inputRef = useRef()
return (
<div>
<h1>Upload Files</h1>
<p>
@DZuz14
DZuz14 / useFileUpload.js
Created June 13, 2021 15:00
useFileUpload. skeleton
import { useState, useEffect } from 'react';
export const useFileUpload = () => {
//
};
import { useState, useEffect } from 'react';
export const useFileUpload = () => {
const [files, setFiles] = useState([])
return {
files,
setFiles
}
};
import { useState, useEffect } from 'react';
export const useFileUpload = () => {
const [files, setFilesState] = useState([])
const setFiles = files => {
setFilesState(Array.from(files))
}
return {
import { useState, useEffect } from 'react';
export const useFileUpload = () => {
const [files, setFilesState] = useState([])
const setFiles = e => {
let filesArr = []
if (e.currentTarget?.files) {
filesArr = Array.from(e.currentTarget.files);