style = (id) => `
@keyframes ${id}-flash {
0% { opacity: 0 }
}
@keyframes ${id}-wiggle {
${(100 / 6) * 0}% { left: 0 }
${(100 / 6) * 1}% { left: 0.75em }
${(100 / 6) * 2}% { left: 0 }
${(100 / 6) * 3}% { left: -0.75em }
${(100 / 6) * 4}% { left: 0 }
${(100 / 6) * 5}% { left: 0.75em }
${(100 / 6) * 6}% { left: 0 }
}
#${id} {
--color: hsl(150,0%,45%);
--bg: hsla(150,0%,60%,20%);
width: 100%;
height: 140px;
max-width: 360px;
box-sizing: border-box;
padding: 1em;
margin: 0.5em 0;
background: repeating-linear-gradient(-45deg, transparent 10px 30px, var(--bg) 30px 50px);
border: 4px solid var(--color);
border-radius: 1vmin;
outline: none;
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
position: relative;
}
#${id}.valid:not(.invalid):not(:focus):not(.dragging) {
background: var(--bg);
border-width: 2px;
padding: calc(1em + 2px);
}
#${id}.valid { --color: hsl(140, 53%, 40%); --bg: hsla(140, 53%, 40%, 15%); }
#${id}:focus, #${id}.dragging, #${id}:not(.invalid) button { --color: hsl(224, 53%, 49%); --bg: hsla(224, 53%, 49%, 15%); }
#${id}.invalid { --color: hsl(0, 53%, 49%); --bg: hsla(0, 53%, 49%, 15%); }
#${id}.dragging { background: var(--bg); }
#${id}.valid::before { content: "file selected:" }
#${id}:focus::before { content: "Paste away! or" }
#${id}.invalid::before { content: "Invalid" }
#${id}::before {
content: "drag and drop, paste, or";
display: inline-block;
vertical-align: middle;
text-align: center;
font-size: 1.1em;
font-weight: bold;
position: relative;
font-family: sans-serif;
color: var(--color);
white-space: pre-wrap;
text-transform: uppercase;
}
#${id}.dragging::before {
margin: auto;
content: "drop here";
font-size: 2em;
opacity: 0.6;
}
#${id}.invalid {
animation: 0.3s ease-out ${id}-wiggle;
content: attr(data-error-message);
}
#${id} button {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: hsl(224, 43%, 80%);
color: hsl(224, 60%, 40%);
margin: 0;
padding: .2em .5em;
border-radius: 10px;
border: none;
font-size: 1.2em;
text-transform: uppercase;
font-weight: bold;
}
#${id}:focus button {
background: hsl(224, 43%, 80%, 75%);
}
#${id}.valid:not(:focus) button {
background: transparent;
color: var(--color);
font-size: 1em;
}
#${id}.dragging button, #${id}.dragging span {
display: none;
}
#${id} span {
color: var(--color);
font-size: 0.9em;
text-align: center;
font-weight: bold;
font-family: sans-serif;
}
#${id}:focus span,
#${id}.invalid span {
visibility: hidden
}
`