From 453c9550e2ea6cc1f44d0588909ef69046b7217e Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Sun, 9 Oct 2022 13:18:03 +0200 Subject: [PATCH] implement better card-flip --- src/components/better/card-flip.js | 54 ++++++++++++++-------------- src/components/better/card-flip.scss | 27 +++++++++++++- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/components/better/card-flip.js b/src/components/better/card-flip.js index 15bea62..ab20b44 100644 --- a/src/components/better/card-flip.js +++ b/src/components/better/card-flip.js @@ -1,24 +1,24 @@ -import React, {useRef, useEffect, useState} from "react" +import React, { useRef, useEffect, useState } from "react" import "./card-flip.scss" -function CardFlip (props) { +function CardFlip(props) { let toggleButtonRef = useRef(null) let closeButtonRef = useRef(null) let overlayRef = useRef(null) - const [ isActive, setIsActive ] = useState(false) + const [isActive, setIsActive] = useState(false) const [transitionStatus, changeTransitionStatus] = useState(0) - + useEffect(() => { - const handler = (event) => { - // you can listen for any animatable CSS property here! - // Note: opacity alone is not enough to properly disable hidden content still in the DOM. - if (event.propertyName === "opacity" && closeButtonRef.current !== null) { - closeButtonRef.current.focus() + const handler = (event) => { + // you can listen for any animatable CSS property here! + // Note: opacity alone is not enough to properly disable hidden content still in the DOM. + if (event.propertyName === "opacity" && closeButtonRef.current !== null) { + closeButtonRef.current.focus() + } } - } - window.addEventListener("transitionend", handler) + window.addEventListener("transitionend", handler) }, []) const handleClick = (event) => { setIsActive(!isActive) @@ -33,23 +33,23 @@ function CardFlip (props) { const overlay = isActive ?
-
- -
{props.memberName}
- {props.subtitle} -

{props.bio}

-
- - - +
+ +
{props.memberName}
+ {props.subtitle} +

{props.bio}

+
+ + + +
-
- : false + : false return (
@@ -66,7 +66,7 @@ function CardFlip (props) {
{overlay}
diff --git a/src/components/better/card-flip.scss b/src/components/better/card-flip.scss index bcbc83b..805967d 100644 --- a/src/components/better/card-flip.scss +++ b/src/components/better/card-flip.scss @@ -1,10 +1,12 @@ * { box-sizing: border-box; } + .team-member { display: inline-block; position: relative; } + .team-content { padding: 0; position: relative; @@ -14,15 +16,18 @@ width: 320px; text-align: center; } + .team-content button { background-color: transparent; border: none; color: currentColor; -webkit-appearance: none; } + .team-content .toggle-button * { text-decoration: underline; } + .team-image { display: block; width: 190px; @@ -35,6 +40,7 @@ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07); text-align: center; } + .team-content .team-name { display: block; font-size: 18px; @@ -43,6 +49,7 @@ margin: 0; margin-bottom: 10px; } + .team-content .team-subtitle { margin-bottom: 0px; display: block; @@ -51,12 +58,14 @@ line-height: 1; color: inherit; } + .team-member .team-image img { margin: 0 auto; border: none; height: auto; width: 100%; } + .team-content-overlay { background-color: #1c6300; color: #fff; @@ -77,6 +86,7 @@ z-index: 100; border-radius: 90px; } + .active .team-content-overlay { opacity: 1; visibility: visible; @@ -87,6 +97,7 @@ height: auto; border-radius: 10px; } + .team-content-overlay .gradient-overlay { position: absolute; width: 100%; @@ -95,14 +106,17 @@ top: 0; left: 0; } + .team-content .team-content-overlay .team-name { font-size: 18px; font-weight: 700; position: relative; } + .team-content .team-content-overlay .team-subtitle { position: relative; } + .team-close-button { border: none; font-weight: bold; @@ -111,9 +125,10 @@ right: 10px; &:focus { - outline: 3px solid lightblue; + outline: 3px solid lightblue; } } + .team-content-overlay p { color: #fff; opacity: 0; @@ -126,10 +141,12 @@ // -o-transition: 0.25s ease-in; // transition: 0.25s ease-in; } + .active .team-content-overlay p { opacity: 1; font-size: 12px; } + .team-socials { position: relative; margin: auto; @@ -139,12 +156,20 @@ text-align: center; line-height: 12px; } + .team-socials a { color: #225165; outline: 0; text-decoration: none; } + .team-socials svg { margin: 0 10px; width: 25px; +} + +@media (prefers-reduced-motion: reduce) { + .team-content-overlay { + transition: 0.0001ms; + } } \ No newline at end of file