mirror of
https://github.com/cupcakearmy/old.nicco.io.git
synced 2024-11-01 00:24:16 +01:00
redesign
This commit is contained in:
commit
a57ad5087a
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
public
|
||||
|
||||
.idea
|
||||
.vscode
|
38
README.md
Normal file
38
README.md
Normal file
@ -0,0 +1,38 @@
|
||||
# React Typescript Stylus Webpack Boilerplate 👨🍳
|
||||
|
||||
This is the starting point for any react-typescript-stylus-webpack-hipsterframeworkxyz boilerplate to get up and running quickly.
|
||||
|
||||
## Getting Started 🚀
|
||||
|
||||
```bash
|
||||
git clone https://github.com/CupCakeArmy/react-boilerplate.git
|
||||
npm i
|
||||
npm run dev
|
||||
|
||||
# Or
|
||||
wget https://github.com/CupCakeArmy/react-boilerplate/archive/master.zip
|
||||
unzip master
|
||||
```
|
||||
|
||||
## Usage 📖
|
||||
|
||||
### Build 🛠
|
||||
|
||||
```bash
|
||||
# Dev
|
||||
npm run build:dev
|
||||
|
||||
# Prod
|
||||
npm run build:prod
|
||||
```
|
||||
|
||||
### Dev 👀
|
||||
|
||||
Compiles on files changed
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
|
||||
# Go to
|
||||
http://localhost:8080
|
||||
```
|
30
package.json
Executable file
30
package.json
Executable file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build:dev": "webpack -d",
|
||||
"build:prod": "webpack -p",
|
||||
"dev": "webpack-dev-server -d"
|
||||
},
|
||||
"dependencies": {
|
||||
"animejs": "^3.0.1",
|
||||
"react": "^16.8",
|
||||
"react-dom": "^16.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/animejs": "^2.0.1",
|
||||
"@types/react": "^16.8",
|
||||
"@types/react-dom": "^16.8",
|
||||
"awesome-typescript-loader": "^5",
|
||||
"css-loader": "^2",
|
||||
"file-loader": "^3",
|
||||
"html-webpack-plugin": "^3",
|
||||
"mini-css-extract-plugin": "^0.5.0",
|
||||
"style-loader": "^0",
|
||||
"stylus": "^0",
|
||||
"stylus-loader": "^3",
|
||||
"typescript": "^3.3.3",
|
||||
"webpack": "^4",
|
||||
"webpack-cli": "^3",
|
||||
"webpack-dev-server": "^3.1.14"
|
||||
}
|
||||
}
|
38
src/App.tsx
Normal file
38
src/App.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import React from 'react'
|
||||
import AnimatedBackground from './Components/AnimatedBackground'
|
||||
import Cursor from './Components/Cursor'
|
||||
import Letters from './Screens/Letters'
|
||||
import { useMousePosition } from './util'
|
||||
|
||||
export const Duration = 4000
|
||||
|
||||
const App: React.FC = () => {
|
||||
|
||||
const mouse = useMousePosition()
|
||||
|
||||
const convertToDeg = (current: number, factor: number) => `${(.5 - current) * factor}deg`
|
||||
|
||||
return <div id="App">
|
||||
<section id={'letters-container'} style={{
|
||||
transform: `rotateX(${convertToDeg(mouse.relative.y, 2)}) rotateY(${convertToDeg(mouse.relative.x, .5)})`,
|
||||
}}>
|
||||
<h1>
|
||||
<Letters/>
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
<div id={'bg'}>
|
||||
<AnimatedBackground/>
|
||||
</div>
|
||||
|
||||
<Cursor/>
|
||||
|
||||
<footer>
|
||||
<span>dev.</span>
|
||||
<br/>
|
||||
<span>say <a href={'mailto:hi@nicco.io'}>hi@nicco.io</a></span>
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
|
||||
export default App
|
38
src/Components/AnimatedBackground.tsx
Normal file
38
src/Components/AnimatedBackground.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Duration } from '../App'
|
||||
import { GoldenRatio, Rand } from '../util'
|
||||
|
||||
type Color = [number, number, number]
|
||||
|
||||
const getRandomColor = () => [Rand(0, 255), Rand(70, 90), Rand(80, 90)] as Color
|
||||
const colorToString = ([h, s, l]: Color) => `hsl(${h}, ${s}%, ${l}%)` as string
|
||||
const valuesToGradient = (dir: number, from: Color, to: Color) => `linear-gradient(${dir}deg, ${colorToString(from)}, ${colorToString(to)})` as string
|
||||
|
||||
const AnimatedBackground: React.FC = () => {
|
||||
|
||||
const [start, setStart] = useState<Color>([255, 255, 255])
|
||||
const [end, setEnd] = useState<Color>([255, 255, 255])
|
||||
const [direction, setDirection] = useState<number>(0)
|
||||
|
||||
const update = () => {
|
||||
const from = getRandomColor()
|
||||
// Calculate cojugate color based on the golden ratio
|
||||
const to: Color = [Math.floor(from[0] + (255 * GoldenRatio * 2)) % 255, from[1], from[2]]
|
||||
|
||||
setStart(from)
|
||||
setEnd(to)
|
||||
setDirection(Rand(0, 360))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
update()
|
||||
const interval = setInterval(update, Duration)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
return <div className={'animated-background'} style={{
|
||||
backgroundImage: valuesToGradient(direction, start, end),
|
||||
}}/>
|
||||
}
|
||||
|
||||
export default AnimatedBackground
|
22
src/Components/Cursor.tsx
Normal file
22
src/Components/Cursor.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import React from 'react'
|
||||
import { useIsMousePresent, useMousePosition } from '../util'
|
||||
|
||||
const Cursor: React.FC = () => {
|
||||
const mouse = useMousePosition()
|
||||
const present = useIsMousePresent()
|
||||
|
||||
return present
|
||||
? <span style={{
|
||||
position: 'fixed',
|
||||
top: mouse.absolute.y,
|
||||
left: mouse.absolute.x,
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
borderRadius: '1em',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
backgroundColor: '#000000',
|
||||
}}/>
|
||||
: null
|
||||
}
|
||||
|
||||
export default Cursor
|
43
src/Components/LetterAnimation.tsx
Normal file
43
src/Components/LetterAnimation.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
import anime from 'animejs'
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
import { Duration } from '../App'
|
||||
|
||||
export type LettersProps = {
|
||||
text: string
|
||||
delay?: number
|
||||
}
|
||||
|
||||
const LetterAnimation: React.FC<LettersProps> = React.memo(({ text, delay }) => {
|
||||
|
||||
const letters = useRef<HTMLElement>(null)
|
||||
|
||||
const animate = () => {
|
||||
if (!letters || !letters.current) return
|
||||
|
||||
const wrapper = letters.current
|
||||
wrapper.innerHTML = wrapper.innerText.replace(
|
||||
/./g,
|
||||
l => `<span class='letter'>${l}</span>`,
|
||||
)
|
||||
|
||||
anime({
|
||||
targets: wrapper.querySelectorAll(`.letter`),
|
||||
translateX: [40, 0],
|
||||
rotateY: [-20, 0],
|
||||
opacity: [0, 1],
|
||||
// color: () => getRandomColor(),
|
||||
easing: 'easeOutExpo',
|
||||
duration: Duration / 3,
|
||||
delay: (el, i) => (delay || 0) + 250 + 25 * i,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
useEffect(animate)
|
||||
|
||||
return <span ref={letters} className="letters">
|
||||
{text}
|
||||
</span>
|
||||
})
|
||||
|
||||
export default LetterAnimation
|
33
src/Screens/Letters.tsx
Normal file
33
src/Screens/Letters.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import LetterAnimation from '../Components/LetterAnimation'
|
||||
|
||||
type Pair = [string, string]
|
||||
|
||||
const pairs: Pair[] = [
|
||||
['visualize', 'create'],
|
||||
['invision', 'build'],
|
||||
['ideate', 'deploy'],
|
||||
]
|
||||
|
||||
export const Duration = 4000
|
||||
|
||||
const Letters: React.FC = React.memo(() => {
|
||||
|
||||
const [index, setIndex] = useState<number>(0)
|
||||
const wrapper = useRef<HTMLElement>(null)
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(
|
||||
() => setIndex((index < pairs.length - 1) ? index + 1 : 0),
|
||||
Duration,
|
||||
)
|
||||
}, [index])
|
||||
|
||||
return <span id={'letters-wrapper'} ref={wrapper}>
|
||||
<LetterAnimation text={pairs[index][0] + '.'}/>
|
||||
<LetterAnimation text={pairs[index][1] + '.'} delay={500}/>
|
||||
</span>
|
||||
})
|
||||
|
||||
export default Letters
|
14
src/index.html
Executable file
14
src/index.html
Executable file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Template</title>
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
1
src/index.styl
Normal file
1
src/index.styl
Normal file
@ -0,0 +1 @@
|
||||
@require './styles/*'
|
7
src/index.tsx
Executable file
7
src/index.tsx
Executable file
@ -0,0 +1,7 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './App'
|
||||
|
||||
import './index.styl'
|
||||
|
||||
ReactDOM.render(<App/>, document.getElementById('root'))
|
4
src/styles/AnimatedBackground.styl
Normal file
4
src/styles/AnimatedBackground.styl
Normal file
@ -0,0 +1,4 @@
|
||||
.animated-background
|
||||
height 100%
|
||||
width 100%
|
||||
animation all 1s linear
|
33
src/styles/App.styl
Normal file
33
src/styles/App.styl
Normal file
@ -0,0 +1,33 @@
|
||||
@require './Breakpoints.styl'
|
||||
|
||||
#App
|
||||
height 100vh
|
||||
width 100vw
|
||||
display flex
|
||||
align-items center
|
||||
justify-content center
|
||||
perspective 1em
|
||||
|
||||
#bg
|
||||
position absolute
|
||||
left 0
|
||||
top 0
|
||||
width 100vw
|
||||
height 100vh
|
||||
z-index -1
|
||||
|
||||
#letters-wrapper
|
||||
display inline-block
|
||||
text-align center
|
||||
font-size 1em
|
||||
font-weight bold
|
||||
+is-phone()
|
||||
font-size 2.5em
|
||||
+is-tablet()
|
||||
font-size 3em
|
||||
+is-netbook()
|
||||
font-size 3.5em
|
||||
+is-laptop()
|
||||
font-size 4em
|
||||
+is-desktop()
|
||||
font-size 4.5em
|
20
src/styles/Breakpoints.styl
Normal file
20
src/styles/Breakpoints.styl
Normal file
@ -0,0 +1,20 @@
|
||||
is-phone()
|
||||
@media (max-width: 599px)
|
||||
{block}
|
||||
|
||||
is-tablet()
|
||||
@media (min-width: 600px) {
|
||||
block
|
||||
}
|
||||
|
||||
is-netbook()
|
||||
@media (min-width: 900px)
|
||||
{block}
|
||||
|
||||
is-laptop()
|
||||
@media (min-width: 1200px)
|
||||
{block}
|
||||
|
||||
is-desktop()
|
||||
@media (min-width: 1800px)
|
||||
{block}
|
18
src/styles/Footer.styl
Normal file
18
src/styles/Footer.styl
Normal file
@ -0,0 +1,18 @@
|
||||
footer
|
||||
font-family 'Inconsolata', monospace
|
||||
display flex
|
||||
align-items center
|
||||
justify-content center
|
||||
flex-direction column
|
||||
font-size 1.2em
|
||||
position absolute
|
||||
bottom 0
|
||||
left 0
|
||||
text-align center
|
||||
width 100vw
|
||||
padding 1em
|
||||
|
||||
a
|
||||
text-decoration inherit
|
||||
color inherit
|
||||
font-weight bold
|
9
src/styles/Letters.styl
Normal file
9
src/styles/Letters.styl
Normal file
@ -0,0 +1,9 @@
|
||||
.letters
|
||||
display inline-block
|
||||
position relative
|
||||
letter-spacing .05em
|
||||
|
||||
.letter
|
||||
display inline-block
|
||||
transform-origin 0 0
|
||||
line-height 1em
|
16
src/styles/global.styl
Normal file
16
src/styles/global.styl
Normal file
@ -0,0 +1,16 @@
|
||||
@import url('https://fonts.googleapis.com/css?family=Raleway')
|
||||
@import url('https://fonts.googleapis.com/css?family=Merriweather:300,400,700')
|
||||
@import url('https://fonts.googleapis.com/css?family=Inconsolata:400,700')
|
||||
|
||||
*
|
||||
box-sizing border-box
|
||||
cursor none
|
||||
|
||||
html,
|
||||
body,
|
||||
#root
|
||||
margin 0
|
||||
border 0
|
||||
font-family 'Merriweather', serif
|
||||
font-size 1em
|
||||
overflow hidden
|
56
src/util.ts
Normal file
56
src/util.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
const getSize = () => {
|
||||
const { innerHeight, innerWidth, outerHeight, outerWidth } = window
|
||||
return { innerHeight, innerWidth, outerHeight, outerWidth }
|
||||
}
|
||||
|
||||
export const useIsMousePresent = ()=> {
|
||||
let [present, setPresent] = useState<boolean>(true)
|
||||
|
||||
useEffect(() => {
|
||||
const enter = ()=> setPresent(true)
|
||||
const leave = ()=> setPresent(false)
|
||||
window.document.addEventListener('mouseenter', enter)
|
||||
window.document.addEventListener('mouseleave', leave)
|
||||
return () => {
|
||||
window.document.removeEventListener('mouseenter', enter)
|
||||
window.document.removeEventListener('mouseleave', leave)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return present
|
||||
}
|
||||
|
||||
export const useMousePosition = () => {
|
||||
let [position, setPosition] = useState({ absolute: { x: 0, y: 0 }, relative: { x: 0, y: 0 } })
|
||||
|
||||
const handle = (e: MouseEvent) => {
|
||||
setPosition({
|
||||
absolute: {
|
||||
x: e.pageX,
|
||||
y: e.pageY,
|
||||
},
|
||||
relative: {
|
||||
x: e.pageX / window.innerWidth,
|
||||
y: e.pageY / window.innerHeight,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('mousemove', handle)
|
||||
return () => {
|
||||
window.removeEventListener('mousemove', handle)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return position
|
||||
}
|
||||
|
||||
export const Rand = (from: number = 0, to: number = 1, float: boolean = false) => {
|
||||
const rand = (Math.random() * (to - from)) + from
|
||||
return float ? rand : rand | 0
|
||||
}
|
||||
|
||||
export const GoldenRatio: number = (1 + Math.sqrt(5)) / 2
|
60
tsconfig.json
Normal file
60
tsconfig.json
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
"removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
}
|
||||
}
|
65
webpack.config.js
Executable file
65
webpack.config.js
Executable file
@ -0,0 +1,65 @@
|
||||
const path = require('path')
|
||||
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
|
||||
module.exports = {
|
||||
entry: [
|
||||
'./index.tsx'
|
||||
],
|
||||
output: {
|
||||
filename: 'bundle.js',
|
||||
path: path.resolve(__dirname, 'public')
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
||||
},
|
||||
context: path.resolve(__dirname, 'src'),
|
||||
devServer: {
|
||||
contentBase: path.resolve(__dirname, 'public/assets'),
|
||||
open: true,
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'index.html'
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'bundle.css'
|
||||
})
|
||||
],
|
||||
stats: {
|
||||
assets: true,
|
||||
assetsSort: 'size',
|
||||
all: false,
|
||||
errors: true,
|
||||
colors: true,
|
||||
performance: true,
|
||||
timings: true,
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
},
|
||||
// {
|
||||
// test: /\.html$/,
|
||||
// use: ['html-loader']
|
||||
// },
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader']
|
||||
}, {
|
||||
test: /\.styl$/,
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader'],
|
||||
}, {
|
||||
test: /\.(jpg|png|gif|svg|woff2?|ttf|eot|svg|otf)$/,
|
||||
use: [{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: './assets/',
|
||||
},
|
||||
}],
|
||||
}]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user