forked from juliencrn/usehooks-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HeadRoom, BackToTop, edit footer & theme color
- Loading branch information
Showing
13 changed files
with
295 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
"source.fixAll": true | ||
}, | ||
"cSpell.words": [ | ||
"fira", | ||
"frontmatter", | ||
"okaidia", | ||
"prismjs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,54 @@ | ||
# Gatsby's Typescript + Material-ui starter | ||
# Usehooks.ts | ||
|
||
[![Netlify Status](https://api.netlify.com/api/v1/badges/1b625068-4ac6-42d5-87fb-902d9077bbef/deploy-status)](https://app.netlify.com/sites/gatsby-material-typescript-starter/deploys) | ||
This is the repository for [usehooks.ts](https://usehooks.ts), a [Gatsby](https://www.gatsbyjs.org) powered blog that publishes easy to understand React Hook code snippets. | ||
|
||
Kick off your project with this [Material-ui](https://material-ui.com/) boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React. | ||
It includes support for Typescript in front-side and node-side and uses Eslint & Prettier. | ||
UseHooks.ts has been strongly inspired by [usehooks.com](https://usehooks.com), thanks to him. My objective here is to publish my hooks in Typescript in order to find them quickly | ||
|
||
This starter don't have any source or style supports, it's your choice. | ||
If you'd like to submit new post ideas, improve existing posts, or change anything about the website feel free to submit an issue or pull-request. | ||
|
||
_Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._ | ||
To run locally, `yarn`, then `yarn dev`, then open [localhost:8000](https://localhost:8000). | ||
|
||
## 🚀 Quick start | ||
## Summary | ||
|
||
1. **Create a Gatsby site.** | ||
- [useLocalStorage](https://gist.github.com/Junscuzzy/59598636c81071fd8c66af092fb02a09) | ||
|
||
Use the Gatsby CLI to create a new site, specifying the default starter. | ||
### Todo | ||
|
||
```shell | ||
# create a new Gatsby site using the starter | ||
gatsby new gatsby-material-typescript-starter https://github.com/Junscuzzy/gatsby-material-typescript-starter | ||
``` | ||
> TODO: Look in all my projects witch hooks I have used | ||
1. **Start developing.** | ||
- [useScrollPosition](https://github.com/n8tb1t/use-scroll-position) | ||
- useDebounce | ||
- useHover | ||
- useWindowSize | ||
- useOnClickOutside | ||
|
||
Navigate into your new site’s directory and start it up. | ||
|
||
```shell | ||
cd gatsby-material-typescript-starter/ | ||
yarn develop | ||
``` | ||
### Ideas from useHooks.com | ||
|
||
1. **Open the source code and start editing!** | ||
[useMemoCompare](https://usehooks.com/useMemoCompare/)<br/> | ||
[useAsync](https://usehooks.com/useAsync/)<br/> | ||
[useRequireAuth](https://usehooks.com/useRequireAuth/)<br/> | ||
[useRouter](https://usehooks.com/useRouter/)<br/> | ||
[useAuth](https://usehooks.com/useAuth/)<br/> | ||
[useEventListener](https://usehooks.com/useEventListener/)<br/> | ||
[useWhyDidYouUpdate](https://usehooks.com/useWhyDidYouUpdate/)<br/> | ||
[useDarkMode](https://usehooks.com/useDarkMode/)<br/> | ||
[useMedia](https://usehooks.com/useMedia/)<br/> | ||
[useLockBodyScroll](https://usehooks.com/useLockBodyScroll/)<br/> | ||
[useTheme](https://usehooks.com/useTheme/)<br/> | ||
[useSpring](https://usehooks.com/useSpring/)<br/> | ||
[useHistory](https://usehooks.com/useHistory/)<br/> | ||
[useScript](https://usehooks.com/useScript/)<br/> | ||
[useKeyPress](https://usehooks.com/useKeyPress/)<br/> | ||
[useMemo](https://usehooks.com/useMemo/)<br/> | ||
[useDebounce](https://usehooks.com/useDebounce/)<br/> | ||
[useOnScreen](https://usehooks.com/useOnScreen/)<br/> | ||
[usePrevious](https://usehooks.com/usePrevious/)<br/> | ||
[useOnClickOutside](https://usehooks.com/useOnClickOutside/)<br/> | ||
[useAnimation](https://usehooks.com/useAnimation/)<br/> | ||
[useWindowSize](https://usehooks.com/useWindowSize/)<br/> | ||
[useHover](https://usehooks.com/useHover/)<br/> | ||
|
||
Your site is now running at `http://localhost:8000`! | ||
|
||
_Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._ | ||
Open the `gatsby-material-typescript-starter` directory in your code editor of choice and edit `src/pages/index.tsx`. Save your changes and the browser will update in real time! | ||
1. **Bonus**: Check all linters using | ||
```shell | ||
yarn lint | ||
``` | ||
Will execute Prettier, Eslint and Typescript checking | ||
All the commands are in your `package.json > scripts`. | ||
## 🧐 What's inside? | ||
|
||
A quick look at the top-level files and directories you'll see in a Gatsby project. | ||
. | ||
├── .vscode/ | ||
├── node_modules/ | ||
├── src/ | ||
├── static/ | ||
├── .editorconfig | ||
├── .eslintrc | ||
├── .gitignore | ||
├── .prettierrc | ||
├── gatsby-browser.js | ||
├── gatsby-config.js | ||
├── gatsby-node.js | ||
├── gatsby-ssr.js | ||
├── LICENSE | ||
├── package.json | ||
├── README.md | ||
├── tsconfig.json | ||
└── yarn.lock | ||
1. **`/.vscode`**: VSCode projects settings. | ||
1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. | ||
1. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”. | ||
1. **`/static`**: Static files like `robots.txt` or `favicon.ico`. | ||
1. **`.editorconfig`**: EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. | ||
1. **`.eslintrc`**: This is a configuration file for [Eslint](https://eslint.org/). Find and fix problems in your JavaScript code | ||
1. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. | ||
1. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent. | ||
1. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser. | ||
1. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail). | ||
1. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. | ||
1. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering. | ||
1. **`LICENSE`**: Gatsby is licensed under the MIT license. | ||
1. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project. | ||
1. **`README.md`**: A text file containing useful reference information about your project. | ||
1. **`tsconfig.json`**: This is a configuration file for [Typescript](https://www.typescriptlang.org/). TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. | ||
1. **`yarn.lock`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).** | ||
## 🎓 Learning Gatsby | ||
Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start: | ||
- **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. | ||
- **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar. | ||
## 💫 Deploy | ||
As a static generated website, you can deploy it on [Netlify](https://www.netlify.com), [Github Page](https://pages.github.com/) or [ZEIT Now](https://zeit.co/) | ||
<p align="center"> | ||
<a href="./LICENSE"><strong>Unlicense</strong></a> — public domain | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { FC, useState } from 'react' | ||
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles' | ||
import Fab from '@material-ui/core/Fab' | ||
import KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp' | ||
import { useScrollPosition } from '@n8tb1t/use-scroll-position' | ||
import { Link } from 'react-scroll' | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
position: 'fixed', | ||
bottom: theme.spacing(2), | ||
right: theme.spacing(2), | ||
zIndex: 1000, | ||
transition: `opacity 200ms`, | ||
}, | ||
}), | ||
) | ||
|
||
const BackToTop: FC = () => { | ||
const classes = useStyles() | ||
const [isVisible, setVisible] = useState(false) | ||
|
||
useScrollPosition( | ||
({ currPos }) => { | ||
const shouldBeVisible = currPos.y > 500 | ||
if (isVisible !== shouldBeVisible) { | ||
setVisible(shouldBeVisible) | ||
} | ||
}, | ||
undefined, | ||
undefined, | ||
true, | ||
200, | ||
) | ||
|
||
return ( | ||
<Link | ||
to="___gatsby" | ||
smooth | ||
isDynamic | ||
className={classes.root} | ||
style={{ opacity: Number(isVisible) }} | ||
> | ||
<Fab color="primary" size="small" aria-label="scroll back to top"> | ||
<KeyboardArrowUpIcon /> | ||
</Fab> | ||
</Link> | ||
) | ||
} | ||
|
||
export default BackToTop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.