Skip to content

Commit e855121

Browse files
committed
🎨 fix animation on download link
1 parent 386cb42 commit e855121

2 files changed

Lines changed: 29 additions & 10 deletions

File tree

web/core/Button/Button.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ButtonHTMLAttributes, forwardRef } from 'react'
1+
import { type ButtonHTMLAttributes, forwardRef } from 'react'
22
import { twMerge } from 'tailwind-merge'
33

44
export const commonButtonStyling = `
@@ -17,7 +17,12 @@ items-center
1717
gap-3
1818
`
1919

20-
export type Variants = 'contained' | 'outlined' | 'ghost' | 'contained-secondary' | 'outlined-secondary'
20+
export type Variants =
21+
| 'contained'
22+
| 'outlined'
23+
| 'ghost'
24+
| 'contained-secondary'
25+
| 'outlined-secondary'
2126

2227
/** Use for common button styling in Button,IconButton, Link/ButtonLink */
2328
export const getVariant = (variant: Variants): string => {
@@ -109,10 +114,23 @@ export type ButtonProps = {
109114
} & ButtonHTMLAttributes<HTMLButtonElement>
110115

111116
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
112-
({ variant = 'contained', type = 'button', children, className = '', ...rest }, ref) => {
117+
(
118+
{
119+
variant = 'contained',
120+
type = 'button',
121+
children,
122+
className = '',
123+
...rest
124+
},
125+
ref,
126+
) => {
113127
const variantClassNames = getVariant(variant)
114128

115-
const buttonClassNames = twMerge(commonButtonStyling, variantClassNames, className)
129+
const buttonClassNames = twMerge(
130+
commonButtonStyling,
131+
variantClassNames,
132+
className,
133+
)
116134

117135
return (
118136
<button ref={ref} type={type} className={buttonClassNames} {...rest}>

web/core/Link/DownloadableLink.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import {
1111
} from 'react-icons/bs'
1212
import { FriendlyCaptchaContext } from '@/contexts/FriendlyCaptchaContext'
1313
import { Typography } from '@/core/Typography'
14-
import verifyCaptcha from '../../app/_actions/verifyCaptcha'
1514
import { twMerge } from '@/lib/twMerge/twMerge'
1615
import { Modal } from '@/sections/Modal'
1716
import FriendlyCaptcha from '@/templates/forms/FriendlyCaptcha'
1817
import type { LinkType } from '@/types'
18+
import verifyCaptcha from '../../app/_actions/verifyCaptcha'
1919
import { ArrowRight } from '../../icons'
2020
import { BaseLink } from './BaseLink'
2121
import { getArrowElement, type ResourceLinkProps } from './ResourceLink'
@@ -122,16 +122,17 @@ const DownloadableLink = forwardRef<HTMLDivElement, DownloadableLinkProps>(
122122
setIsFriendlyChallengeDone(true)
123123
const result = await verifyCaptcha(solution)
124124
setNotHuman(result !== true)
125-
setIsHuman(result == true)
125+
setIsHuman(result === true)
126126
},
127-
[],
127+
[setIsHuman],
128128
)
129129

130130
const commonResourceLinkWrapperClassName = `
131-
group/link
131+
group
132132
text-base
133133
relative
134134
flex
135+
cursor-pointer
135136
flex-col
136137
justify-end
137138
gap-0
@@ -193,7 +194,7 @@ const DownloadableLink = forwardRef<HTMLDivElement, DownloadableLinkProps>(
193194
className={
194195
type !== 'stickyMenu'
195196
? commonResourceLinkWrapperClassName
196-
: `group/link relative flex w-fit items-end justify-center text-slate-80 text-sm underline-offset-2`
197+
: `group relative flex w-fit cursor-pointer items-end justify-center text-slate-80 text-sm underline-offset-2`
197198
}
198199
title={`${assetLabel}`}
199200
aria-haspopup='dialog'
@@ -222,7 +223,7 @@ const DownloadableLink = forwardRef<HTMLDivElement, DownloadableLinkProps>(
222223
</div>
223224
{type !== 'stickyMenu' && (
224225
<div className='relative h-0.5'>
225-
<div className='absolute inset-0 z-10 h-0.5 w-[0%] bg-grey-50 transition-all duration-300 group-hover/link:w-full dark:bg-white-100' />
226+
<div className='absolute inset-0 z-10 h-0.5 w-[0%] bg-grey-50 transition-all duration-300 group-hover:w-full dark:bg-white-100' />
226227
<div className='absolute inset-0 z-0 h-px w-full bg-grey-50 dark:bg-white-100' />
227228
</div>
228229
)}

0 commit comments

Comments
 (0)