Skip to content

Commit

Permalink
feat(card): created card component
Browse files Browse the repository at this point in the history
Card #25
  • Loading branch information
Kacper Kruczek committed Feb 24, 2022
1 parent 1f7fd59 commit e655406
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ui/card/card.component.tsx
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>
);
5 changes: 5 additions & 0 deletions src/ui/card/card.model.ts
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;
};
24 changes: 24 additions & 0 deletions src/ui/card/card.utils.ts
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));
3 changes: 3 additions & 0 deletions src/ui/card/index.ts
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';
1 change: 1 addition & 0 deletions src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './alert';
export * from './button';
export * from './card';
export * from './date-format';
export * from './label';
export * from './pagination';
Expand Down

0 comments on commit e655406

Please sign in to comment.