Skip to content

Commit 8aee3c8

Browse files
Feat: Design for Footer, Form Update
1 parent b5a62c3 commit 8aee3c8

6 files changed

Lines changed: 261 additions & 53 deletions

File tree

src/components/footer.tsx

Lines changed: 178 additions & 7 deletions
Large diffs are not rendered by default.

src/components/newsletter-form.tsx

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React, { useState } from 'react';
22
import {
3+
Container,
34
Input,
45
Button,
56
Stack,
67
Alert,
8+
HStack,
79
AlertIcon,
810
FormControl,
911
FormLabel,
@@ -36,7 +38,6 @@ const Newsletter = ({}) => {
3638
const [status, setStatus] = useState(null);
3739
const FORM_URL = `https://api.convertkit.com/v3/forms/1917969/subscribe`;
3840
const API = process.env.GATSBY_CONVERTKIT_API_KEY;
39-
console.log(API);
4041
// const formik = useFormik({
4142
// initialValues: {
4243
// name: '',
@@ -87,12 +88,11 @@ const Newsletter = ({}) => {
8788
email: '',
8889
}}
8990
onSubmit={async (values, actions) => {
90-
const data = {
91+
const feed = JSON.stringify({
9192
api_key: API,
9293
email: values.email,
9394
first_name: values.name,
94-
};
95-
const feed = JSON.stringify(data);
95+
});
9696
console.log(feed);
9797
fetch(FORM_URL, {
9898
method: 'POST',
@@ -142,39 +142,52 @@ const Newsletter = ({}) => {
142142
Sorry, API error has occured, please try again later.
143143
</Alert>
144144
)}
145-
<Field name="name" validate={validateName}>
146-
{({ field, form }) => (
147-
<FormControl
148-
isInvalid={form.errors.name && form.touched.name}
149-
isRequired
150-
>
151-
<FormLabel htmlFor="name">First name</FormLabel>
152-
<Input {...field} id="name" placeholder="你的名字" />
153-
<FormErrorMessage>{form.errors.name}</FormErrorMessage>
154-
</FormControl>
155-
)}
156-
</Field>
157-
<Field name="email" validate={validateEmail}>
158-
{({ field, form }) => (
159-
<FormControl
160-
isInvalid={form.errors.email && form.touched.email}
161-
isRequired
162-
>
163-
<FormLabel htmlFor="email">E-mail</FormLabel>
164-
<Input
165-
{...field}
166-
type="email"
167-
id="email"
168-
name="email"
169-
placeholder="你的電郵地址"
170-
/>
171-
<FormErrorMessage>{form.errors.email}</FormErrorMessage>
172-
</FormControl>
173-
)}
174-
</Field>
175-
<Button mt={4} isLoading={props.isSubmitting} type="submit">
176-
Submit
177-
</Button>
145+
<Stack
146+
direction={{ base: 'column', md: 'row' }}
147+
minHeight="80px"
148+
my="4"
149+
>
150+
<Field name="name" validate={validateName}>
151+
{({ field, form }) => (
152+
<FormControl
153+
isInvalid={form.errors.name && form.touched.name}
154+
isRequired
155+
>
156+
{/* <FormLabel htmlFor="name">First name</FormLabel> */}
157+
<Input {...field} id="name" placeholder="Your name" />
158+
<FormErrorMessage>{form.errors.name}</FormErrorMessage>
159+
</FormControl>
160+
)}
161+
</Field>
162+
<Field name="email" validate={validateEmail}>
163+
{({ field, form }) => (
164+
<FormControl
165+
isInvalid={form.errors.email && form.touched.email}
166+
isRequired
167+
>
168+
{/* <FormLabel htmlFor="email">E-mail</FormLabel> */}
169+
<Input
170+
{...field}
171+
type="email"
172+
id="email"
173+
name="email"
174+
placeholder="Your email"
175+
/>
176+
<FormErrorMessage>{form.errors.email}</FormErrorMessage>
177+
</FormControl>
178+
)}
179+
</Field>
180+
<Button
181+
width="300px"
182+
variant="brand"
183+
mt={4}
184+
isLoading={props.isSubmitting}
185+
colorScheme={status === 'SUCCESS' ? 'green' : 'blue'}
186+
type="submit"
187+
>
188+
Submit
189+
</Button>
190+
</Stack>
178191
</Form>
179192
)}
180193
</Formik>

src/components/post-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const PostList = ({ edges }: EdgesType) => (
4747
</Text>
4848
</HStack>
4949
<Link to={edge.node.fields.slug}>
50-
<Heading as="h2" variant="title">
50+
<Heading as="h2" variant="title" mt="0">
5151
{edge.node.frontmatter.title}
5252
</Heading>
5353
</Link>

src/components/sidebar.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
VStack,
1111
SimpleGrid,
1212
useColorMode,
13-
mode,
13+
useColorModeValue,
1414
IconButton,
1515
} from '@chakra-ui/react';
1616
import {
@@ -52,16 +52,31 @@ const Sidebar: React.FC = () => {
5252
/>
5353
</GatsbyLink>
5454
{/* Author */}
55-
<Heading as="h1" fontSize="medium" mt="4">
56-
Samuel W.
57-
</Heading>
55+
<GatsbyLink to="/">
56+
<Heading as="h1" fontSize="medium" mt="4">
57+
Samuel W.
58+
</Heading>
59+
</GatsbyLink>
5860
<Box dangerouslySetInnerHTML={{ __html: config.author.fullbio }} />
5961
</Flex>
6062
<VStack alignItems={{ base: 'flex-end', md: 'flex-start' }} spacing="8">
6163
{/* Menu */}
6264
<VStack spacing="2" alignItems={{ base: 'flex-end', md: 'flex-start' }}>
6365
{config.menu.map((item) => (
64-
<GatsbyLink to={item.path} key={item.label}>
66+
<GatsbyLink
67+
to={item.path}
68+
key={item.label}
69+
borderBottomWidth="1px"
70+
borderBottomColor="transparent"
71+
_hover={{
72+
color: useColorModeValue('primary.500', 'primary.400'),
73+
borderBottomColor: useColorModeValue(
74+
'primary.500',
75+
'primary.400',
76+
),
77+
borderBottomWidth: '1px',
78+
}}
79+
>
6580
{item.label}
6681
</GatsbyLink>
6782
))}

src/components/tag.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Tag = ({ children }) => (
1111
px="3"
1212
py="2"
1313
borderRadius="full"
14+
transition="all 0.1s"
1415
_hover={{ background: 'primary.500', color: 'white' }}
1516
>
1617
<TagLeftIcon width="10px" as={FaHashtag} mr="1" />

theme.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const customTheme = extendTheme({
1515
mono: 'Space Mono, IBM Plex Mono, monospace',
1616
},
1717
colors: {
18+
transparent: 'rgba(0,0,0,0)',
1819
text: {
1920
100: 'lightgray',
2021
400: 'darkgray',
@@ -121,6 +122,10 @@ const customTheme = extendTheme({
121122
outline: (props) => ({
122123
borderColor: 'indigo.200',
123124
}),
125+
brand: (props) => ({
126+
backgroundColor: mode('primary.500', 'primary.400'),
127+
color: 'white',
128+
}),
124129
disabled: (props) => ({
125130
color: 'primary.500',
126131
_hover: {
@@ -138,9 +143,7 @@ const customTheme = extendTheme({
138143
// color: mode('red.900', 'whiteAlpha.100')(props),
139144
}),
140145
},
141-
Link: {
142-
baseStyle: {},
143-
},
146+
Link: {},
144147
VStack: {
145148
baseStyle: {
146149
align: 'flex-start',
@@ -163,6 +166,11 @@ const customTheme = extendTheme({
163166
fontSize: '2xl',
164167
my: '0',
165168
lineHeight: 'tall',
169+
borderBottom: '1px dotted rgba(0,0,0,0)',
170+
transition: 'all 0.1s ease-in-out',
171+
_hover: {
172+
borderBottom: '1px dotted black',
173+
},
166174
},
167175
heading: {
168176
fontSize: '3xl',

0 commit comments

Comments
 (0)