refactor(starter): upgrade to new version of gatsby

This commit is contained in:
Alexander Shelepenok
2022-01-09 20:12:31 +00:00
parent 84bdc5899d
commit 67ebabbaac
397 changed files with 26665 additions and 34984 deletions

View File

@@ -1,31 +0,0 @@
// @flow strict
import React from 'react';
import { Link } from 'gatsby';
import styles from './Menu.module.scss';
type Props = {
menu: {
label: string,
path: string
}[]
};
const Menu = ({ menu }: Props) => (
<nav className={styles['menu']}>
<ul className={styles['menu__list']}>
{menu.map((item) => (
<li className={styles['menu__list-item']} key={item.path}>
<Link
to={item.path}
className={styles['menu__list-item-link']}
activeClassName={styles['menu__list-item-link--active']}
>
{item.label}
</Link>
</li>
))}
</ul>
</nav>
);
export default Menu;

View File

@@ -1,39 +1,35 @@
@import '../../../assets/scss/variables';
@import '../../../assets/scss/mixins';
@import "../../../assets/scss/variables";
@import "../../../assets/scss/mixins";
.menu {
@include margin-bottom(1);
&__list {
list-style: none;
padding: 0;
margin: 0;
padding: 0;
&-item {
padding: 0;
margin: 10px 0;
padding: 0;
&-link {
font-size: $typographic-base-font-size;
color: $typographic-base-font-color;
font-weight: normal;
border: 0;
color: $typographic-base-font-color;
font-size: $typographic-base-font-size;
font-weight: normal;
&:hover,
&:focus {
color: $color-primary;
border-bottom: 1px solid $color-primary;
color: $color-primary;
}
&--active {
color: $color-base;
border-bottom: 1px solid $color-base;
color: $color-base;
}
}
}
}
}
}

View File

@@ -1,24 +0,0 @@
// @flow strict
import React from 'react';
import renderer from 'react-test-renderer';
import Menu from './Menu';
describe('Menu', () => {
const props = {
menu: [
{
label: 'Item 0',
path: '/#0/'
},
{
label: 'Item 1',
path: '/#1/'
}
]
};
it('renders correctly', () => {
const tree = renderer.create(<Menu {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,16 @@
import React from "react";
import renderer from "react-test-renderer";
import { Menu } from "@/components/Sidebar/Menu";
import * as mocks from "@/mocks";
describe("Menu", () => {
const props = {
menu: mocks.menu,
};
it("renders correctly", () => {
const tree = renderer.create(<Menu {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,32 @@
import React from "react";
import { Link } from "gatsby";
import styles from "./Menu.module.scss";
type Props = {
menu: {
label: string;
path: string;
}[];
};
const Menu: React.FC<Props> = ({ menu }: Props) => (
<nav className={styles.menu}>
<ul className={styles.menu__list}>
{menu.map(item => (
<li className={styles["menu__list-item"]} key={item.path}>
<Link
to={item.path}
className={styles["menu__list-item-link"]}
activeClassName={styles["menu__list-item-link--active"]}
>
{item.label}
</Link>
</li>
))}
</ul>
</nav>
);
export default Menu;

View File

@@ -12,9 +12,9 @@ exports[`Menu renders correctly 1`] = `
>
<a
className="menu__list-item-link"
href="/#0/"
href="/"
>
Item 0
Articles
</a>
</li>
<li
@@ -22,9 +22,19 @@ exports[`Menu renders correctly 1`] = `
>
<a
className="menu__list-item-link"
href="/#1/"
href="/pages/about"
>
Item 1
About Me
</a>
</li>
<li
className="menu__list-item"
>
<a
className="menu__list-item-link"
href="/pages/contacts"
>
Contact Me
</a>
</li>
</ul>

View File

@@ -1,2 +0,0 @@
// @flow strict
export { default } from './Menu';

View File

@@ -0,0 +1 @@
export { default as Menu } from "./Menu";