From f1399242f44a8c2d3a51dc00fc7d527b58715709 Mon Sep 17 00:00:00 2001 From: Roy Schut Date: Wed, 9 Jun 2021 14:33:58 +0200 Subject: [PATCH] feat(project): replace buttonlink with variant text buttons --- src/components/Button/Button.module.scss | 17 ++++-- src/components/Button/Button.tsx | 39 ++++++++------ .../Button/__snapshots__/Button.test.tsx.snap | 2 +- .../ButtonLink/ButtonLink.module.scss | 53 ------------------- src/components/ButtonLink/ButtonLink.test.tsx | 18 ------- src/components/ButtonLink/ButtonLink.tsx | 19 ------- .../__snapshots__/ButtonLink.test.tsx.snap | 15 ------ .../Filter/__snapshots__/Filter.test.tsx.snap | 8 +-- src/components/Header/Header.module.scss | 4 -- src/components/Header/Header.test.tsx | 6 +-- .../Header/__snapshots__/Header.test.tsx.snap | 12 ++++- src/components/Layout/Layout.tsx | 8 +-- .../Layout/__snapshots__/Layout.test.tsx.snap | 4 +- .../Root/__snapshots__/Root.test.tsx.snap | 4 +- src/components/Sidebar/Sidebar.test.tsx | 10 ++-- .../__snapshots__/SideBar.test.tsx.snap | 12 ++++- .../Video/__snapshots__/Video.test.tsx.snap | 8 +-- 17 files changed, 86 insertions(+), 153 deletions(-) delete mode 100644 src/components/ButtonLink/ButtonLink.module.scss delete mode 100644 src/components/ButtonLink/ButtonLink.test.tsx delete mode 100644 src/components/ButtonLink/ButtonLink.tsx delete mode 100644 src/components/ButtonLink/__snapshots__/ButtonLink.test.tsx.snap diff --git a/src/components/Button/Button.module.scss b/src/components/Button/Button.module.scss index 0d5c1e947..c9551ac92 100644 --- a/src/components/Button/Button.module.scss +++ b/src/components/Button/Button.module.scss @@ -35,21 +35,30 @@ } &.primary, - &.active { + &.active:not(.text) { color: var(--highlight-contrast-color, white); background-color: var(--highlight-color, black); &.outlined { border-color: var(--highlight-color, white); } } - &.text:not(:hover):not(.active) { - background: none; + &.text { + font-size: 18px; + font-weight: 700; opacity: 0.7; + &:not(:hover) { + background: none; + } + &.active { + opacity: 1; + } } @media (hover: hover) and (pointer: fine) { &:hover:not(.active), &:focus:not(.active), + &:hover:is(.text), + &:focus:is(.text), &:active { z-index: 1; opacity: 1; @@ -61,7 +70,7 @@ border-color: white; } } - &:focus.active { + &:hover &:focus.active { transform: scale(1.1); &.fullWidth { transform: scale(1.04); diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 6c1b9d51b..3d0d7107d 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -1,5 +1,6 @@ import React from 'react'; import classNames from 'classnames'; +import { NavLink } from 'react-router-dom'; import styles from './Button.module.scss'; @@ -14,7 +15,8 @@ type Props = { fullWidth?: boolean; startIcon?: JSX.Element; variant?: Variant; - onClick: () => void; + onClick?: () => void; + to?: string; }; const Button: React.FC = ({ label, @@ -23,20 +25,27 @@ const Button: React.FC = ({ fullWidth = false, active = false, variant = 'outlined', + to, onClick, -}: Props) => ( - -); +}: Props) => { + const className = classNames(styles.button, [styles[color]], [styles[variant]], { + [styles.active]: active, + [styles.fullWidth]: fullWidth, + }); + const icon = startIcon ?
{startIcon}
: null; + const span = {label}; + + return to ? ( + + {icon} + {span} + + ) : ( + + ); +}; export default Button; diff --git a/src/components/Button/__snapshots__/Button.test.tsx.snap b/src/components/Button/__snapshots__/Button.test.tsx.snap index 5faf373f0..c2a6944e5 100644 --- a/src/components/Button/__snapshots__/Button.test.tsx.snap +++ b/src/components/Button/__snapshots__/Button.test.tsx.snap @@ -3,7 +3,7 @@ exports[`