-
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.
Merge branch 'release/1.0.0' into main
- Loading branch information
Showing
66 changed files
with
1,336 additions
and
264 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 |
---|---|---|
@@ -1,41 +1,10 @@ | ||
# TypeScript Next.js example | ||
## [viktoriaweizel.com](https://viktoriaweizel.com) | ||
|
||
This is a really simple project that shows the usage of Next.js with TypeScript. | ||
> 🛠️ WORK IN PROGRESS | ||
## Deploy your own | ||
This website consists of a blog and multiple image galleries to showcase the work and adventures of Viktoria Weizel. | ||
|
||
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example): | ||
|
||
[](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-typescript&project-name=with-typescript&repository-name=with-typescript) | ||
|
||
## How to use it? | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: | ||
|
||
```bash | ||
npx create-next-app --example with-typescript with-typescript-app | ||
# or | ||
yarn create next-app --example with-typescript with-typescript-app | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). | ||
|
||
## Notes | ||
|
||
This example shows how to integrate the TypeScript type system into Next.js. Since TypeScript is supported out of the box with Next.js, all we have to do is to install TypeScript. | ||
|
||
``` | ||
npm install --save-dev typescript | ||
``` | ||
|
||
To enable TypeScript's features, we install the type declarations for React and Node. | ||
|
||
``` | ||
npm install --save-dev @types/react @types/react-dom @types/node | ||
``` | ||
|
||
When we run `next dev` the next time, Next.js will start looking for any `.ts` or `.tsx` files in our project and builds it. It even automatically creates a `tsconfig.json` file for our project with the recommended settings. | ||
|
||
Next.js has built-in TypeScript declarations, so we'll get autocompletion for Next.js' modules straight away. | ||
|
||
A `type-check` script is also added to `package.json`, which runs TypeScript's `tsc` CLI in `noEmit` mode to run type-checking separately. You can then include this, for example, in your `test` scripts. | ||
#### Stack | ||
* Next.js with Typescript (Incremental Static Site Generation) | ||
* GraphQL | ||
* Headless CMS Directus v9 |
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,19 @@ | ||
import React from "react"; | ||
import { FunctionComponent } from "react"; | ||
|
||
const ArrowRightSmall: FunctionComponent = () => ( | ||
<svg | ||
width="26" | ||
height="16" | ||
viewBox="0 0 26 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M25.7071 8.70711C26.0976 8.31658 26.0976 7.68342 25.7071 7.29289L19.3431 0.928932C18.9526 0.538408 18.3195 0.538408 17.9289 0.928932C17.5384 1.31946 17.5384 1.95262 17.9289 2.34315L23.5858 8L17.9289 13.6569C17.5384 14.0474 17.5384 14.6805 17.9289 15.0711C18.3195 15.4616 18.9526 15.4616 19.3431 15.0711L25.7071 8.70711ZM0 9L25 9V7L0 7L0 9Z" | ||
fill="white" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default ArrowRightSmall; |
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,28 @@ | ||
import Link from "next/link"; | ||
import React, { FunctionComponent } from "react"; | ||
|
||
const Hero: FunctionComponent<{}> = () => { | ||
return ( | ||
<div className="hero"> | ||
<div className="container"> | ||
<div className="row"> | ||
<div className="col-lg-8 col-12"> | ||
<h1 className="hero__title">Hi, I'm Viktoria</h1> | ||
<h3 className="hero__subtitle"> | ||
Passionate traveler <br /> & photographer. | ||
</h3> | ||
</div> | ||
</div> | ||
<div className="row"> | ||
<div className="col-12"> | ||
<Link href="/gallery"> | ||
<a className="button--white">Gallery</a> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Hero; |
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,25 @@ | ||
import Link from "next/link"; | ||
import React, { FunctionComponent } from "react"; | ||
|
||
interface ILinkWithIconProps { | ||
title: string; | ||
href: string; | ||
children: React.ReactElement | React.ReactElement[]; | ||
} | ||
|
||
const LinkWithIcon: FunctionComponent<ILinkWithIconProps> = ({ | ||
title, | ||
href, | ||
children, | ||
}): React.ReactElement => { | ||
return ( | ||
<Link href={href}> | ||
<a className="link link--icon"> | ||
<span className="link__title">{title}</span> | ||
{children} | ||
</a> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default LinkWithIcon; |
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,33 @@ | ||
import React, { createContext, useState, useEffect, useContext } from "react"; | ||
import ETheme from "../enums/theme.enum"; | ||
|
||
interface IThemeProvider { | ||
theme: ETheme; | ||
setTheme: (theme: ETheme) => void; | ||
} | ||
|
||
export const ThemeProvider = ({ children }) => { | ||
const [theme, setTheme] = useState(ETheme.DARK); | ||
|
||
useEffect(() => { | ||
const bodyClassList = document.body.classList; | ||
if (theme === ETheme.LIGHT) { | ||
bodyClassList.remove("dark-theme"); | ||
bodyClassList.add("light-theme"); | ||
return; | ||
} | ||
|
||
bodyClassList.remove("light-theme"); | ||
bodyClassList.add("dark-theme"); | ||
}, [theme]); | ||
|
||
return ( | ||
<ThemeContext.Provider value={{ theme, setTheme }}> | ||
{children} | ||
</ThemeContext.Provider> | ||
); | ||
}; | ||
|
||
export const ThemeContext = createContext<Partial<IThemeProvider>>({}); | ||
export const useTheme = (): IThemeProvider => | ||
useContext(ThemeContext) as IThemeProvider; |
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,30 @@ | ||
import React from "react"; | ||
import { FaMoon } from "react-icons/fa"; | ||
import { FaSun } from "react-icons/fa"; | ||
import ETheme from "../enums/theme.enum"; | ||
import { useTheme } from "./ThemeProvider"; | ||
|
||
const ThemeToggler = ({ onToggle }) => { | ||
const { theme } = useTheme(); | ||
return ( | ||
<> | ||
<input | ||
type="checkbox" | ||
onChange={onToggle} | ||
name="chooseTheme" | ||
id="chooseTheme" | ||
className="d-none" | ||
checked={theme === ETheme.DARK} | ||
/> | ||
<label htmlFor="chooseTheme"> | ||
{theme === ETheme.LIGHT ? ( | ||
<FaMoon /> | ||
) : ( | ||
<FaSun style={{ color: "var(--white)" }} /> | ||
)} | ||
</label> | ||
</> | ||
); | ||
}; | ||
|
||
export default ThemeToggler; |
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.
a183d25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: