-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.tsx
More file actions
75 lines (69 loc) · 1.78 KB
/
Card.tsx
File metadata and controls
75 lines (69 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use client';
import { Button } from '@react-universal/components';
import { Div, H2, Span } from '@react-universal/elements';
import { useCallback, useState } from 'react';
interface CardProps {
children?: React.ReactNode;
href?: string;
ref?: React.Ref<HTMLAnchorElement>;
title?: string;
}
export const Card: React.FC<CardProps> = ({ children, href, ref, title }) => {
const [hovered, setHovered] = useState(false);
const handleHoverIn = useCallback(() => setHovered(true), []);
const handleHoverOut = useCallback(() => setHovered(false), []);
return (
<Button
ref={ref}
href={href}
hrefAttrs={{
target: '_blank',
rel: 'noopener noreferrer',
}}
role="link"
sx={{
bgColor: `rgba(var(--card-rgb) / ${hovered ? 0.1 : 0})`,
borderRadius: '0.5rem',
borderWidth: 1,
flexDir: 'column',
p: '5',
transitionDuration: '200ms',
transitionProperty: 'background-color, border-color',
}}
onHoverIn={handleHoverIn}
onHoverOut={handleHoverOut}
>
<H2
sx={{
fontSize: '1.5rem',
fontWeight: 600,
lineHeight: 1.23,
mb: { xs: '0.5rem', md: '0.7rem' },
}}
>
{title}{' '}
<Span
sx={{
display: 'inline-block' as any,
transform: `translateX(${hovered ? '4px' : 0})`,
// '@media (prefers-reduced-motion)': 'none',
transition: 'transform 200ms',
}}
>
->
</Span>
</H2>
<Div
sx={{
fontSize: '0.9rem',
lineHeight: 1.5,
maxWidth: '30ch',
opacity: 0.6,
textWrap: 'balance',
}}
>
{children}
</Div>
</Button>
);
};