Skip to content

Commit

Permalink
add form
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-parag committed Jul 3, 2020
1 parent f7cfb78 commit c2534e0
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
statickit.json
99 changes: 99 additions & 0 deletions components/ContactForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from 'react'
import styled from 'styled-components'
import { designTokens } from '../Theme/designTokens'
import { useForm, ValidationError } from '@statickit/react';

const FormButton = styled.button`
font-family: inherit;
border: 1px solid var(--primary);
background: var(--primaryTransparent);
color: var(--primaryDark);
display: block;
width: 100%;
padding: ${designTokens.space[3]};
border-radius: ${designTokens.space[1]};
margin-top: ${designTokens.space[4]};
cursor: pointer;
transition: all 120ms ease-out 0s;
&:hover, &:focus {
border-color: var(--primaryTransparent);
}
`

const EmptyStateIcon = styled.div`
display: inline-flex;
background: var(--primaryTransparent);
color: var(--primary);
align-items: center;
justify-content: center;
width: ${designTokens.space[7]};
height: ${designTokens.space[7]};
margin-bottom: ${designTokens.space[2]};
border-radius: 50%;
`

const EmptyState = styled.div`
display: flex;
align-items: center;
flex-direction: column;
`

export default function ContactForm() {

const [state, handleSubmit] = useForm("contactForm");
if (state.succeeded) {
return(
<EmptyState>
<EmptyStateIcon>
<svg width="48" height="48" xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>
<polyline points='416 128 192 384 96 288' style={{
fill: 'none',
stroke: 'currentColor',
strokeLinecap: 'round',
strokeLinejoin:'round',
strokeWidth: '32px'
}}/>
</svg>
</EmptyStateIcon>
<h4>Message Sent!</h4>
</EmptyState>
)
}

return(
<form onSubmit={handleSubmit}>
<p>Do you have feedback about this post or want to suggest an idea you'd like to hear about in a future post? Send me a message!</p>
<label htmlFor="message">
Message
</label>
<textarea
id="message"
name="message"
placeholder="What is your feedback or suggestion?"
/>
<ValidationError
prefix="Message"
field="message"
errors={state.errors}
style={{
color: 'var(--secondaryDark)',
fontSize: designTokens.fontSizes[1],
marginBottom: designTokens.space[3],
display: 'block'
}}
/>
<label htmlFor="email">
Email Address (Optional)
</label>
<input
id="email"
type="email"
name="email"
placeholder="[email protected]"
/>
<FormButton type="submit" disabled={state.submitting}>
Send Message
</FormButton>
</form>
)
}
36 changes: 23 additions & 13 deletions components/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ const FooterButton = styled.button`
}
`

const FooterBottom = styled.div`
display: inline-flex;
align-items: center;
margin-top: ${designTokens.space[4]};
@media screen and (max-width: ${designTokens.breakpoints[4]}) {
flex-direction: column;
}
`

const FooterLogo = styled.div`
display: inline-flex;
align-items: center;
margin-right: ${designTokens.space[4]};
@media screen and (max-width: ${designTokens.breakpoints[4]}) {
margin-bottom: ${designTokens.space[2]};
}
`

