Skip to content

Commit

Permalink
rewrite website
Browse files Browse the repository at this point in the history
- improve best practices
- use the latest version of next.js and tailwindcss
- remove unused ressources
- update structure
- include next.js Conformance
- improve linting rules
- update packages
- remove duplicated nav items
  • Loading branch information
enochndika committed Jun 24, 2021
1 parent fceb5b1 commit 48e0e11
Show file tree
Hide file tree
Showing 76 changed files with 1,975 additions and 2,297 deletions.
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": [
"plugin:prettier/recommended", // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"next" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
"plugins": ["unused-imports"],
"rules": {
"prettier/prettier": [
"warn",
{
"singleQuote": true
}
],
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-var-requires": "off",
"unused-imports/no-unused-imports-ts": 2,
"react/react-in-jsx-scope": "off",
"react/no-unescaped-entities": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"react/prop-types": [2, { "ignore": ["children"] }],
"react/display-name": "off"
}
}
38 changes: 0 additions & 38 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
3 changes: 0 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ module.exports = withMDX({
images: {
domains: ['res.cloudinary.com'],
},
future: {
webpack5: true,
},
async redirects() {
return [
{
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build",
"start": "next start",
"postbuild": "next-sitemap",
"lint": "next lint",
"prepare": "husky install"
},
"lint-staged": {
Expand All @@ -26,33 +27,32 @@
"@reach/portal": "^0.13.0",
"formik": "^2.2.6",
"mdx-utils": "^0.2.0",
"next": "^10.2.0",
"react": "17.0.1",
"next": "^11.0.1",
"react": "^17.0.2",
"react-content-loader": "^6.0.1",
"react-dom": "17.0.1",
"react-div-100vh": "^0.6.0",
"react-dom": "^17.0.2",
"react-dom-confetti": "^0.2.0",
"react-hook-form": "^7.6.4",
"react-live": "^2.2.3",
"yup": "^0.32.9"
},
"devDependencies": {
"@types/node": "^14.14.28",
"@types/react": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"autoprefixer": "^10.2.4",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"@types/node": "^15.12.4",
"@types/react": "^17.0.11",
"@typescript-eslint/parser": "^4.28.0",
"autoprefixer": "^10.2.6",
"eslint": "^7.29.0",
"eslint-config-next": "^11.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-unused-imports": "^1.1.1",
"husky": "^5.1.3",
"lint-staged": "^10.5.4",
"next-sitemap": "^1.5.6",
"postcss": "^8.2.6",
"prettier": "^2.2.1",
"tailwindcss": "^2.0.3",
"typescript": "^4.1.5"
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"next-sitemap": "^1.6.124",
"postcss": "^8.3.5",
"prettier": "^2.3.1",
"tailwindcss": "^2.2.4",
"typescript": "^4.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Autocomplete = ({
setShowSuggestions(true);
setValue(e.currentTarget.value);
},
[value],
[setValue, suggestions],
);

const onClick = (e) => {
Expand Down
13 changes: 6 additions & 7 deletions packages/code/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

interface CodeProps {
variant: 'black' | 'default' | 'indigo' | 'blue-outline';
Expand All @@ -15,20 +15,19 @@ const classes = {

const Code = ({ children, variant, acceptCopy }: CodeProps) => {
const [copied, setCopied] = useState(false);
let resetCopy;
const resetCopy = useRef<any>();

const onCopyCode = async () => {
await navigator.clipboard.writeText(children);
setCopied(true);
const onCopyCode = () => {
navigator.clipboard.writeText(children).then(() => setCopied(true));
};

useEffect(() => {
if (copied) {
resetCopy = setTimeout(() => setCopied(false), 2500);
resetCopy.current = setTimeout(() => setCopied(false), 2500);
}

return () => {
clearTimeout(resetCopy);
clearTimeout(resetCopy.current);
};
}, [copied]);
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/code/snippets/blueOutline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';

export const CodePage = () => (
<div className="m-8">
<Code>yarn add swr react-table</Code>
<Code>yarn add swr react-documentationTable</Code>
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/examples/bottom.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';
import Drawer from '../index';

const DrawerBottom: FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/examples/left.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';
import Drawer from '../index';

const DrawerLeft: FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/examples/right.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';
import Drawer from '../index';

const DrawerRight: FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/examples/simple.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';
import Drawer from '../index';

const DrawerSimple: FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/drawer/examples/top.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';
import Drawer from '../index';

const DrawerTop: FC = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Drawer = ({
};
window.addEventListener('click', handleOutsideClick);
return () => window.removeEventListener('click', handleOutsideClick);
}, [isOpen, ref]);
}, [isOpen, ref, toggle]);

// close modal when you click on "ESC" key
useEffect(() => {
Expand All @@ -64,7 +64,7 @@ const Drawer = ({
};
document.addEventListener('keyup', handleEscape);
return () => document.removeEventListener('keyup', handleEscape);
}, [isOpen]);
}, [isOpen, toggle]);

// hide scrollbar and prevent body from moving when modal is open
useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/hamburger-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ HamburgerMenu.Toggler = ({ toggle }: HamburgerTogglerProps) => (
);

HamburgerMenu.Collapse = ({ children, isOpen }: HamburgerCollapseProps) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const ref = useRef<HTMLDivElement>(null);
const inlineStyles: CSSProperties = isOpen
? { height: ref.current?.scrollHeight }
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/examples/animation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modal from '../index';
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';

const ModalAnimation: FC = () => {
const { toggle, isOpen } = useDisclosure();
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/examples/default.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modal from '../index';
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';

const ModalDefault: FC = () => {
const { toggle, isOpen } = useDisclosure();
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/examples/extraLarge.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modal from '../index';
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';

const ModalExtraLarge: FC = () => {
const { toggle, isOpen } = useDisclosure();
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/examples/large.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modal from '../index';
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';

const ModalLarge: FC = () => {
const { toggle, isOpen } = useDisclosure();
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/examples/notClosedOutside.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Modal from '../index';
import { FC } from 'react';
import Button from '@/packages/button';
import useDisclosure from '@/website/utils/useDisclosure';
import useDisclosure from '@/website/hooks/useDisclosure';

const ModalNotClosedOutside: FC = () => {
const { toggle, isOpen } = useDisclosure();
Expand Down
4 changes: 2 additions & 2 deletions packages/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Modal = ({
};
window.addEventListener('click', handleOutsideClick);
return () => window.removeEventListener('click', handleOutsideClick);
}, [isOpen, ref]);
}, [closeOnClickOutside, isOpen, ref, toggle]);

// close modal when you click on "ESC" key
useEffect(() => {
Expand All @@ -65,7 +65,7 @@ const Modal = ({
};
document.addEventListener('keyup', handleEscape);
return () => document.removeEventListener('keyup', handleEscape);
}, [isOpen]);
}, [isOpen, toggle]);

// Put focus on modal dialogue, hide scrollbar and prevent body from moving when modal is open
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sidenav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Sidenav = ({
};
window.addEventListener('mousedown', handleOutsideClick);
return () => window.removeEventListener('mousedown', handleOutsideClick);
}, [isOpen, ref]);
}, [closeOnClickOutside, isOpen, ref, toggle]);

return (
<aside
Expand Down
Loading

1 comment on commit 48e0e11

@vercel
Copy link

@vercel vercel bot commented on 48e0e11 Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.