Skip to content

Commit 50b9f5e

Browse files
committed
feat: new cards
1 parent f00f8e2 commit 50b9f5e

File tree

3 files changed

+719
-668
lines changed

3 files changed

+719
-668
lines changed

src/Card/Card.tsx

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import React, { FC, HTMLAttributes, ElementType, Ref } from 'react';
22
import classNames from 'classnames';
3-
import { Card as CardBase } from 'reactstrap';
43
import { CSSModule } from 'reactstrap/types/lib/utils';
54

65
export interface CardProps extends HTMLAttributes<HTMLElement> {
76
/** Utilizzarlo in caso di utilizzo di componenti personalizzati */
87
tag?: ElementType;
9-
/** Utilizzarlo quando si passa `a` a `tag` per ottenere una special card cliccabile */
10-
href?: string;
118
/** Classi aggiuntive da usare per il componente Card */
129
className?: string;
1310
/** Da utilizzare per impostare un riferimento all'elemento DOM */
@@ -16,48 +13,36 @@ export interface CardProps extends HTMLAttributes<HTMLElement> {
1613
cssModule?: CSSModule;
1714
/** Abilita la versione teaser della Card */
1815
teaser?: boolean;
19-
/** Quando attivo distanzia la Card nella versione mobile */
20-
spacing?: boolean;
21-
/** Quando attivo rimuove il componente contenitore della carta. Utile per card multiple nello stesso contenitore */
22-
noWrapper?: boolean;
23-
/** Classi aggiuntive per l'elemento contenitore */
24-
wrapperClassName?: string;
16+
/** La card contiene un'immagine */
17+
image?: boolean;
18+
/** La card ha un bordo */
19+
border?: boolean;
2520
testId?: string;
2621
}
2722

2823
export const Card: FC<CardProps> = ({
29-
tag = 'div',
30-
href = undefined,
24+
tag = 'article',
3125
teaser,
32-
spacing,
33-
noWrapper = false,
34-
wrapperClassName,
26+
image,
27+
border=true,
3528
testId,
3629
...attributes
3730
}) => {
38-
const wrapperClasses = classNames('card-wrapper', wrapperClassName, {
39-
'card-space': spacing,
31+
const cardClasses = classNames('it-card', attributes.className, {
32+
'card-teaser': teaser,
33+
'it-card-image': image,
34+
'border': border,
4035
'card-teaser-wrapper': teaser
4136
});
42-
const cardClasses = classNames(attributes.className, {
43-
'card-teaser': teaser
44-
});
4537

46-
if (noWrapper) {
47-
return (
48-
<CardBase
49-
{...attributes}
50-
className={cardClasses}
51-
tag={tag}
52-
href={tag === 'a' ? href : undefined}
53-
data-testid={testId}
54-
/>
55-
);
56-
}
38+
const T = tag;
5739

5840
return (
59-
<div className={wrapperClasses} data-testid={testId}>
60-
<CardBase {...attributes} className={cardClasses} tag={tag} href={tag === 'a' ? href : undefined} />
61-
</div>
41+
<T
42+
{...attributes}
43+
className={cardClasses}
44+
data-testid={testId}
45+
/>
6246
);
47+
6348
};

0 commit comments

Comments
 (0)