export default function Footer() {
const clearStorage = () => {
localStorage.removeItem('theme')
Expand Down Expand Up @@ -104,26 +122,18 @@ export default function Footer() {
</FooterList>
<small>Made with Next.js and Styled Components</small>
<br/>
<div style={{
display: 'inline-flex',
alignItems: 'center',
marginTop: designTokens.space[4]
}}>
<div style={{
display: 'inline-flex',
alignItems: 'center',
marginRight: designTokens.space[4]
}}>
<FooterBottom>
<FooterLogo>
<div style={{
width: '32px',
marginRight: designTokens.space[2],
}}>
<Logo/>
</div>
<strong>Ryan's Notes</strong>
</div>
<FooterButton onClick={clearStorage}>Clear Storage</FooterButton>
</div>
</FooterLogo>
<FooterButton onClick={clearStorage}>Reset Theme</FooterButton>
</FooterBottom>
</FooterInner>
</FooterContainer>
)
Expand Down
39 changes: 39 additions & 0 deletions components/GlobalStyles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,45 @@ export const GlobalStyles = createGlobalStyle`
color: var(--secondaryDark);
}
}
hr {
background: var(--grey200);
border: 0;
height: 1px
}
input, textarea, select {
font-family: inherit;
color: inherit;
background: var(--grey100);
display: block;
width: 100%;
border: 1px solid var(--grey400);
border-radius: ${designTokens.space[1]};
padding: ${designTokens.space[3]};
margin: ${designTokens.space[2]} auto ${designTokens.space[3]};
transition: all 120ms ease-out 0s;
&:focus {
background: transparent;
border-color: var(--primary);
}
}
textarea {
height: ${designTokens.space[9]};
resize: none;
}
::placeholder {
color: var(--grey500);
}
form {
label {
font-size: ${designTokens.fontSizes[1]};
color: var(--grey700);
}
}
strong {
font-weight: ${designTokens.fontWeights.bold};
Expand Down
81 changes: 42 additions & 39 deletions components/Layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ThemeProvider } from 'styled-components'
import { notionLight, notionDark, darkTheme, lightTheme, hyrule, zora, gerudo, hebra, eldin, sheikah, korok, yiga } from '../Theme/'
import { designTokens } from '../Theme/designTokens'
import Footer from '../Footer'
import { StaticKitProvider } from '@statickit/react'

const LayoutContainer = styled.div`
width: 100%;
Expand Down Expand Up @@ -69,45 +70,47 @@ export default function Layout({ children, pageTitle, description, ...props }) {
return lightTheme
})
}>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="utf-8" />
<meta name="Description" content={description}></meta>
<meta property="og:url" content="https://notes.ryanparag.com"></meta>
<meta property="og:type" content="website"></meta>
<meta property="og:title" content={pageTitle}></meta>
<meta property="og:description" content={description}></meta>
<meta property="og:image" content="/notes-social-media.png"></meta>
<link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png"></link>
<link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png"></link>
<link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png"></link>
<link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png"></link>
<link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png"></link>
<link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png"></link>
<link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png"></link>
<link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png"></link>
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png"></link>
<link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png"></link>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png"></link>
<link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png"></link>
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png"></link>
<link rel="manifest" href="/favicon/manifest.json"></link>
<meta name="msapplication-TileColor" content="#ffffff"></meta>
<meta name="msapplication-TileImage" content="/favicon/ms-icon-144x144.png"></meta>
<meta name="theme-color" content="#ffffff"></meta>
<link rel="mask-icon" href="/favicon/notes-favicon.svg" color="#00d1b2"></link>
<link rel="icon" href="/favicon/notes-favicon.svg"></link>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700;800&display=swap" rel="stylesheet"></link>
<title>{pageTitle}</title>
</Head>
<GlobalStyles/>
<Header toggleTheme={toggleTheme} theme={theme} />
<section>
<Main>
<LayoutContainer>{children}</LayoutContainer>
</Main>
</section>
<Footer/>
<StaticKitProvider site="3f3ebc6301b7">
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="utf-8" />
<meta name="Description" content={description}></meta>
<meta property="og:url" content="https://notes.ryanparag.com"></meta>
<meta property="og:type" content="website"></meta>
<meta property="og:title" content={pageTitle}></meta>
<meta property="og:description" content={description}></meta>
<meta property="og:image" content="/notes-social-media.png"></meta>
<link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png"></link>
<link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png"></link>
<link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png"></link>
<link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png"></link>
<link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png"></link>
<link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png"></link>
<link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png"></link>
<link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png"></link>
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png"></link>
<link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png"></link>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png"></link>
<link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png"></link>
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png"></link>
<link rel="manifest" href="/favicon/manifest.json"></link>
<meta name="msapplication-TileColor" content="#ffffff"></meta>
<meta name="msapplication-TileImage" content="/favicon/ms-icon-144x144.png"></meta>
<meta name="theme-color" content="#ffffff"></meta>
<link rel="mask-icon" href="/favicon/notes-favicon.svg" color="#00d1b2"></link>
<link rel="icon" href="/favicon/notes-favicon.svg"></link>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700;800&display=swap" rel="stylesheet"></link>
<title>{pageTitle}</title>
</Head>
<GlobalStyles/>
<Header toggleTheme={toggleTheme} theme={theme} />
<section>
<Main>
<LayoutContainer>{children}</LayoutContainer>
</Main>
</section>
<Footer/>
</StaticKitProvider>
</ThemeProvider>
</>

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"export": "next export"
},
"dependencies": {
"@statickit/react": "^2.1.1",
"babel-plugin-styled-components": "^1.10.7",
"color": "^3.1.2",
"gray-matter": "^4.0.2",
Expand Down
3 changes: 3 additions & 0 deletions pages/post/[postname].js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ReactMarkdown from 'react-markdown'
import CodeBlock from '@components/CodeBlock'
import { format } from 'timeago.js'
import { designTokens } from '@components/Theme/designTokens'
import ContactForm from '@components/ContactForm'

import Layout from '@components/Layout'
import getSlugs from '@utils/getSlugs'
Expand Down Expand Up @@ -49,6 +50,8 @@ export default function BlogPost({ siteTitle, frontmatter, markdownBody }) {
/>
</div>
</article>
<hr/>
<ContactForm/>
</Layout>
</>
)
Expand Down
35 changes: 34 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,22 @@
resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.4.4.tgz#d94cbb3b354a07f1f5b80e554d6b9e34aba99e41"
integrity sha512-9nKENeWRI6kQk44TbeqleIVtNLfcS3klVUepzl/ZCqzR5Bi06uqBCD277hdVvG/wL1pxA+R/pgJQLqnF5E2wPQ==

"@statickit/core@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@statickit/core/-/core-2.5.1.tgz#3f6004ac87c0042e2b0b353a7bbc062da9b6fac1"
integrity sha512-DaAoeD4V/Kf1jpzqTEZ/NatYg5b3TUgDN/mbvhUguE6aE00ePVGlX1W790rDGc5rQHMkf1rN5iv428Z1gMNe+g==
dependencies:
"@types/promise-polyfill" "^6.0.3"
fetch-ponyfill "^6.1.0"
promise-polyfill "^8.1.3"

"@statickit/react@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@statickit/react/-/react-2.1.1.tgz#3d67a57190a0a6b36a2ceeeec7ff8585ca2a94c5"
integrity sha512-zZGQQAw7D3GHzBb4NHeNOSeM0UmNn6496qq9Fg2RVPOKwvDZoJ6YovOnZVi1x5GJdF8BSUbLrlv1CNihFK3hDw==
dependencies:
"@statickit/core" "^2.5.1"

"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
Expand All @@ -1060,6 +1076,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.5.tgz#dcce4430e64b443ba8945f0290fb564ad5bac6dd"
integrity sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==

"@types/promise-polyfill@^6.0.3":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@types/promise-polyfill/-/promise-polyfill-6.0.3.tgz#e2f38fcd244a9e0df2cc7528e0711abcbc707b5e"
integrity sha512-f/BFgF9a+cgsMseC7rpv9+9TAE3YNjhfYrtwCo/pIeCDDfQtE6PY0b5bao2eIIEpZCBUy8Y5ToXd4ObjPSJuFw==

"@types/q@^1.5.1":
version "1.5.4"
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24"
Expand Down Expand Up @@ -2680,6 +2701,13 @@ fault@^1.0.2:
dependencies:
format "^0.2.0"

fetch-ponyfill@^6.1.0:
version "6.1.1"
resolved "https://registry.yarnpkg.com/fetch-ponyfill/-/fetch-ponyfill-6.1.1.tgz#dd8cdff0741a98bc89aeb85820302beb9bcc0bf4"
integrity sha512-rWLgTr5A44/XhvCQPYj0X9Tc+cjUaHofSM4lcwjc9MavD5lkjIhJ+h8JQlavPlTIgDpwhuRozaIykBvX9ItaSA==
dependencies:
node-fetch "~2.6.0"

figgy-pudding@^3.5.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
Expand Down Expand Up @@ -3909,7 +3937,7 @@ next@^9.4.4:
webpack "4.43.0"
webpack-sources "1.4.3"

[email protected]:
[email protected], node-fetch@~2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
Expand Down Expand Up @@ -4650,6 +4678,11 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

promise-polyfill@^8.1.3:
version "8.1.3"
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.1.3.tgz#8c99b3cf53f3a91c68226ffde7bde81d7f904116"
integrity sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g==

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/prop-types-exact/-/prop-types-exact-1.2.0.tgz#825d6be46094663848237e3925a98c6e944e9869"
Expand Down

0 comments on commit c2534e0

Please sign in to comment.