-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
83811e0
commit d9bdb48
Showing
21 changed files
with
288 additions
and
133 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const puppeteer = require('puppeteer') | ||
|
||
;(async () => { | ||
const browser = await puppeteer.launch() | ||
try { | ||
const page = await browser.newPage() | ||
async function shoot(path, query = '') { | ||
await page.goto(`http://creepyface.io/cover?seed=7&${query}`) | ||
await page.waitForSelector('.loaded') | ||
const element = await page.$('.cover') | ||
await element.screenshot({ path }) | ||
} | ||
await shoot('cover.jpg', 'small=true') | ||
await shoot('packages/creepyface-site/public/logo.jpg') | ||
} finally { | ||
await browser.close() | ||
} | ||
})() |
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
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
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,22 +1,65 @@ | ||
import React from 'react' | ||
import classNames from 'classnames' | ||
import { Point } from 'creepyface' | ||
import { GetServerSideProps, InferGetServerSidePropsType } from 'next' | ||
import React, { useCallback, useEffect, useState } from 'react' | ||
import CreepyFaces from '../src/components/CreepyFaces' | ||
import Logo from '../src/components/Logo' | ||
import useImperativePointProvider from '../src/hooks/imperative' | ||
import { smallImageSize } from '../src/util/constants' | ||
import knuthShuffle from 'knuth-shuffle-seeded' | ||
import range from 'lodash.range' | ||
|
||
// Use 1080 * 540 | ||
export default function Cover() { | ||
export const getServerSideProps: GetServerSideProps<{ | ||
rows: number | ||
cols: number | ||
seed: number | ||
}> = async (context) => ({ | ||
props: { | ||
rows: context.query.small === 'true' ? 4 : 6, | ||
cols: 12, | ||
seed: parseInt((context.query.seed as string) ?? '0'), | ||
}, | ||
}) | ||
|
||
export default function Cover( | ||
props: InferGetServerSidePropsType<typeof getServerSideProps> | ||
) { | ||
const { rows, cols, seed } = props | ||
const [lastPoint, setLastPoint] = useState<Point>() | ||
const [pointProvider, setPoint] = useImperativePointProvider() | ||
const [loaded, setLoaded] = useState(false) | ||
|
||
useEffect(() => { | ||
if (loaded && lastPoint) { | ||
setPoint(lastPoint) | ||
} | ||
}, [loaded, lastPoint, setPoint]) | ||
|
||
return ( | ||
<> | ||
<style jsx global>{` | ||
.logo { | ||
width: 56vw; | ||
position: relative; | ||
transform: translateY(-24%); | ||
} | ||
`}</style> | ||
<CreepyFaces timeToDefault={0} points={pointProvider} fullscreen dim /> | ||
<Logo onPointerPositionChange={setPoint} /> | ||
</> | ||
<div | ||
className={classNames('cover', { loaded })} | ||
style={{ width: cols * smallImageSize, height: rows * smallImageSize }} | ||
> | ||
<CreepyFaces | ||
timeToDefault={0} | ||
points={pointProvider} | ||
fullscreen | ||
dim | ||
shuffle | ||
getIds={useCallback( | ||
(size: number, total: number) => { | ||
const ids = knuthShuffle( | ||
range(total - 1).map((i) => i + 1), | ||
seed | ||
) | ||
ids[(Math.floor(rows / 2) - 2) * cols + 5] = 0 | ||
return ids.slice(0, size) | ||
}, | ||
[rows, cols, seed] | ||
)} | ||
onLoad={useCallback(() => setLoaded(true), [])} | ||
/> | ||
<Logo simple onPointerPositionChange={setLastPoint} /> | ||
</div> | ||
) | ||
} |
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,7 +1,6 @@ | ||
import { GetStaticProps } from 'next' | ||
import Home from '.' | ||
import { getHomeGetStaticProps } from '../src/backend/api' | ||
|
||
export const getStaticProps: GetStaticProps<React.ComponentProps<typeof Home>> = | ||
async () => ({ props: { create: true } }) | ||
export const getStaticProps = getHomeGetStaticProps(true) | ||
|
||
export default Home |
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
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
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
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
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
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
Oops, something went wrong.