-
Notifications
You must be signed in to change notification settings - Fork 3
/
website.js
141 lines (120 loc) · 2.92 KB
/
website.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import styled from '@emotion/styled'
import React from 'react'
import ReactDOM from 'react-dom'
import useMobileDetect from 'use-mobile-detect-hook'
import { SplitColorChannelText, FliesText, LiquidDistortionText, DistortionText } from './src'
const COLOR = '#2f2f2f'
const Container = styled.div`
font-family: -apple-system, system-ui, BlinkMacSystemFont;
display: flex;
justify-content: center;
align-items: center;
flex-direction: ${props => props.direction};
margin-top: ${props => props.top};
#description {
color: ${COLOR};
font-size: 1.4rem;
margin-bottom: 80px;
a {
text-decoration: none;
border-bottom: 2px solid;
color: inherit;
}
}
.footer-container {
margin-top: 30px;
}
footer {
font-size: 1.4rem;
color: inherit;
a {
text-decoration: none;
border-bottom: 2px solid;
color: inherit;
}
}
@media only screen and (max-width: 1024px) {
#description {
font-size: 0.9rem;
margin-left: 5px;
margin-top: 20px;
margin-bottom: 30px;
line-height: 1.3rem;
}
footer {
font-size: 1rem;
}
}
`
const LinkButton = styled.a`
text-decoration: none;
padding: 1rem;
border: 4px solid ${COLOR};
font-size: 1.2rem;
color: ${COLOR};
font-weigth: bold;
transition: background 0.1s;
border-radius: 5px;
&:hover {
background-color: ${COLOR};
color: white;
}
@media only screen and (max-width: 1024px) {
font-size: 0.9rem;
padding: 0.5rem;
border-width: 2px;
border-radius: 3px;
}
`
const Footer = props => (
<footer style={{ marginTop: 5 }}>
<p>
Made with ♥ by <a href="http://ntsketches.in">Nitin Tulswani</a>
</p>
</footer>
)
const App = props => {
const detectMobile = useMobileDetect()
const [value, setValue] = React.useState(0)
const [width, setWidth] = React.useState()
const ref = React.createRef()
React.useEffect(() => {
const { width } = ref.current.getBoundingClientRect()
setWidth(width)
})
const updateShader = e => {
if (!detectMobile.isMobile()) {
setValue(e.clientX)
}
}
return (
<Container top="50px" direction="column" ref={ref} onMouseMove={updateShader}>
<div id="app">
<FliesText
appendTo="app"
text="React Text Fun"
fontSize={detectMobile.isMobile() ? 50 : 220}
fontWeight="bold"
fill="#2f2f2f"
cellWidth={value < 1 ? 0.02 : value * 0.000015}
speed={6}
dodge={true}
dodgeY={value === 0 ? 2.0 : value / 1000}
/>
</div>
<div id="description">
A small component library that encapsulates <a href="https://blotter.js.org/#/materials">Blotter.js</a> shader
materials in the form of React components and provides a very easy to use API.
</div>
<div>
<LinkButton href="https://github.com/nitin42/react-text-fun#table-of-contents" aria-label="documentation">
Documentation
</LinkButton>
</div>
<div className="footer-container">
<Footer />
</div>
</Container>
)
}
ReactDOM.render(<App />, document.getElementById('root'))