-
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.
- Loading branch information
Showing
5 changed files
with
146 additions
and
155 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,176 +1,143 @@ | ||
import * as React from "react" | ||
import * as React from 'react' | ||
// import {reactive} from 'https://esm.sh/@arrow-js/core'; | ||
|
||
const pageStyles = { | ||
color: "#232129", | ||
padding: 96, | ||
fontFamily: "-apple-system, Roboto, sans-serif, serif", | ||
} | ||
const headingStyles = { | ||
marginTop: 0, | ||
marginBottom: 64, | ||
maxWidth: 320, | ||
} | ||
const headingAccentStyles = { | ||
color: "#663399", | ||
} | ||
const paragraphStyles = { | ||
marginBottom: 48, | ||
} | ||
const codeStyles = { | ||
color: "#8A6534", | ||
padding: 4, | ||
backgroundColor: "#FFF4DB", | ||
fontSize: "1.25rem", | ||
borderRadius: 4, | ||
} | ||
const listStyles = { | ||
marginBottom: 96, | ||
paddingLeft: 0, | ||
} | ||
const listItemStyles = { | ||
fontWeight: 300, | ||
fontSize: 24, | ||
maxWidth: 560, | ||
marginBottom: 30, | ||
} | ||
import costumeTemplateSrc from '../images/motor-spirit-costume-template.jpg' | ||
import costumeLogoSrc from '../images/motor-spirit-costume-logo.png' | ||
|
||
const linkStyle = { | ||
color: "#8954A8", | ||
fontWeight: "bold", | ||
fontSize: 16, | ||
verticalAlign: "5%", | ||
} | ||
import './index.scss' | ||
|
||
const docLinkStyle = { | ||
...linkStyle, | ||
listStyleType: "none", | ||
marginBottom: 24, | ||
} | ||
const cWidth = 1033; | ||
const cHeight = 1280; | ||
|
||
let uploadedImage; | ||
global.uploadedImage = uploadedImage; | ||
|
||
const descriptionStyle = { | ||
color: "#232129", | ||
fontSize: 14, | ||
marginTop: 10, | ||
marginBottom: 0, | ||
lineHeight: 1.25, | ||
function _(domId) { | ||
return document.getElementById(domId) | ||
} | ||
|
||
const docLink = { | ||
text: "Documentation", | ||
url: "https://www.gatsbyjs.com/docs/", | ||
color: "#8954A8", | ||
function val(domId) { | ||
return _(domId).value.trim(); | ||
} | ||
|
||
const badgeStyle = { | ||
color: "#fff", | ||
backgroundColor: "#088413", | ||
border: "1px solid #088413", | ||
fontSize: 11, | ||
fontWeight: "bold", | ||
letterSpacing: 1, | ||
borderRadius: 4, | ||
padding: "4px 6px", | ||
display: "inline-block", | ||
position: "relative", | ||
top: -2, | ||
marginLeft: 10, | ||
lineHeight: 1, | ||
function click() { | ||
let costumeName = val('costumeName'); | ||
const canvas = _('canvas'); | ||
canvas.width = cWidth; | ||
canvas.height = cHeight; | ||
const ctx = canvas.getContext('2d'); | ||
const templateImage = new Image(); | ||
templateImage.src = costumeTemplateSrc; | ||
ctx.drawImage(templateImage, 0, 0, cWidth, cHeight); | ||
ctx.fillStyle = 'white'; | ||
ctx.strokeStyle = 'black'; | ||
ctx.textAlign = 'center'; | ||
ctx.font = `${cHeight/20}px Arial`; | ||
// if (ctx.measureText(costumeName).width > cWidth/2) { | ||
// costumeName = costumeName.replace(' ', '\n') | ||
// } // TODO way to linebreak? | ||
ctx.fillText(costumeName, 290, 440); | ||
ctx.strokeText(costumeName, 290, 440); | ||
ctx.textAlign = 'left'; | ||
ctx.font = `${cHeight/30}px Arial`; | ||
ctx.fillText('Includes:', 150, 650); | ||
if (val('component1')) ctx.fillText(`– ${val('component1')}`, 150, 700); | ||
if (val('component2')) ctx.fillText(`– ${val('component2')}`, 150, 750); | ||
if (val('component3')) ctx.fillText(`– ${val('component3')}`, 150, 800); | ||
if (val('component4')) ctx.fillText(`– ${val('component4')}`, 150, 850); | ||
const maskPoints = { | ||
NW: [685, 175], NE: [905, 180], | ||
Wmidpoint: [325, 650], Wradius: 700, | ||
SW: [680, 1150], SE: [930, 1160], | ||
} | ||
const maskWidth = Math.max(maskPoints.NE[0], maskPoints.SE[0]) - maskPoints.Wmidpoint[0]; // 505 | ||
const maskHeight = Math.max(maskPoints.SE[1], maskPoints.SW[1]) - Math.min(maskPoints.NE[1], maskPoints.NW[1]); | ||
ctx.beginPath(); | ||
ctx.moveTo(...maskPoints.NW); | ||
ctx.lineTo(...maskPoints.NE); | ||
ctx.lineTo(...maskPoints.SE); | ||
ctx.lineTo(...maskPoints.SW); | ||
ctx.arcTo(...maskPoints.Wmidpoint, ...maskPoints.NW, maskPoints.Wradius); | ||
ctx.closePath(); | ||
ctx.clip(); | ||
// global.console.log({maskWidth, maskHeight}, ' ... uploadedImage w h:', uploadedImage.width, 'x', uploadedImage.height) | ||
const multiplier = maskHeight / uploadedImage.height; | ||
const newImageWidth = Math.floor(uploadedImage.width * multiplier); | ||
const newImageHeight = maskHeight; | ||
uploadedImage.width = newImageWidth; | ||
uploadedImage.height = newImageHeight; | ||
// global.console.log('new...', uploadedImage.width, uploadedImage.height); | ||
ctx.drawImage(uploadedImage, | ||
// sx, sy, sWidth, sHeight, | ||
maskPoints.Wmidpoint[0] - (uploadedImage.width / 2) + (maskWidth / 2), | ||
maskPoints.NW[1], // ... NW[1] - (uploadedImage.height/2) + (maskHeight/2) | ||
newImageWidth, | ||
newImageHeight | ||
); | ||
// 425, 175 ... mask spans from x=425 to x=930... midpoint 677.5... | ||
// global.console.log( maskPoints.Wmidpoint[0] - (uploadedImage.width / 2) + (maskWidth / 2), maskPoints.NW[1]) // ... NW[1] - (uploadedImage.height/2) + (maskHeight/2) | ||
|
||
} | ||
|
||
const links = [ | ||
{ | ||
text: "Tutorial", | ||
url: "https://www.gatsbyjs.com/docs/tutorial/getting-started/", | ||
description: | ||
"A great place to get started if you're new to web development. Designed to guide you through setting up your first Gatsby site.", | ||
color: "#E95800", | ||
}, | ||
{ | ||
text: "How to Guides", | ||
url: "https://www.gatsbyjs.com/docs/how-to/", | ||
description: | ||
"Practical step-by-step guides to help you achieve a specific goal. Most useful when you're trying to get something done.", | ||
color: "#1099A8", | ||
}, | ||
{ | ||
text: "Reference Guides", | ||
url: "https://www.gatsbyjs.com/docs/reference/", | ||
description: | ||
"Nitty-gritty technical descriptions of how Gatsby works. Most useful when you need detailed information about Gatsby's APIs.", | ||
color: "#BC027F", | ||
}, | ||
{ | ||
text: "Conceptual Guides", | ||
url: "https://www.gatsbyjs.com/docs/conceptual/", | ||
description: | ||
"Big-picture explanations of higher-level Gatsby concepts. Most useful for building understanding of a particular topic.", | ||
color: "#0D96F2", | ||
}, | ||
{ | ||
text: "Plugin Library", | ||
url: "https://www.gatsbyjs.com/plugins", | ||
description: | ||
"Add functionality and customize your Gatsby site or app with thousands of plugins built by our amazing developer community.", | ||
color: "#8EB814", | ||
}, | ||
{ | ||
text: "Build and Host", | ||
url: "https://www.gatsbyjs.com/cloud", | ||
badge: true, | ||
description: | ||
"Now you’re ready to show the world! Give your Gatsby site superpowers: Build and host on Gatsby Cloud. Get started for free!", | ||
color: "#663399", | ||
}, | ||
] | ||
function fileOnChange({target: uploadTarget}) { | ||
const [file] = uploadTarget.files | ||
if (file?.type.match('image.*')) { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = ({target: readerTarget}) => { | ||
if (readerTarget.readyState == FileReader.DONE) { | ||
uploadedImage = new Image(); | ||
uploadedImage.src = readerTarget.result; | ||
_('button').innerText = 'okay meme it' | ||
} | ||
} | ||
} else alert('got to be an image!') | ||
} | ||
|
||
const IndexPage = () => { | ||
return ( | ||
<main style={pageStyles}> | ||
<h1 style={headingStyles}> | ||
Congratulations | ||
<br /> | ||
<span style={headingAccentStyles}>— you just made a Gatsby site! 🎉🎉🎉</span> | ||
<main> | ||
<h1> | ||
<img src={costumeLogoSrc} style={{height:'3em',verticalAlign:'middle'}} alt="'Motor Spirit Costumes' logo (parody of Spirit Halloween's logo) by @billabongvalley@Instagram" /> | ||
Gizz Costume Generator | ||
</h1> | ||
<p style={paragraphStyles}> | ||
Edit <code style={codeStyles}>src/pages/index.js</code> to see this page | ||
update in real-time. 😎 | ||
</p> | ||
<ul style={listStyles}> | ||
<li style={docLinkStyle}> | ||
<a | ||
style={linkStyle} | ||
href={`${docLink.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`} | ||
> | ||
{docLink.text} | ||
</a> | ||
</li> | ||
{links.map(link => ( | ||
<li key={link.url} style={{ ...listItemStyles, color: link.color }}> | ||
<span> | ||
<a | ||
style={linkStyle} | ||
href={`${link.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`} | ||
> | ||
{link.text} | ||
</a> | ||
{link.badge && ( | ||
<span style={badgeStyle} aria-label="New Badge"> | ||
NEW! | ||
</span> | ||
)} | ||
<p style={descriptionStyle}>{link.description}</p> | ||
</span> | ||
<canvas id="canvas"/> | ||
<div id="form"> | ||
<label>What's the costume? | ||
<input id="costumeName" name="costumeName" /> | ||
</label> | ||
<p>What's it come with?</p> | ||
<ul> | ||
<li> | ||
<label>component 1 | ||
<input id="component1" name="component1" /> | ||
</label> | ||
</li> | ||
<li> | ||
<label>component 2 | ||
<input id="component2" name="component2" /> | ||
</label> | ||
</li> | ||
<li> | ||
<label>component 3 | ||
<input id="component3" name="component3" /> | ||
</label> | ||
</li> | ||
<li> | ||
<label>component 4 | ||
<input id="component4" name="component4" /> | ||
</label> | ||
</li> | ||
))} | ||
</ul> | ||
<img | ||
alt="Gatsby G Logo" | ||
src="data:image/svg+xml,%3Csvg width='24' height='24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2a10 10 0 110 20 10 10 0 010-20zm0 2c-3.73 0-6.86 2.55-7.75 6L14 19.75c3.45-.89 6-4.02 6-7.75h-5.25v1.5h3.45a6.37 6.37 0 01-3.89 4.44L6.06 9.69C7 7.31 9.3 5.63 12 5.63c2.13 0 4 1.04 5.18 2.65l1.23-1.06A7.959 7.959 0 0012 4zm-8 8a8 8 0 008 8c.04 0 .09 0-8-8z' fill='%23639'/%3E%3C/svg%3E" | ||
/> | ||
</ul> | ||
<label>Pick a photo... | ||
<input type="file" id="image" onChange={fileOnChange} /> | ||
</label> | ||
<button id="button" onClick={click}>Add image first</button> | ||
</div> | ||
</main> | ||
) | ||
} | ||
|
||
export default IndexPage | ||
|
||
export const Head = () => <title>Home Page</title> | ||
export const Head = () => <title>KGLW.net presents Motor Spirit Costumes</title> |
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,24 @@ | ||
main { | ||
display: flex; | ||
flex-flow: row wrap; | ||
height: 100%; | ||
} | ||
|
||
h1 { | ||
max-width: 15em; | ||
font-family: Agbalumo, fantasy; | ||
} | ||
|
||
#form { // yeah I know | ||
max-width: 20em; | ||
margin-bottom: 2rem; | ||
text-align: center; | ||
ul { | ||
text-align: left; | ||
} | ||
} | ||
|
||
canvas { | ||
background: pink; | ||
max-width: min(100%, 20rem); | ||
} |