Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Security upgrade styled-components from 5.3.5 to 5.3.7 #51

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintcache

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Next.js
.next/
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import './FilterBar.css';
import styles from '@/styles/FilterBar.module.css';
import Select, { MultiValue, Theme } from "react-select";
import makeAnimated from 'react-select/animated';
import { CSSProperties } from "styled-components";
import { GroupedOption, KeywordOption, LanguageOption } from "../../model/Options";
import { groupedOptions } from "../../data";
import { GroupedOption, KeywordOption, LanguageOption } from "@/models/Options";
import { groupedOptions } from "@/data/optionsData";

// animation on select
const animatedComponents = makeAnimated();
Expand Down Expand Up @@ -49,7 +49,7 @@ const ProjectsFilterBar = ({onChange}: { onChange: (value: MultiValue<LanguageOp

return <Select<LanguageOption | KeywordOption, true, GroupedOption>
isDisabled={false} isLoading={false} isClearable isRtl={false} isSearchable
name="projects-search-bar" className="multi-select" classNamePrefix="select" isMulti
name="projects-search-bar" className={styles["multi-select"]} classNamePrefix="select" isMulti
closeMenuOnSelect={false} closeMenuOnScroll={true} placeholder="Select options to filter projects"
noOptionsMessage={() => "No more languages or keywords to select 😢"} components={animatedComponents}
options={groupedOptions} formatGroupLabel={formatGroupLabel} onChange={onChange} theme={customTheme}
Expand Down
114 changes: 114 additions & 0 deletions components/meta/PageMetaTags.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* Defines a component to add basic
* meta tags for page.
*
* @module components.meta.basic-tags
*/

import { pathToUrl } from "@/utils/routes"
import Head from "next/head"
import { FC } from "react"

/**
* Structure to represent the basic meta tags component properties.
*/
export interface PageMetaTagsProps {
/**
* Title of the page.
*/
title?: string

/**
* Description of the page
*/
description?: string

/**
* Path to access the canonical page.
*/
pagePath: string

/**
* Substructure to handle image for social networks.
*/
image?: {
/**
* Path to the image.
*/
path: string

/**
* Width of the image.
*/
width: number

/**
* Height of the image.
*/
height: number

/**
* Alternative text for the image.
*/
alt: string
}
}

/**
* Represents a set of needed meta tags to upgrade SEO,
* display basic informations and for social networks sharing.
*
* @param {PageMetaTagsProps} param0 component parameters
* @returns {JSX.Element} component instance
*/
const PageMetaTags: FC<PageMetaTagsProps> = (props) => {
const { title, description, pagePath, image } = {
...props,
title: props.title ? props.title + " | GL's Portfolio" : "Guillaume Letellier Portfolio",
description: props.description || "Portfolio of Guillaume Letellier, a french student at University of Caen Normandy",
pagePath: pathToUrl(props.pagePath),
image: {
...props.image,
path: props.image && pathToUrl(props.image.path),
}
}

return (
<Head key="page_meta_tags">
<title data-testid="site-title">{title}</title>
<meta data-testid="meta-title" name="title" content={title} />
<meta data-testid="meta-description" name="description" content={description} />
<link data-testid="link-canonical" rel="canonical" href={pagePath} />

{/* Open Graph / Facebook */}
{/* <meta data-testid="meta-og-sitename" property="og:site_name" content="Guillaume Letellier's Portfolio" />
<meta data-testid="meta-og-type" property="og:type" content="website" />
<meta data-testid="meta-og-url" property="og:url" content={pagePath} />
<meta data-testid="meta-og-title" property="og:title" content={title} />
<meta data-testid="meta-og-description" property="og:description" content={description} />
{
props.image && <>
<meta data-testid="meta-og-image" property="og:image" content={image.path} />
<meta data-testid="meta-og-image-width" property="og:image:width" content={`${image.width}`} />
<meta data-testid="meta-og-image-height" property="og:image:height" content={`${image.height}`} />
<meta data-testid="meta-og-image-alt" property="og:image:alt" content={image.alt} />
</>
} */}

{/* Twitter */}
{/* <meta name="twitter:site" content="@khollector" /> */}
{/* <meta data-testid="meta-twitter-card" name="twitter:card" content={`summary${props.image ? "_large_image" : ""}`} />
<meta data-testid="meta-twitter-url" name="twitter:url" content={pagePath} />
<meta data-testid="meta-twitter-title" name="twitter:title" content={title} />
<meta data-testid="meta-twitter-description" name="twitter:description" content={description} />
{
props.image && <>
<meta data-testid="meta-twitter-image" name="twitter:image" content={image.path} />
</>
} */}
</Head>
)
}
PageMetaTags.displayName = "PageMetaTags"

export default PageMetaTags
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { faChevronRight } from "@fortawesome/free-solid-svg-icons";
import classNames from "classnames";
import { FontAwesomeIcon } from "../icons";
library.add(faChevronRight);

const Chevron = (props: { className?: string; }) => {
return <FontAwesomeIcon className={props.className} type="solid" size="1x" iconName="chevron-right" />
return <FontAwesomeIcon iconName="chevron-right" type="solid" size="1x" className={classNames(props.className, "icon-size")} />
};

export default Chevron;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./accordion.css";
import styles from "@/styles/Accordion.module.css";
import { ReactNode, useEffect, useRef, useState } from "react";
import Chevron from "./Chevron";

Expand Down Expand Up @@ -40,10 +40,10 @@ const Accordion = (props: { title: string; children: ReactNode; id?: string, isO
}
}, [props.isOpen])

return <div className="accordion" id={props.id}>
<button className={`accordion__title ${active && "active"}`} onClick={toggleAccordion}>{props.title}<Chevron className={`accordion__icon ${rotate}`} /></button>
<div className="accordion__content" ref={content} style={{ maxHeight: (active ? height : 0) }}>
<div className="accordion__text">{props.children}</div>
return <div className={styles["accordion"]} id={props.id}>
<button className={`${styles["accordion__title"]} ${active && styles["active"]}`} onClick={toggleAccordion}>{props.title}<Chevron className={`${styles["accordion__icon"]} ${styles[rotate]}`} /></button>
<div className={styles["accordion__content"]} ref={content} style={{ maxHeight: (active ? height : 0) }}>
<div className={styles["accordion__text"]}>{props.children}</div>
</div>
</div>
};
Expand Down
28 changes: 22 additions & 6 deletions src/components/button/index.tsx → components/ui/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './buttons.css';
import { Link } from 'react-router-dom';
import styles from "@/styles/Button.module.css"
import Link from 'next/link';
import styled from 'styled-components';
import classNames from 'classnames'

const ButtonWrapper = styled.button<{ size?: number }>`
border: none;
Expand All @@ -18,22 +19,37 @@ const ButtonWrapper = styled.button<{ size?: number }>`
`;

export const Button = (props: { className?: string; children: React.Component | string | number | boolean | JSX.Element; size?: number; style?: React.CSSProperties }) => {
return <ButtonWrapper size={props.size} className={"button " + props.className} style={props.style}>
const classnames = classNames(
styles["button"],
props.className && props.className,
)

return <ButtonWrapper size={props.size} className={classnames} style={props.style}>
{props.children}
</ButtonWrapper>
};

export const ButtonLink = (props: { targetLink: string; className?: string; children: React.Component | string | number | boolean | JSX.Element; size?: number; style?: React.CSSProperties, title?: string }) => {
return <Link to={props.targetLink} className="button-link" title={props.title}>
<ButtonWrapper size={props.size} className={"button " + props.className} style={props.style}>
const classnames = classNames(
styles["button"],
props.className && props.className,
)

return <Link href={props.targetLink} className="button-link" title={props.title}>
<ButtonWrapper size={props.size} className={classnames} style={props.style}>
{props.children}
</ButtonWrapper>
</Link>;
};

export const ButtonExternalLink = (props: { download?: boolean, title: string; targetLink: string; className?: string; target?: string, children: React.Component | string | number | boolean | JSX.Element; size?: number; style?: React.CSSProperties }) => {
const classnames = classNames(
styles["button"],
props.className && props.className,
)

return <a className="button-link" href={props.targetLink} title={props.title} download={props.download} target={props.target} rel="noreferrer">
<ButtonWrapper size={props.size} className={"button " + props.className} style={props.style}>
<ButtonWrapper size={props.size} className={classnames} style={props.style}>
{props.children}
</ButtonWrapper>
</a>;
Expand Down
Loading