Skip to content

Commit

Permalink
feat(ui): enhance styled base card
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericvilcot committed Nov 23, 2022
1 parent 0e134cb commit f5dceb9
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 9 deletions.
72 changes: 63 additions & 9 deletions src/components/card/BaseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
import classNames from 'classnames'
import Skeleton from '@mui/material/Skeleton'
import Image from 'next/image'
import React from 'react'

type BaseCardProps = {
export type BaseCardProps = {
title?: JSX.Element
description?: JSX.Element
backgroundImageUrl?: string
loading?: boolean
disabled?: boolean
disabledBackgroundImageUrl?: string
}

export const BaseCard: React.FC<BaseCardProps> = ({ title, description }) => (
<div className="okp4-nemeton-web-base-card-main">
{title && <div className="okp4-nemeton-web-base-card-title-container">{title}</div>}
{description && (
<div className="okp4-nemeton-web-base-card-description-container">{description}</div>
)}
</div>
)
export const BaseCard: React.FC<BaseCardProps> = ({
title,
description,
loading,
disabled,
disabledBackgroundImageUrl,
backgroundImageUrl
}) =>
loading ? (
<div className="okp4-nemeton-web-base-card-main">
<Skeleton
height={45}
sx={{ bgcolor: 'rgba(255, 255, 255, 0.13)', borderRadius: '10px' }}
variant="rectangular"
width={80}
/>
<div>
<Skeleton
height={30}
sx={{ bgcolor: 'rgba(255, 255, 255, 0.13)', borderRadius: '10px' }}
variant="text"
width={160}
/>
<Skeleton
height={30}
sx={{ bgcolor: 'rgba(255, 255, 255, 0.13)', borderRadius: '10px' }}
variant="text"
width={160}
/>
</div>
</div>
) : (
<div style={{ position: 'relative' }}>
{backgroundImageUrl && (
<Image
alt="background-image"
className="okp4-nemeton-web-base-card-bg-image"
fill
sizes="100%"
src={backgroundImageUrl}
/>
)}
<div
className={classNames('okp4-nemeton-web-base-card-main', { disabled })}
style={{
backgroundImage:
disabled && disabledBackgroundImageUrl ? `url(${disabledBackgroundImageUrl})` : 'none'
}}
>
{title && <div className="okp4-nemeton-web-base-card-title-container">{title}</div>}
{description && (
<div className="okp4-nemeton-web-base-card-description-container">{description}</div>
)}
</div>
</div>
)
14 changes: 14 additions & 0 deletions src/components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@
box-shadow: 0 4px 20px rgb(0 0 0 / 25%);
border-radius: 20px;
padding: 0 30px;
position: relative;

&.disabled {
border: 1px solid rgba(255, 255, 255, 0.2);
text-align: center;
color: rgba(255, 255, 255, 0.6);
background-repeat: no-repeat;
background-position: bottom right;
}
}

.okp4-nemeton-web-base-card-bg-image {
opacity: 0.4;
border-radius: 20px;
}

0 comments on commit f5dceb9

Please sign in to comment.