15 | Hi, I'm Katherine! I am a Senior Software Engineer at GitHub with a passion for developing web and mobile
16 | applications that make a positive impact on peoples lives.
17 |
18 |
19 | In addition to coding and learning new tech, I enjoy rock climbing, drinking coffee,
20 | playing guitar, reading, and hanging with my dog. If any of these things interest you too,
21 | I'd love to chat!
22 |
23 |
24 |
25 | )
26 | }
27 |
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/hooks/useLocalStorage.js:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 |
3 | export function useLocalStorage(key, initialValue) {
4 | // State to store our value
5 | // Pass initial state function to useState so logic is only executed once
6 | const [storedValue, setStoredValue] = useState(() => {
7 | try {
8 | // Get from local storage by key
9 | const item = window.localStorage.getItem(key)
10 |
11 | return item ? item : initialValue
12 | } catch (error) {
13 | // If error also return initialValue
14 | console.log(error)
15 | return initialValue
16 | }
17 | })
18 |
19 | // Return a wrapped version of useState's setter function that ...
20 | // ... persists the new value to localStorage.
21 | const setValue = (value) => {
22 | try {
23 | // Allow value to be a function so we have same API as useState
24 | const valueToStore = value instanceof Function ? value(storedValue) : value
25 | // Save state
26 | setStoredValue(valueToStore)
27 | // Save to local storage
28 | window.localStorage.setItem(key, JSON.stringify(valueToStore))
29 | } catch (error) {
30 | // A more advanced implementation would handle the error case
31 | console.log(error)
32 | }
33 | }
34 |
35 | return [storedValue, setValue]
36 | }
37 |
--------------------------------------------------------------------------------
/components/layout.js:
--------------------------------------------------------------------------------
1 | import { AnimatePresence, motion } from 'framer-motion'
2 | import { faDev, faGithub, faLinkedinIn, faTwitter } from '@fortawesome/free-brands-svg-icons'
3 |
4 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
5 | import Head from 'next/head'
6 | import Link from 'next/link'
7 | import dynamic from 'next/dynamic'
8 | import { faPencilAlt } from '@fortawesome/free-solid-svg-icons'
9 | import { useEffect } from 'react'
10 | import { useLocalStorage } from '../hooks/useLocalStorage'
11 |
12 | const DarkModeToggle = dynamic(() => import('dark-mode-toggle-animation'), { ssr: false })
13 |
14 | export default function Layout({ children }) {
15 | const [theme, setTheme] = useLocalStorage('theme', 'light')
16 |
17 | useEffect(() => {
18 | if (
19 | localStorage.theme === 'dark' ||
20 | (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
21 | ) {
22 | document.getElementsByTagName('html')[0].classList.add('dark')
23 | } else {
24 | document.getElementsByTagName('html')[0].classList.remove('dark')
25 | }
26 | }, [])
27 |
28 | useEffect(() => {
29 | if (theme == 'dark') {
30 | document.getElementsByTagName('html')[0].classList.add('dark')
31 | localStorage.theme = 'dark'
32 | } else {
33 | document.getElementsByTagName('html')[0].classList.remove('dark')
34 | localStorage.theme = 'light'
35 | }
36 | }, [theme])
37 |
38 | const toggleDarkMode = () => {
39 | if (theme == 'dark') {
40 | setTheme('light')
41 | } else {
42 | setTheme('dark')
43 | }
44 | }
45 |
46 | return (
47 |