Skip to content

Commit

Permalink
25 move project to nextjs (#27)
Browse files Browse the repository at this point in the history
* Move the whole project to Next

* Fix built files

* Add description to links and fix navbar

* Add aria label and custom loader
  • Loading branch information
alex-dishen authored Jul 11, 2023
1 parent 144536b commit 6811dce
Show file tree
Hide file tree
Showing 21 changed files with 757 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
url: https://alex-dishen.web.app
steps:
- uses: actions/checkout@v3
- run: npm i && npm run build
- run: yarn i && yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/hosting-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy to Firebase Hosting on PR
on: pull_request

jobs:
build_and_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: yarn && yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_ALEX_DISHEN }}'
expires: 3d
projectId: alex-dishen
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
node_modules

# production
/dist
/out

.next
tsconfig.tsbuildinfo
.eslintcache

.next
tsconfig.tsbuildinfo
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- React
- TypeScript
- Next.js
- Styled-Components

## Screenshots
Expand Down Expand Up @@ -47,12 +48,7 @@ $ yarn
4. Run the project.

```sh
$ npm start
$ npm run dev
or
$ yarn start
$ yarn dev
```

## Navigation

- See my previous project [Swipi](https://github.com/midstem/swipi)
- See my next project [Swipi Landing](https://github.com/midstem/swipi-landing)
2 changes: 1 addition & 1 deletion app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const About = () => {
<StyledAbout>
<Header>Meet Oleksandr</Header>
<Image
unoptimized
src="/red-shirt.webp"
alt="Oleksandr in red shirt"
height={350}
width={600}
quality={100}
/>
<Greeting>Greetings and welcome to my personal website!</Greeting>
<AboutMe>
Expand Down
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const metadata: Metadata = {

const RootLayout = ({ children }: { children: ReactNode }) => {
return (
<html>
<html lang="en">
<body>
<StyledComponentsRegistry>
<Navbar />
Expand Down
15 changes: 13 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import Image from 'next/image'
import Image, { ImageLoaderProps } from 'next/image'
import { options } from './constants'
import RightArrow from 'src/assets/icons/arrow-right.svg'
import {
Expand All @@ -18,6 +18,16 @@ import {
StyledLink,
} from './styles'

const imageLoader = ({
src,
width,
quality,
}: {
src: string
width: number
quality?: number
}) => `${src}?w=${width}&q=${quality}`

const Home = () => (
<StyledHome>
<Welcome>
Expand All @@ -29,7 +39,8 @@ const Home = () => (
alt="Oleksandr in black shirt"
width={100}
height={100}
unoptimized
quality={100}
loader={imageLoader}
/>
</ImageHolder>
<Name>Oleksandr</Name>
Expand Down
4 changes: 2 additions & 2 deletions moris.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"useAbsolutePath": "-"
}
"useAbsolutePath": "-"
}
35 changes: 27 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
module.exports = {
const nextConfig = {
trailingSlash: true,
output: 'export',
image: {
loader: 'custom'
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"]
});

return config;
const fileLoaderRule = config.module.rules.find(rule =>
rule.test?.test?.('.svg'),
)
config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: /url/ },
use: ['@svgr/webpack'],
},
)
fileLoaderRule.exclude = /\.svg$/i
return config
},
};
}

export default nextConfig
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "portfolio",
"version": "1.0.0",
"homepage": "http://alex-dishen.github.io/portfolio",
"type": "module",
"scripts": {
"dev": "next dev",
"start": "next start",
"start": "serve out",
"build": "next build",
"lint": "eslint --cache ./src ./app",
"lint:format": "prettier --write --loglevel warn \"./**/*.{js,jsx,ts,tsx,css,md,json}\"",
Expand Down Expand Up @@ -37,6 +38,7 @@
"prettier": "^2.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"serve": "^14.2.0",
"styled-components": "^6.0.3",
"swipi": "^1.1.8",
"typescript": "^4.9.5"
Expand Down
2 changes: 2 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /
21 changes: 16 additions & 5 deletions src/components/Navbar/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Paths } from 'src/constants'
import Bolt from 'src/assets/icons/bolt.svg'
import FBolt from 'src/assets/icons/bolt-filled.svg'
import Pen from 'src/assets/icons/pen.svg'
Expand All @@ -10,24 +11,34 @@ import FMail from 'src/assets/icons/mail-filled.svg'

export const pages = [
{
path: '/',
path: Paths.HOME,
ariaLabel: 'Home',
filledPicture: <FExplore />,
plainPicture: <Explore />,
},
{
path: '/projects',
path: Paths.PROJECTS,
ariaLabel: 'Projects',
filledPicture: <FBolt />,
plainPicture: <Bolt />,
},
{
path: 'https://medium.com/@oleksandrdidyshen',
path: Paths.BLOG,
ariaLabel: 'Blog',
filledPicture: <Pen />,
plainPicture: <Pen />,
},
{
path: '/about',
path: Paths.ABOUT,
ariaLabel: 'About',
filledPicture: <FPerson />,
plainPicture: <Person />,
},
{ path: '/contact', filledPicture: <FMail />, plainPicture: <Mail /> },
{
path: Paths.CONTACT,
ariaLabel: 'Contact information',

filledPicture: <FMail />,
plainPicture: <Mail />,
},
]
9 changes: 5 additions & 4 deletions src/components/Navbar/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Paths } from 'src/constants'
import { glowingColors } from 'src/styles/palette'

export const getGlowingColor = (
location: string,
setGlowingColor: (a: string) => void,
) => {
if (location === '/') return setGlowingColor(glowingColors.blue)
if (location === Paths.HOME) return setGlowingColor(glowingColors.blue)

if (location === '/projects') return setGlowingColor(glowingColors.orange)
if (location === Paths.PROJECTS) return setGlowingColor(glowingColors.orange)

if (location === '/about') return setGlowingColor(glowingColors.red)
if (location === Paths.ABOUT) return setGlowingColor(glowingColors.red)

if (location === '/contact') return setGlowingColor(glowingColors.purple)
if (location === Paths.CONTACT) return setGlowingColor(glowingColors.purple)
}
3 changes: 2 additions & 1 deletion src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ const Navbar = () => {
return (
<>
<StyledNavbar delay={animationDelay} isMobile={isMobile}>
{pages.map(({ path, filledPicture, plainPicture }) => (
{pages.map(({ path, filledPicture, plainPicture, ariaLabel }) => (
<LinkHolder key={path} glowingColor={glowingColor}>
<StyledLink
href={path}
target={path.includes('http') ? '_blank' : ''}
aria-label={ariaLabel}
>
{pathName === path ? filledPicture : plainPicture}
</StyledLink>
Expand Down
3 changes: 0 additions & 3 deletions src/components/Navbar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const StyledLink = styled(Link)`
height: 100%;
width: 100%;
border-radius: 12px;
/* padding: 10px; */
background-color: black;
`

Expand All @@ -55,8 +54,6 @@ export const LinkHolder = styled.div<ImageHolderTypes>(
overflow: hidden;
svg {
/* height: 100%; */
/* width: 100%; */
height: 26px;
width: 26px;
transition: 0.4s;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Navbar/useNavbar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { usePathname } from 'next/navigation'
import { useEffect, useState } from 'react'
import { Paths } from 'src/constants'
import { getGlowingColor } from 'src/components/Navbar/helpers'

const useNavbar = () => {
Expand All @@ -9,7 +10,7 @@ const useNavbar = () => {
const pathName = usePathname()

const getAnimationDelay = () =>
setAnimationDelay(pathName === '/' ? 3.4 : 0.9)
setAnimationDelay(pathName === Paths.HOME ? 3.4 : 0.9)

const getIsMobile = () => setIsMobile(window.innerWidth < 1050 ? true : false)

Expand Down
7 changes: 7 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum Paths {
HOME = '/',
ABOUT = '/about/',
BLOG = 'https://medium.com/@oleksandrdidyshen',
PROJECTS = '/projects/',
CONTACT = '/contact/',
}
2 changes: 1 addition & 1 deletion src/hooks/useInView/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface IVisibleSections {
[key: string]: boolean;
[key: string]: boolean
}
42 changes: 21 additions & 21 deletions src/styles/font.css
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-ExtraLight.ttf') format('truetype');
font-weight: 100;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-ExtraLight.ttf') format('truetype');
font-weight: 100;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Light.ttf') format('truetype');
font-weight: 300;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Light.ttf') format('truetype');
font-weight: 300;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Regular.ttf') format('truetype');
font-weight: normal;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Regular.ttf') format('truetype');
font-weight: normal;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Medium.ttf') format('truetype');
font-weight: 500;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Medium.ttf') format('truetype');
font-weight: 500;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-SemiBold.ttf') format('truetype');
font-weight: 600;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-SemiBold.ttf') format('truetype');
font-weight: 600;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Bold.ttf') format('truetype');
font-weight: bold;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-Bold.ttf') format('truetype');
font-weight: bold;
}

@font-face {
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-ExtraBold.ttf') format('truetype');
font-weight: 900;
font-family: 'Manrope';
src: url('../assets/fonts/Manrope-ExtraBold.ttf') format('truetype');
font-weight: 900;
}
Loading

0 comments on commit 6811dce

Please sign in to comment.