From 877b3d3806af19c821c29c3635a76cdbd313a97b Mon Sep 17 00:00:00 2001 From: Sonny Date: Fri, 7 Jan 2022 17:09:12 +0100 Subject: [PATCH] Ajout style --- .vscode/settings.json | 3 ++ components/Categories/Categories.js | 36 ++++++++------ components/Links/Link.js | 29 +++-------- components/Links/LinkBlock.js | 30 ++++++++++++ components/Links/Links.js | 4 +- pages/index.js | 3 +- styles/categories.module.scss | 74 +++++++++++++++++++++++++---- styles/globals.scss | 29 +++++++++-- styles/links.module.scss | 35 +++++++++++++- 9 files changed, 187 insertions(+), 56 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 components/Links/LinkBlock.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..54f6c0d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "discord.enabled": false +} \ No newline at end of file diff --git a/components/Categories/Categories.js b/components/Categories/Categories.js index 8feb8ae..273da10 100644 --- a/components/Categories/Categories.js +++ b/components/Categories/Categories.js @@ -2,30 +2,36 @@ import styles from '../../styles/categories.module.scss'; export default function Categories({ categories, favorites, handleSelectCategory, categoryActive }) { return (
-
+

Favoris

-
    - {favorites.map(({ name, category }, key) => { +
      + {favorites.map(({ name, link, category }, key) => { const catName = categories.find(c => c.id === category).name; return
    • - {name} - {catName} + + {name} - {catName} +
    • ; })}
-
+

Catégories

-
    - {categories.map(({ id, name }, key) => ( -
  • handleSelectCategory(id)} - > - {name} {id === categoryActive ? '(active)' : ''} -
  • - ))} +
      + {categories.map(({ id, name }, key) => { + const className = `${styles['item']} ${id === categoryActive ? styles['active'] : ''}`; + const onClick = () => handleSelectCategory(id); + + return ( +
    • + {name} +
    • + ) + })}
+
+ +
); } \ No newline at end of file diff --git a/components/Links/Link.js b/components/Links/Link.js index f217585..864498f 100644 --- a/components/Links/Link.js +++ b/components/Links/Link.js @@ -1,28 +1,11 @@ -import { useEffect, useCallback } from 'react'; -import { useInView } from 'react-intersection-observer'; - import styles from '../../styles/links.module.scss'; -export default function Link({ category, setCategoryActive, refCategoryActive }) { - const { ref, inView } = useInView({ threshold: .5 }); - const { id, name, links, ref: refCategory } = category; - - useEffect(() => inView ? setCategoryActive(id) : null, [id, inView, setCategoryActive]); - - const setRefs = useCallback((node) => { - refCategory.current = node; - refCategoryActive.current = node; - ref(node); - }, [ref, refCategoryActive, refCategory]); - +export default function Link({ link }) { return ( -
-

{name}

-
    - {links.map(({ name }, key2) => ( -
  • {name}
  • - ))} -
-
+
  • + + {link?.name} {link?.link} + +
  • ); } \ No newline at end of file diff --git a/components/Links/LinkBlock.js b/components/Links/LinkBlock.js new file mode 100644 index 0000000..8733764 --- /dev/null +++ b/components/Links/LinkBlock.js @@ -0,0 +1,30 @@ +import { useEffect, useCallback } from 'react'; +import { useInView } from 'react-intersection-observer'; + +import Link from './Link'; + +import styles from '../../styles/links.module.scss'; + +export default function LinkBlock({ category, setCategoryActive, refCategoryActive }) { + const { ref, inView } = useInView({ threshold: .5 }); + const { id, name, links, ref: refCategory } = category; + + useEffect(() => inView ? setCategoryActive(id) : null, [id, inView, setCategoryActive]); + + const setRefs = useCallback((node) => { + refCategory.current = node; + refCategoryActive.current = node; + ref(node); + }, [ref, refCategoryActive, refCategory]); + + return ( +
    +

    {name}

    +
      + {links.map((link, key2) => ( + + ))} +
    +
    + ); +} \ No newline at end of file diff --git a/components/Links/Links.js b/components/Links/Links.js index 0fc4f0a..b487616 100644 --- a/components/Links/Links.js +++ b/components/Links/Links.js @@ -1,11 +1,11 @@ -import Link from './Link'; +import LinkBlock from './LinkBlock'; import styles from '../../styles/links.module.scss'; export default function Links({ categories, setCategoryActive, refCategoryActive }) { return (
    {categories.map((category, key) => ( - a { + color: #3f88c5; + text-decoration: none; + padding: 10px 15px; + border: 1px solid #dadce0; + border-bottom: 2px solid #dadce0; + border-radius: 3px; + margin-bottom: 10px; + display: flex; + flex-direction: column; + transition: .15s; + + &:hover { + border-bottom-color: #3f88c5; + transform: scale(1.01); + } + + & .link-url { + color: #bbb; + font-size: .80em; + } + } + } } } \ No newline at end of file