Skip to content

Commit

Permalink
Merge pull request #870 from hxtree/feature/basic-card-hover-chevron
Browse files Browse the repository at this point in the history
Add chevron animation on hover
  • Loading branch information
hxtree committed Mar 18, 2024
2 parents 5b8f187 + 2139204 commit cc75d59
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions clients/design-system/src/components/Card/BasicCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import './style.module.scss';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { faChevronRight, faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { CardRibbonColor } from './CardRibbonColor.type';

export type BasicCardProps = {
Expand All @@ -18,6 +18,15 @@ export type BasicCardProps = {
// TODO finish fleshing in basic card props
export const BasicCard = (props: BasicCardProps): JSX.Element => {
const { ribbonText, ribbonColor, title, imageSrc, testId, url, cta, children } = props;
const [isHovered, setIsHovered] = useState(false);

const handleMouseEnter = () => {
setIsHovered(true);
};

const handleMouseLeave = () => {
setIsHovered(false);
};

const ribbonClasses = [
'card-ribbon',
Expand All @@ -30,7 +39,11 @@ export const BasicCard = (props: BasicCardProps): JSX.Element => {
}

return (
<div className="card h-100 border-radius-4">
<div
className="card h-100 border-radius-4"
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
<div className='card-thumbnail'>
<div className="card-img-top-wrapper">
<div className="card-img-top" style={{background: `url(${imageSrc})`}}/>
Expand All @@ -52,7 +65,7 @@ export const BasicCard = (props: BasicCardProps): JSX.Element => {
{cta}
</span>
<span className="icon text-end flex-fill">
<FontAwesomeIcon icon={faArrowRight}/>
<FontAwesomeIcon icon={isHovered ? faArrowRight: faChevronRight} />
</span>
</div>
<a href={url} className="stretched-link"></a>
Expand Down

0 comments on commit cc75d59

Please sign in to comment.