-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tecuity/demo-site
Adding demo site via Github page
- Loading branch information
Showing
25 changed files
with
6,474 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
/site-dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/src | ||
/demo-site | ||
/site-dist | ||
/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react"; | ||
|
||
export default () => ( | ||
<a | ||
href="https://github.com/tecuity/barcode-generator" | ||
class="github-corner" | ||
aria-label="View source on GitHub" | ||
> | ||
<svg | ||
width="80" | ||
height="80" | ||
viewBox="0 0 250 250" | ||
style={{ | ||
fill: "#a2a2a2", | ||
color: "#fff", | ||
position: "absolute", | ||
top: 0, | ||
border: 0, | ||
left: 0, | ||
transform: "scale(-1, 1)" | ||
}} | ||
aria-hidden="true" | ||
> | ||
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> | ||
<path | ||
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" | ||
fill="currentColor" | ||
style={{ transformOrigin: "130px 106px" }} | ||
class="octo-arm" | ||
></path> | ||
<path | ||
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" | ||
fill="currentColor" | ||
class="octo-body" | ||
></path> | ||
</svg> | ||
</a> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,259 @@ | ||
import React from "react"; | ||
import styled from "@emotion/styled"; | ||
import { keyframes, css } from "@emotion/core"; | ||
import quotes from './quotes' | ||
|
||
export default ({ svg }) => { | ||
const [currentBarcodeSVG, setCurrentBarcodeSVG] = React.useState(svg); | ||
const [isPrinting, setIsPrinting] = React.useState(false); | ||
const [isTearing, setIsTearing] = React.useState(false); | ||
const [currentQuote, setCurrentQuote] = React.useState(0) | ||
|
||
React.useEffect(() => { | ||
if (prevSVG.current === null && svg) { | ||
setCurrentBarcodeSVG(svg); | ||
setIsPrinting(true); | ||
} else if (prevSVG.current !== null && prevSVG.current !== undefined) { | ||
setIsTearing(true); | ||
} | ||
}, [svg]); | ||
|
||
const prevSVG = React.useRef(); | ||
React.useEffect(() => { | ||
prevSVG.current = svg; | ||
}); | ||
|
||
const handleAnimationEnd = () => { | ||
if (isTearing) { | ||
setCurrentQuote(x => x === quotes.length - 1 ? 0 : x + 1) | ||
setIsTearing(false); | ||
setCurrentBarcodeSVG(svg); | ||
} | ||
}; | ||
|
||
const handleTransitionEnd = () => { | ||
if (isPrinting) { | ||
setIsPrinting(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Wrapper> | ||
<Slot> | ||
<Cutter /> | ||
</Slot> | ||
<ReceiptPositioner> | ||
<ReceiptHider> | ||
<ReceiptColumn show={isPrinting && !isTearing}> | ||
<ReceiptPaper | ||
printing={isPrinting} | ||
tearing={isTearing} | ||
onAnimationEnd={handleAnimationEnd} | ||
onTransitionEnd={handleTransitionEnd} | ||
> | ||
<Quote> | ||
{quotes[currentQuote]} | ||
</Quote> | ||
<BarcodeWrapper> | ||
<Barcode src={currentBarcodeSVG} alt="" /> | ||
</BarcodeWrapper> | ||
{/* <ReceiptShadow /> */} | ||
</ReceiptPaper> | ||
</ReceiptColumn> | ||
</ReceiptHider> | ||
</ReceiptPositioner> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const Wrapper = styled("div")` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const BarcodeWrapper = styled("div")` | ||
width: 100%; | ||
padding: 15px; | ||
`; | ||
|
||
const Barcode = styled("img")` | ||
width: 100%; | ||
max-height: 100px; | ||
`; | ||
|
||
const Slot = styled("div")` | ||
width: 400px; | ||
height: 10px; | ||
background: linear-gradient( | ||
to right, | ||
rgb(65, 65, 65) 0%, | ||
rgb(31, 31, 31) 2%, | ||
rgb(31, 31, 31) 98%, | ||
rgb(65, 65, 65) 100% | ||
); | ||
box-shadow: inset 0px -4px 4px rgba(255, 255, 255, 0.1), | ||
inset 0px 3px 3px rgba(0, 0, 0, 0.4); | ||
border-radius: 4px; | ||
position: relative; | ||
`; | ||
|
||
const Cutter = styled("div")` | ||
position: absolute; | ||
left: 15px; | ||
bottom: 0px; | ||
width: calc(100% - 30px); | ||
height: 1px; | ||
background: #d7d7d7; | ||
&::after { | ||
background: linear-gradient(-45deg, #ffffff 2px, transparent 0), | ||
linear-gradient(45deg, #d7d7d7 2px, transparent 0); | ||
background-position: left-bottom; | ||
background-repeat: repeat-x; | ||
background-size: 4px 4px; | ||
content: " "; | ||
display: block; | ||
position: absolute; | ||
bottom: 0px; | ||
left: 0px; | ||
width: 100%; | ||
height: 4px; | ||
} | ||
`; | ||
|
||
const ReceiptPositioner = styled("div")` | ||
width: 100%; | ||
height: 39px; | ||
position: absolute; | ||
left: 0px; | ||
bottom: 0px; | ||
display: flex; | ||
justify-content: center; | ||
`; | ||
|
||
const ReceiptHider = styled("div")` | ||
width: 100%; | ||
overflow: hidden; | ||
display: flex; | ||
justify-content: center; | ||
height: 450px; | ||
`; | ||
|
||
const ReceiptColumn = styled("div")` | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
position: relative; | ||
&::after{ | ||
content: ""; | ||
width: 340px; | ||
height: 30px; | ||
background: linear-gradient(to bottom, rgba(0,0,0,.3), rgba(0,0,0,0)); | ||
position: absolute; | ||
left: 0px; | ||
top: 0px; | ||
z-index: 9; | ||
transition: opacity 500ms; | ||
opacity: ${({show}) => show ? 1 : 0}; | ||
} | ||
`; | ||
|
||
const printPaper = keyframes` | ||
0%{ | ||
transform: translateY(-100%); | ||
} | ||
100%{ | ||
transform: translateY(0%); | ||
} | ||
`; | ||
|
||
const tearPaper = keyframes` | ||
0%{ | ||
transform: translateY(0%) rotate(0deg); | ||
} | ||
25%{ | ||
transform: translateY(3%) rotate(3deg); | ||
} | ||
65%{ | ||
opacity: 1; | ||
} | ||
100%{ | ||
transform: translateY(100%) rotate(10deg); | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
const ReceiptPaper = styled("div")` | ||
width: 340px; | ||
background: #fff; | ||
position: relative; | ||
box-shadow: 0px 10px 10px -4px rgba(0, 0, 0, 0.2); | ||
transform: translateY(-100%); | ||
z-index: 3; | ||
animation: ${({ tearing, printing }) => | ||
tearing | ||
? css` | ||
${tearPaper} 700ms | ||
` | ||
: printing | ||
? css` | ||
${printPaper} 1000ms | ||
` | ||
: ""}; | ||
animation-fill-mode: forwards; | ||
animation-timing-function: linear; | ||
transform-origin: top left; | ||
&::after { | ||
background: linear-gradient(-45deg, white 4px, transparent 0), | ||
linear-gradient(45deg, white 4px, transparent 0); | ||
transform: rotate(180deg); | ||
background-position: left-bottom; | ||
background-repeat: repeat-x; | ||
background-size: 8px 8px; | ||
content: " "; | ||
display: block; | ||
position: absolute; | ||
bottom: -8px; | ||
left: 0px; | ||
width: 100%; | ||
height: 8px; | ||
} | ||
&::before { | ||
background: linear-gradient(-45deg, white 4px, transparent 0), | ||
linear-gradient(45deg, white 4px, transparent 0); | ||
background-position: left-bottom; | ||
background-repeat: repeat-x; | ||
background-size: 8px 8px; | ||
content: " "; | ||
display: block; | ||
position: absolute; | ||
top: -8px; | ||
left: 0px; | ||
width: 100%; | ||
height: 8px; | ||
} | ||
`; | ||
|
||
const Quote = styled('p')` | ||
font-family: "VT323", monospace; | ||
white-space: pre-wrap; | ||
margin: 0px; | ||
padding: 15px; | ||
font-size: 24px; | ||
padding-bottom: 0px; | ||
` | ||
|
||
// const ReceiptShadow = styled("div")` | ||
// position: absolute; | ||
// width: calc(100% + 20px); | ||
// height: 100%; | ||
// background: rgba(0, 0, 0, 0.2); | ||
// filter: blur(15px); | ||
// left: -10px; | ||
// top: 0px; | ||
// content: ""; | ||
// transform: perspective(1000px) rotateX(-30deg); | ||
// z-index: -2; | ||
// `; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@font-face { | ||
font-family: "Digital"; | ||
font-weight: 400; | ||
src: url("./digital.ttf") format("truetype"); | ||
} | ||
* { | ||
box-sizing: border-box; | ||
} | ||
body, | ||
input, | ||
textarea, | ||
button { | ||
font-family: "Montserrat", sans-serif; | ||
} | ||
body { | ||
background: #d5d8d9; | ||
} | ||
.github-corner:hover .octo-arm { | ||
animation: octocat-wave 560ms ease-in-out; | ||
} | ||
@keyframes octocat-wave { | ||
0%, | ||
100% { | ||
transform: rotate(0); | ||
} | ||
20%, | ||
60% { | ||
transform: rotate(-25deg); | ||
} | ||
40%, | ||
80% { | ||
transform: rotate(10deg); | ||
} | ||
} | ||
@media (max-width: 500px) { | ||
.github-corner:hover .octo-arm { | ||
animation: none; | ||
} | ||
.github-corner .octo-arm { | ||
animation: octocat-wave 560ms ease-in-out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<title>Barcode Generator | Tecuity</title> | ||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,600|VT323&display=swap" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="text/javascript" src="./index.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.