-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathindex.tsx
More file actions
89 lines (80 loc) · 2.82 KB
/
Copy pathindex.tsx
File metadata and controls
89 lines (80 loc) · 2.82 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React, { ReactNode } from 'react'
import clsx from 'clsx'
import Link from '@docusaurus/Link'
import { useState, useEffect } from 'react'
import { useColorMode } from '@docusaurus/theme-common'
import Heading from '@theme/Heading'
import CutOffCorners from '@site/src/components/elements/cut-off-corners'
import Button from '@site/src/components/elements/buttons/button'
import styles from './styles.module.scss'
export interface CardItem {
title?: ReactNode
description?: ReactNode
href?: string
flaskOnly?: boolean
buttonIcon?: 'arrow-right' | 'external-arrow'
}
interface CardListItemProps {
item: CardItem
}
export default function CardListItem({ item }: CardListItemProps) {
const { title, description, href, flaskOnly, buttonIcon = 'arrow-right' } = item
const [isHovered, setIsHovered] = useState(false)
const { colorMode } = useColorMode()
const [theme, setTheme] = useState('')
useEffect(() => {
setTheme(colorMode)
}, [colorMode])
return (
<li
className={clsx(styles['item'], isHovered && styles['active'], flaskOnly && styles['flask'])}>
<CutOffCorners size="s">
<div
className={styles['holder']}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}>
<Link to={href} className={clsx(styles['inner'], 'link-styles-none')}>
{flaskOnly && (
<div className={styles['tag-holder']}>
<CutOffCorners size={'xs'}>
<span
className={clsx(
styles['tag'],
'type-label-caption uppercase font-weight-medium'
)}>
Flask
</span>
</CutOffCorners>
</div>
)}
<div className={styles['header']}>
<Heading as="h3" className={clsx(styles['title'], 'type-heading-xs')}>
{title}
</Heading>
<p className={clsx(styles['description'], 'type-paragraph-s')}>{description}</p>
</div>
{href && (
<Button
as="button"
label={false}
type={theme === 'dark' ? 'secondary' : 'primary'}
icon={buttonIcon}
style={
theme === 'dark'
? {
'--button-color-hover': 'var(--general-white)',
'--button-text-color-hover': 'var(--general-black)',
}
: {
'--button-color-hover': 'var(--general-black)',
'--button-text-color-hover': 'var(--general-white)',
}
}
/>
)}
</Link>
</div>
</CutOffCorners>
</li>
)
}