From 92a9a931cbee08d7a8de7bd4ad2c793900a9702e Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 3 Jun 2023 15:56:14 +0200 Subject: [PATCH] Timeline: Add group --- src/App.tsx | 30 ++++++++++- src/components/timeline/Timeline.scss | 39 -------------- src/components/timeline/TimelineElement.scss | 51 +++++++++++++++++++ src/components/timeline/TimelineElement.tsx | 20 +++++--- .../timeline/TimelineElementCard.tsx | 18 +++++++ 5 files changed, 110 insertions(+), 48 deletions(-) create mode 100644 src/components/timeline/TimelineElement.scss create mode 100644 src/components/timeline/TimelineElementCard.tsx diff --git a/src/App.tsx b/src/App.tsx index 744c424..4965994 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,7 @@ import ShortDescription from "./components/ShortDescription"; import Timeline from "./components/timeline/Timeline"; import TimelineElement from "./components/timeline/TimelineElement"; import {PROJECTS} from "./data/Project"; +import TimelineCard from './components/timeline/TimelineElementCard'; function App() { return ( @@ -11,7 +12,34 @@ function App() { - { PROJECTS.map(p => ) } + + + Youpi + + + Youpi + + + Youpi + + + Youpi + + + + + Youpi + + + Youpi + + + Youpi + + + Youpi + + ) diff --git a/src/components/timeline/Timeline.scss b/src/components/timeline/Timeline.scss index 68ea633..8a3f931 100644 --- a/src/components/timeline/Timeline.scss +++ b/src/components/timeline/Timeline.scss @@ -4,45 +4,6 @@ & > ul { @apply list-none py-5 px-0 relative w-full max-w-5xl mx-auto; - & > li { - @apply mb-12 relative flex; - - & > details { - @apply w-4/5 md:w-2/5 left-[10%] md:left-0 rounded-xl overflow-hidden relative bg-[#f5f5f5]; - box-shadow: 3px 3px 12px #dee1e4, -3px -3px 12px #fff; - - & > summary { - @apply block select-none cursor-pointer outline-none p-5 mb-0 font-semibold; - transition: all 600ms cubic-bezier(0.2, 1, 0.3, 1); - - &:hover { - @apply bg-[#f8f8f8]; - } - } - - & > p { - @apply py-5 pl-0 pr-2; - } - - &[open] { - & > summary { - @apply mb-5 pb-5; - border-bottom: 1px solid rgba(0, 0, 0, 0.1); - } - } - } - - // Place point in center line - &:before { - @apply content-[""] w-6 h-6 rounded-[50%] absolute top-5 left-0 md:left-1/2 bg-[#f8f8f8] -ml-2 z-50; - box-shadow: 2px 2px 5px #dee1e4, -2px -2px 5px #fff; - } - - &:nth-child(even) { - @apply md:justify-end; - } - } - // Draw center line &:before { @apply top-0 bottom-0 left-0 md:left-1/2 absolute content-[""] w-2 bg-[#f5f5f5]; diff --git a/src/components/timeline/TimelineElement.scss b/src/components/timeline/TimelineElement.scss new file mode 100644 index 0000000..732d772 --- /dev/null +++ b/src/components/timeline/TimelineElement.scss @@ -0,0 +1,51 @@ +.timeline-element { + @apply relative flex flex-col md:flex-row justify-between; + + // Place point in center line + &:before { + @apply content-[""] w-6 h-6 rounded-[50%] absolute top-5 left-0 md:left-1/2 bg-[#f8f8f8] -ml-2 z-50; + box-shadow: 2px 2px 5px #dee1e4, -2px -2px 5px #fff; + } + + &:nth-child(even) { + @apply md:flex-row-reverse; + + .timeline-element__category { + @apply md:flex-row-reverse; + } + } + + .timeline-element__info, .timeline-element__category { + @apply relative w-4/5 md:w-2/5 left-[10%] md:left-0; + } + + .timeline-element__category { + @apply top-5 flex md:justify-end mb-12; + } + + .timeline-element__info { + & > details { + @apply mb-12 rounded-xl overflow-hidden relative bg-[#f5f5f5]; + box-shadow: 3px 3px 12px #dee1e4, -3px -3px 12px #fff; + + & > summary, & > div { + @apply p-5; + } + + & > summary { + @apply block select-none cursor-pointer outline-none mb-0 font-semibold; + transition: all 600ms cubic-bezier(0.2, 1, 0.3, 1); + + &:hover { + @apply bg-[#f8f8f8]; + } + } + + &[open] { + & > summary { + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + } + } + } + } +} \ No newline at end of file diff --git a/src/components/timeline/TimelineElement.tsx b/src/components/timeline/TimelineElement.tsx index 2fc9adc..37cd81b 100644 --- a/src/components/timeline/TimelineElement.tsx +++ b/src/components/timeline/TimelineElement.tsx @@ -1,18 +1,22 @@ -import react, {Children} from 'react' +import './TimelineElement.scss' +import react, {ReactNode} from 'react' import Project from '../../data/Project' type TimelineElementProps = { - project: Project + category: string, + children: ReactNode } -function TimelineElement({ project } : TimelineElementProps) { +function TimelineElement({ category, children } : TimelineElementProps) { return ( -
  • -
    - { project.name } -

    { project.description }

    -
    +
  • +
    + { category } +
    +
    + { children } +
  • ) } diff --git a/src/components/timeline/TimelineElementCard.tsx b/src/components/timeline/TimelineElementCard.tsx new file mode 100644 index 0000000..16d4df2 --- /dev/null +++ b/src/components/timeline/TimelineElementCard.tsx @@ -0,0 +1,18 @@ +import react, {ReactNode} from 'react' +import Project from '../../data/Project' + +type TimelineElementCardProps = { + title: string, + children: ReactNode +} + +function TimelineCard({ title, children } : TimelineElementCardProps) { + return ( +
    + {title} +
    {children}
    +
    + ) +} + +export default TimelineCard \ No newline at end of file