aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Buttons
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-29 17:01:42 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-29 17:50:45 +0100
commit76c01d51ccbdd0faaf12b624328a40ef24f33f88 (patch)
tree3cad2a35955e7e90806cc5180554e33f5cde43f1 /src/components/Buttons
parent395571bd89498fce46d37f3853cf718387fd0d9a (diff)
chore: add a button-like component for links
Diffstat (limited to 'src/components/Buttons')
-rw-r--r--src/components/Buttons/ButtonLink/ButtonLink.tsx30
-rw-r--r--src/components/Buttons/Buttons.module.scss54
-rw-r--r--src/components/Buttons/index.tsx3
3 files changed, 86 insertions, 1 deletions
diff --git a/src/components/Buttons/ButtonLink/ButtonLink.tsx b/src/components/Buttons/ButtonLink/ButtonLink.tsx
new file mode 100644
index 0000000..70039a8
--- /dev/null
+++ b/src/components/Buttons/ButtonLink/ButtonLink.tsx
@@ -0,0 +1,30 @@
+import { ButtonPosition } from '@ts/types/app';
+import Link from 'next/link';
+import { ReactNode } from 'react';
+import styles from '../Buttons.module.scss';
+
+const ButtonLink = ({
+ children,
+ target,
+ position = 'left',
+ isExternal = false,
+}: {
+ children: ReactNode;
+ target: string;
+ position?: ButtonPosition;
+ isExternal?: boolean;
+}) => {
+ const classes = `${styles.btn} ${styles.link} ${styles[`link--${position}`]}`;
+
+ return isExternal ? (
+ <a className={classes} href={target}>
+ {children}
+ </a>
+ ) : (
+ <Link href={target}>
+ <a className={classes}>{children}</a>
+ </Link>
+ );
+};
+
+export default ButtonLink;
diff --git a/src/components/Buttons/Buttons.module.scss b/src/components/Buttons/Buttons.module.scss
index 9f046d2..e05bd1d 100644
--- a/src/components/Buttons/Buttons.module.scss
+++ b/src/components/Buttons/Buttons.module.scss
@@ -80,6 +80,60 @@
}
}
+.link {
+ width: max-content;
+ padding: var(--spacing-2xs) var(--spacing-sm);
+ background: var(--color-bg);
+ border: fun.convert-px(3) solid var(--color-primary);
+ border-radius: fun.convert-px(5);
+ box-shadow: fun.convert-px(1) fun.convert-px(1) fun.convert-px(1)
+ var(--color-shadow-light),
+ fun.convert-px(1) fun.convert-px(2) fun.convert-px(2) fun.convert-px(-2)
+ var(--color-shadow-light),
+ fun.convert-px(3) fun.convert-px(4) fun.convert-px(5) fun.convert-px(-4)
+ var(--color-shadow-light);
+ color: var(--color-primary);
+ font-weight: 600;
+ text-decoration: none;
+ transition: all 0.3s ease-in-out 0s;
+
+ &--left {
+ margin-right: auto;
+ }
+
+ &--right {
+ margin-left: auto;
+ }
+
+ &--center {
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ &:hover,
+ &:focus {
+ box-shadow: fun.convert-px(1) fun.convert-px(1) fun.convert-px(1)
+ var(--color-shadow-lighter),
+ fun.convert-px(1) fun.convert-px(2) fun.convert-px(2) fun.convert-px(-2)
+ var(--color-shadow-lighter),
+ fun.convert-px(3) fun.convert-px(4) fun.convert-px(5) fun.convert-px(-4)
+ var(--color-shadow-lighter),
+ fun.convert-px(7) fun.convert-px(10) fun.convert-px(12) fun.convert-px(-3)
+ var(--color-shadow-lighter);
+ transform: scale(1.08);
+ }
+
+ &:focus {
+ text-decoration: underline var(--color-primary) fun.convert-px(3);
+ }
+
+ &:active {
+ box-shadow: 0 0 0 0 var(--color-shadow-light);
+ text-decoration: none;
+ transform: scale(0.94);
+ }
+}
+
.search,
.theme {
display: block;
diff --git a/src/components/Buttons/index.tsx b/src/components/Buttons/index.tsx
index 53d4e91..74060f7 100644
--- a/src/components/Buttons/index.tsx
+++ b/src/components/Buttons/index.tsx
@@ -1,6 +1,7 @@
import Button from './Button/Button';
+import ButtonLink from './ButtonLink/ButtonLink';
import ButtonSearch from './ButtonSearch/ButtonSearch';
import ButtonSubmit from './ButtonSubmit/ButtonSubmit';
import ButtonTheme from './ButtonTheme/ButtonTheme';
-export { Button, ButtonSearch, ButtonSubmit, ButtonTheme };
+export { Button, ButtonLink, ButtonSearch, ButtonSubmit, ButtonTheme };