-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Card #25
- Loading branch information
Kacper Kruczek
committed
Feb 24, 2022
1 parent
1f7fd59
commit e655406
Showing
5 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
|
||
import { BaseCardProps } from './card.model'; | ||
import { getCardClasses } from './card.utils'; | ||
|
||
export const Card: React.FC<BaseCardProps> = ({ | ||
elevation, | ||
children, | ||
className, | ||
}) => ( | ||
<div className={clsx(getCardClasses(elevation), className)}>{children}</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type BaseElevationOptions = 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'; | ||
export type BaseCardProps = { | ||
elevation?: BaseElevationOptions; | ||
className?: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import clsx from 'clsx'; | ||
|
||
import { BaseElevationOptions } from './card.model'; | ||
|
||
const getShadowClass = (elevation?: BaseElevationOptions) => { | ||
switch (elevation) { | ||
case 'none': | ||
return 'shadow-none'; | ||
case 'sm': | ||
return 'shadow-sm'; | ||
case 'md': | ||
return 'shadow-md'; | ||
case 'lg': | ||
return 'shadow-lg'; | ||
case 'xl': | ||
return 'shadow-xl'; | ||
case '2xl': | ||
return 'shadow-2xl'; | ||
default: | ||
return 'shadow'; | ||
} | ||
}; | ||
export const getCardClasses = (elevation?: BaseElevationOptions) => | ||
clsx('border rounded p-2 ', getShadowClass(elevation)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './card.component'; | ||
export * from './card.model'; | ||
export * from './card.utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters