Skip to content

Commit

Permalink
Migrate to Nextjs (HamishMW#31)
Browse files Browse the repository at this point in the history
* Init next

* Storybook?

* Fix storybook

* CSS modulify all the CSS

* Update image component

* Setup build

* Add dynamic imports

* Update articles + fix page transitions

* Update nav scroll

* Update Home.js

* Update Image.module.css

* Add meta component; fix highlighting

* Update Navbar.js

* Update another.mdx
  • Loading branch information
HamishMW committed Apr 15, 2022
1 parent dba0e37 commit 0e79832
Show file tree
Hide file tree
Showing 165 changed files with 7,052 additions and 4,453 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

15 changes: 9 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"extends": "react-app",
"plugins": ["react-hooks"],
"env": {
"es6": true
},
"extends": ["eslint:recommended", "next/core-web-vitals"],
"rules": {
"import/no-anonymous-default-export": 0,
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
"semi": "error"
"semi": "error",
"no-unused-vars": "warn",
"import/no-anonymous-default-export": "off",
"react/display-name": "off",
"@next/next/no-img-element": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ typings/
build/
build-storybook/
.serverless
.next
2 changes: 1 addition & 1 deletion .storybook/StoryContainer.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.story-container {
.storyContainer {
width: 100vw;
height: 100vh;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion .storybook/StoryContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const StoryContainer = ({
children,
}) => (
<div
className="story-container"
className="storyContainer"
style={{
padding,
gap: gutter,
Expand Down
29 changes: 22 additions & 7 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
const path = require('path');

module.exports = {
addons: [
'@storybook/addon-actions',
'@storybook/addon-controls',
'@storybook/addon-a11y',
'@storybook/addon-toolbars',
{
name: '@storybook/preset-create-react-app',
options: {
scriptsPackageName: '@hamishmw/react-scripts-postcss',
},
},
'storybook-addon-next',
],
stories: ['../src/**/*.stories.js'],
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
core: {
builder: 'webpack5',
},
webpackFinal: async (config, { configType }) => {
config.resolve.modules = [path.resolve(__dirname, '../src'), 'node_modules'];

const imageRule = config.module.rules.find(rule => rule.test.test('.svg'));
imageRule.exclude = /\.svg$/;

config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});

config.module.rules.push({
test: /\.(mp4|hdr|glb|woff2)$/i,
type: 'asset/resource',
});

return config;
},
};
2 changes: 1 addition & 1 deletion .storybook/preview.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.story-root {
.storyRoot {
position: absolute;
inset: 0;
}
13 changes: 7 additions & 6 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import '../src/app/reset.css';
import '../src/app/global.css';
import '../src/app/App.css';
import '../src/layouts/App/reset.css';
import '../src/layouts/App/global.css';
import './preview.css';

import { useEffect } from 'react';
import { ThemeProvider } from '../src/components/ThemeProvider';
import { ThemeProvider, fontStyles, tokenStyles } from '../src/components/ThemeProvider';

export const decorators = [
(Story, context) => {
const theme = context.globals.theme;

useEffect(() => {
document.body.setAttribute('class', theme);
document.body.dataset.theme = theme;
}, [theme]);

return (
<ThemeProvider themeId={theme}>
<div id="story-root" className="story-root">
<style>{fontStyles}</style>
<style>{tokenStyles}</style>
<div id="story-root" className="storyRoot">
<Story />
</div>
</ThemeProvider>
Expand Down
23 changes: 14 additions & 9 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"extends": [
"stylelint-config-standard"
"stylelint-config-standard",
"stylelint-config-prettier",
"stylelint-config-css-modules"
],
"rules": {
"selector-class-pattern": null,
"custom-property-pattern": null,
"string-quotes": "single",
"selector-class-pattern": "^[a-z][a-zA-Z0-9]+$",
"custom-property-pattern": "^[a-z][a-zA-Z0-9]+$",
"custom-media-pattern": "^[a-z][a-zA-Z0-9]+$",
"selector-id-pattern": null,
"declaration-block-no-redundant-longhand-properties": null,
"value-keyword-case": null,
"value-keyword-case": ["lower", { "camelCaseSvgKeywords": true }],
"alpha-value-notation": "number",
"declaration-colon-newline-after": null,
"indentation": null,
"selector-combinator-space-before": null,
"value-list-comma-newline-after": null,
"custom-media-pattern": null
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": ["global"]
}
]
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm install
Once it's done start up a local server with:

```bash
npm start
npm run dev
```

To view the components storybook:
Expand Down Expand Up @@ -52,7 +52,7 @@ npm run deploy:api

## Permissions

I'm cool with anyone using the code or parts of the code for their own site, it is open source so people can learn from it and adapt it. However, I would encourage you to modify the theme and components it to make it your own. If you are using the site's design largely unmodified, I'd appreciate being credited as the designer of the website.
I'm cool with anyone using the code or parts of the code for their own site, it is open source so people can learn from it and adapt it. However, I would encourage you to modify the theme and components it to make it your own. If you are using the site's design largely unmodified, I'd appreciate being credited as the designer of the website.

I do not give permission to present any of my projects as your own (this is being actively used as my portfolio site and these are my real projects I've worked on).

Expand Down
18 changes: 18 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
reactStrictMode: false,
trailingSlash: true,
pageExtensions: ['page.js', 'api.js'],
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: [{ loader: '@svgr/webpack', options: { svgo: false } }],
});

config.module.rules.push({
test: /\.(mp4|hdr|glb|woff2)$/i,
type: 'asset/resource',
});

return config;
},
};
Loading

0 comments on commit 0e79832

Please sign in to comment.