summaryrefslogtreecommitdiffstats
path: root/src/components/atoms/links
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-04-16 16:08:49 +0200
committerArmand Philippot <git@armandphilippot.com>2022-04-16 16:41:30 +0200
commit5a6e4eea16047083e2de0e91a1b3ed9be8d6eb68 (patch)
treeea0c5390aca73907aade5321f30cb7bf8d3ab1cb /src/components/atoms/links
parentdaffe6e8b9e2021ffb9d006482143bc4db985f02 (diff)
refactor: support React 18
I replaced the deprecated VFC type with FC type and made all children explicits. Formatjs is still not compatible with React 18 so I need to skip type checking when comitting. There are some type errors because of IntlProvider in Storybook stories.
Diffstat (limited to 'src/components/atoms/links')
-rw-r--r--src/components/atoms/links/link.module.scss20
-rw-r--r--src/components/atoms/links/link.tsx6
-rw-r--r--src/components/atoms/links/nav-link.tsx4
-rw-r--r--src/components/atoms/links/sharing-link.tsx4
-rw-r--r--src/components/atoms/links/social-link.tsx4
5 files changed, 26 insertions, 12 deletions
diff --git a/src/components/atoms/links/link.module.scss b/src/components/atoms/links/link.module.scss
index e7ead86..d23667a 100644
--- a/src/components/atoms/links/link.module.scss
+++ b/src/components/atoms/links/link.module.scss
@@ -5,7 +5,9 @@
&[hreflang] {
&::after {
display: inline-block;
- content: "\0000a0["attr(hreflang) "]";
+ /* Prettier is removing spacing between content parts. */
+ /* prettier-ignore */
+ content: "\0000a0[" attr(hreflang) "]";
font-size: var(--font-size-sm);
}
}
@@ -13,22 +15,30 @@
&--external {
&::after {
display: inline-block;
- content: "\0000a0"url(fun.encode-svg('<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_blue}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_blue}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'));
+ /* Prettier is removing spacing between content parts. */
+ /* prettier-ignore */
+ content: "\0000a0" url(fun.encode-svg('<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_blue}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_blue}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'));
}
&:focus:not(:active)::after {
- content: "\0000a0"url(fun.encode-svg('<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_white}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_white}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'));
+ /* Prettier is removing spacing between content parts. */
+ /* prettier-ignore */
+ content: "\0000a0" url(fun.encode-svg('<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_white}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_white}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'));
}
&[hreflang] {
&::after {
- content: "\0000a0["attr(hreflang) "]\0000a0"url(fun.encode-svg(
+ /* Prettier is removing spacing between content parts. */
+ /* prettier-ignore */
+ content: "\0000a0[" attr(hreflang) "]\0000a0" url(fun.encode-svg(
'<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_blue}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_blue}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'
));
}
&:focus:not(:active)::after {
- content: "\0000a0["attr(hreflang) "]\0000a0"url(fun.encode-svg(
+ /* Prettier is removing spacing between content parts. */
+ /* prettier-ignore */
+ content: "\0000a0[" attr(hreflang) "]\0000a0" url(fun.encode-svg(
'<svg width="13" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path fill="#{var.$light-theme_white}" d="M100 0 59.543 5.887l20.8 6.523-51.134 51.134 7.249 7.248L87.59 19.66l6.522 20.798z"/><path fill="#{var.$light-theme_white}" d="M4 10a4 4 0 0 0-4 4v82a4 4 0 0 0 4 4h82a4 4 0 0 0 4-4V62.314h-8V92H8V18h29.686v-8z"/></svg>'
));
}
diff --git a/src/components/atoms/links/link.tsx b/src/components/atoms/links/link.tsx
index 87f11fc..674c07b 100644
--- a/src/components/atoms/links/link.tsx
+++ b/src/components/atoms/links/link.tsx
@@ -1,9 +1,13 @@
import NextLink from 'next/link';
-import { FC } from 'react';
+import { FC, ReactNode } from 'react';
import styles from './link.module.scss';
export type LinkProps = {
/**
+ * The link body.
+ */
+ children: ReactNode;
+ /**
* Set additional classnames to the link.
*/
className?: string;
diff --git a/src/components/atoms/links/nav-link.tsx b/src/components/atoms/links/nav-link.tsx
index 25c0e7d..7c6fede 100644
--- a/src/components/atoms/links/nav-link.tsx
+++ b/src/components/atoms/links/nav-link.tsx
@@ -1,5 +1,5 @@
import Link from 'next/link';
-import { VFC, ReactNode } from 'react';
+import { FC, ReactNode } from 'react';
import styles from './nav-link.module.scss';
export type NavLinkProps = {
@@ -22,7 +22,7 @@ export type NavLinkProps = {
*
* Render a navigation link.
*/
-const NavLink: VFC<NavLinkProps> = ({ href, label, logo }) => {
+const NavLink: FC<NavLinkProps> = ({ href, label, logo }) => {
return (
<Link href={href}>
<a className={styles.link}>
diff --git a/src/components/atoms/links/sharing-link.tsx b/src/components/atoms/links/sharing-link.tsx
index 3cd2dd1..ca53ef9 100644
--- a/src/components/atoms/links/sharing-link.tsx
+++ b/src/components/atoms/links/sharing-link.tsx
@@ -1,4 +1,4 @@
-import { VFC } from 'react';
+import { FC } from 'react';
import { useIntl } from 'react-intl';
import styles from './sharing-link.module.scss';
@@ -26,7 +26,7 @@ export type SharingLinkProps = {
*
* Render a sharing link.
*/
-const SharingLink: VFC<SharingLinkProps> = ({ medium, url }) => {
+const SharingLink: FC<SharingLinkProps> = ({ medium, url }) => {
const intl = useIntl();
const text = intl.formatMessage(
{
diff --git a/src/components/atoms/links/social-link.tsx b/src/components/atoms/links/social-link.tsx
index 8c7c790..464bc60 100644
--- a/src/components/atoms/links/social-link.tsx
+++ b/src/components/atoms/links/social-link.tsx
@@ -2,7 +2,7 @@ import GithubIcon from '@assets/images/social-media/github.svg';
import GitlabIcon from '@assets/images/social-media/gitlab.svg';
import LinkedInIcon from '@assets/images/social-media/linkedin.svg';
import TwitterIcon from '@assets/images/social-media/twitter.svg';
-import { VFC } from 'react';
+import { FC } from 'react';
import styles from './social-link.module.scss';
export type SocialWebsite = 'Github' | 'Gitlab' | 'LinkedIn' | 'Twitter';
@@ -23,7 +23,7 @@ export type SocialLinkProps = {
*
* Render a social icon link.
*/
-const SocialLink: VFC<SocialLinkProps> = ({ name, url }) => {
+const SocialLink: FC<SocialLinkProps> = ({ name, url }) => {
/**
* Retrieve a social link icon by id.
* @param {string} id - The social website id.