mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-11 10:46:16 +02:00
refactor(starter): upgrade and move to typescript
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
.contacts {
|
||||
@include margin-bottom(1);
|
||||
|
||||
&__list {
|
||||
.list {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
list-style: none;
|
||||
margin: 10px -3px;
|
||||
padding: 0;
|
||||
width: 140px;
|
||||
max-width: 150px;
|
||||
@include padding-equal(0);
|
||||
@include margin(0.5, 0);
|
||||
|
||||
&-item {
|
||||
.item {
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
border: 1px solid $color-gray-bg;
|
||||
@@ -23,12 +23,16 @@
|
||||
height: $button-height;
|
||||
justify-content: center;
|
||||
line-height: $button-height;
|
||||
margin: 4px;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
width: $button-height;
|
||||
@include padding-equal(0);
|
||||
@include margin-equal(0.25);
|
||||
|
||||
&-link {
|
||||
&:nth-child(3n + 1) {
|
||||
@include margin-left(0);
|
||||
}
|
||||
|
||||
.link {
|
||||
border: 0;
|
||||
color: $color-base;
|
||||
display: flex;
|
||||
|
@@ -5,9 +5,8 @@ import { Contacts } from "@/components/Sidebar/Contacts";
|
||||
import * as mocks from "@/mocks";
|
||||
|
||||
describe("Contacts", () => {
|
||||
const props = { contacts: mocks.contacts };
|
||||
|
||||
it("renders correctly", () => {
|
||||
const props = { contacts: mocks.contacts };
|
||||
const tree = renderer.create(<Contacts {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import React from "react";
|
||||
|
||||
import { Icon } from "@/components/Icon";
|
||||
import { ICONS } from "@/constants";
|
||||
import { Dictionary } from "@/types";
|
||||
import { getContactHref, getIcon } from "@/utils";
|
||||
|
||||
import styles from "./Contacts.module.scss";
|
||||
import * as styles from "./Contacts.module.scss";
|
||||
|
||||
type Props = {
|
||||
contacts: Dictionary<string>;
|
||||
@@ -12,19 +13,21 @@ type Props = {
|
||||
|
||||
const Contacts: React.FC<Props> = ({ contacts }: Props) => (
|
||||
<div className={styles.contacts}>
|
||||
<ul className={styles.contacts__list}>
|
||||
{Object.keys(contacts).map(name => (
|
||||
<li className={styles["contacts__list-item"]} key={name}>
|
||||
<a
|
||||
className={styles["contacts__list-item-link"]}
|
||||
href={getContactHref(name, contacts[name])}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<Icon name={name} icon={getIcon(name)} />
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
<ul className={styles.list}>
|
||||
{(Object.keys(contacts) as Array<keyof typeof ICONS>).map(name =>
|
||||
contacts[name] ? (
|
||||
<li className={styles.item} key={name}>
|
||||
<a
|
||||
className={styles.link}
|
||||
href={getContactHref(name, contacts[name])}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<Icon name={name} icon={getIcon(name)} />
|
||||
</a>
|
||||
</li>
|
||||
) : null,
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
@@ -1,23 +1,15 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Contacts renders correctly 1`] = `
|
||||
<div
|
||||
className="contacts"
|
||||
>
|
||||
<ul
|
||||
className="contacts__list"
|
||||
>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<div>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 22 28"
|
||||
>
|
||||
<title>
|
||||
@@ -29,17 +21,13 @@ exports[`Contacts renders correctly 1`] = `
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<li>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="mailto:#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 28 28"
|
||||
>
|
||||
<title>
|
||||
@@ -51,17 +39,13 @@ exports[`Contacts renders correctly 1`] = `
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<li>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="https://github.com/#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 26 28"
|
||||
>
|
||||
<title>
|
||||
@@ -73,17 +57,13 @@ exports[`Contacts renders correctly 1`] = `
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<li>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="https://www.twitter.com/#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 26 28"
|
||||
>
|
||||
<title>
|
||||
@@ -95,17 +75,13 @@ exports[`Contacts renders correctly 1`] = `
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<li>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="https://t.me/#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 28 28"
|
||||
>
|
||||
<title>
|
||||
@@ -117,28 +93,6 @@ exports[`Contacts renders correctly 1`] = `
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
className="contacts__list-item"
|
||||
>
|
||||
<a
|
||||
className="contacts__list-item-link"
|
||||
href="https://vk.com/#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<svg
|
||||
className="icon"
|
||||
viewBox="0 0 31 28"
|
||||
>
|
||||
<title>
|
||||
vkontakte
|
||||
</title>
|
||||
<path
|
||||
d="M29.953 8.125c0.234 0.641-0.5 2.141-2.344 4.594-3.031 4.031-3.359 3.656-0.859 5.984 2.406 2.234 2.906 3.313 2.984 3.453 0 0 1 1.75-1.109 1.766l-4 0.063c-0.859 0.172-2-0.609-2-0.609-1.5-1.031-2.906-3.703-4-3.359 0 0-1.125 0.359-1.094 2.766 0.016 0.516-0.234 0.797-0.234 0.797s-0.281 0.297-0.828 0.344h-1.797c-3.953 0.25-7.438-3.391-7.438-3.391s-3.813-3.938-7.156-11.797c-0.219-0.516 0.016-0.766 0.016-0.766s0.234-0.297 0.891-0.297l4.281-0.031c0.406 0.063 0.688 0.281 0.688 0.281s0.25 0.172 0.375 0.5c0.703 1.75 1.609 3.344 1.609 3.344 1.563 3.219 2.625 3.766 3.234 3.437 0 0 0.797-0.484 0.625-4.375-0.063-1.406-0.453-2.047-0.453-2.047-0.359-0.484-1.031-0.625-1.328-0.672-0.234-0.031 0.156-0.594 0.672-0.844 0.766-0.375 2.125-0.391 3.734-0.375 1.266 0.016 1.625 0.094 2.109 0.203 1.484 0.359 0.984 1.734 0.984 5.047 0 1.062-0.203 2.547 0.562 3.031 0.328 0.219 1.141 0.031 3.141-3.375 0 0 0.938-1.625 1.672-3.516 0.125-0.344 0.391-0.484 0.391-0.484s0.25-0.141 0.594-0.094l4.5-0.031c1.359-0.172 1.578 0.453 1.578 0.453z"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
Reference in New Issue
Block a user