Skip to content

Commit

Permalink
add gradient to bottom on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
FBalint committed Jul 3, 2024
1 parent 6192803 commit 9c59652
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/solutions/SolutionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Circle,
HStack,
Heading,
Expand All @@ -8,6 +9,7 @@ import {
} from "@chakra-ui/react"
import DisplayCard from "components/common/DisplayCard"
import Image from "next/image"
import { transparentize } from "utils/transparentize"

export type Props = {
title: string
Expand Down Expand Up @@ -42,6 +44,7 @@ const SolutionCard = ({
outlineColor={outlineColor}
outlineOffset="-1px"
onClick={onClick}
zIndex={2}
_before={{
content: `""`,
position: "absolute",
Expand All @@ -57,10 +60,42 @@ const SolutionCard = ({
transition: "0.3s",
filter: `blur(2px) saturate(70%)`,
}}
_after={{
transition: "0.3s",
opacity: 0,
content: `""`,
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
bg: `linear-gradient(to top, ${transparentize(
cardBg,
1
)}, ${transparentize(cardBg, 0)} 66%)`,
}}
_hover={{
_before: { opacity: 0.25, filter: `blur(0) saturate(100%)` },
_before: {
opacity: 0.25,
filter: `blur(0) saturate(100%)`,
},
_after: {
opacity: 1,
},
}}
>
<Box
position="absolute"
top={0}
left={0}
right={0}
bottom={0}
outline="1px solid"
outlineColor={outlineColor}
outlineOffset="-1px"
zIndex={3}
rounded={"2xl"}
/>
<Stack spacing={3} zIndex={1} justifyContent={"space-between"} h={"100%"}>
<HStack gap={3}>
<Circle
Expand Down
15 changes: 15 additions & 0 deletions src/utils/transparentize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ThemeTypings } from "@chakra-ui/react"

/**
* Transparentize Chakra UI color tokens
*
* @param color - Chakra UI (semantic) token
* @param opacity - Opacity value 0 to 1.
*/
export const transparentize = (color: ThemeTypings["colors"], value: number) => {
const key = color.replaceAll(".", "-")
return `color-mix(in srgb, var(--chakra-colors-${key}) ${Math.max(
Math.min(value * 100, 100),
0
)}%, transparent)`
}

0 comments on commit 9c59652

Please sign in to comment.