Skip to content

Commit 381996d

Browse files
fix: hero story and added attribute it-class to it-card component (#369)
* chore: changeset * fix: format
1 parent 799df4b commit 381996d

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

.changeset/deep-spies-find.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@italia/card': patch
3+
'@italia/hero': patch
4+
---
5+
6+
Added attribute it-class to it-card component to set additional custom classes on card. Updated hero docs"

packages/card/src/card.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ $utilities: (
2626
),
2727
'shadow': map-get($utilities, 'shadow'),
2828
'border': map-get($utilities, 'border'),
29+
'padding': map-get($utilities, 'padding'),
30+
'padding-x': map-get($utilities, 'padding-x'),
31+
'padding-y': map-get($utilities, 'padding-y'),
2932
);
3033

3134
/**
@@ -59,6 +62,7 @@ dl {
5962
margin-top: 0;
6063
margin-bottom: var(--#{$prefix}spacing-s);
6164
}
65+
6266
/* END copied from bsi reboot */
6367

6468
::slotted(figure),

packages/card/src/it-card.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export class ItCard extends BaseComponent {
4141
@property({ type: String, attribute: 'heading-level' })
4242
headingLevel: CardHeadingLevel = 'h3';
4343

44+
@property({ type: String, attribute: 'it-class' })
45+
itClass: string | undefined;
46+
4447
@queryAssignedElements({ slot: 'title' })
4548
_titleElements!: HTMLElement[];
4649

@@ -157,7 +160,7 @@ export class ItCard extends BaseComponent {
157160
const hasTitleIcon = this._titleElements.some((el) => el.querySelector('.it-card-title-icon-wrapper') !== null);
158161
const isInline = this.variant.startsWith('inline');
159162

160-
const classes = this.composeClass('it-card', 'rounded', shadowClass, borderClass, {
163+
const classes = this.composeClass('it-card', 'rounded', shadowClass, borderClass, this.itClass, {
161164
'it-card-inline': isInline,
162165
'it-card-inline-reverse': this.variant.endsWith('reverse'),
163166
'it-card-inline-mini': this.variant.includes('mini'),

packages/card/stories/it-card.stories.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface CardProps {
1919
headingLevel?: CardHeadingLevel;
2020
shadow?: CardShadow;
2121
border?: '0';
22+
'it-class'?: string;
2223
}
2324

2425
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
@@ -74,6 +75,11 @@ const meta = {
7475
options: [undefined, '0'],
7576
description: 'Imposta il valore 0 per rimuovere il bordo della card.',
7677
},
78+
'it-class': {
79+
type: 'string',
80+
description:
81+
"Aggiunge classi custom alla card generata. Utile per impostare padding custom all'interno della Card.",
82+
},
7783
// scrollLimit: {
7884
// name: 'scroll-limit',
7985
// control: 'number',
@@ -131,6 +137,7 @@ export const EsempioInterattivo: Story = {
131137
heading-level=${ifDefined(args.headingLevel)}
132138
shadow=${ifDefined(args.shadow)}
133139
border=${ifDefined(args.border)}
140+
it-class=${ifDefined(args['it-class'])}
134141
>
135142
<a slot="title" href="#">Titolo del contenuto</a>
136143
<figure slot="image" class="figure img-full">

packages/hero/stories/it-hero.stories.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export const ConTestoEImmaginePrimaryFilter: Story = {
132132
render: (args) => renderComponent({ ...args, children: html`${exampleSlotImage}` }),
133133
};
134134

135-
// TODO: Sostituire in questo esempio, lhtml della card con il componente <it-card>
136135
export const OverlapContent: Story = {
137136
name: 'Con immagine e margine negativo per contenuti sovrapposti',
138137
args: { ...meta.args, overlap: true },
@@ -141,28 +140,25 @@ export const OverlapContent: Story = {
141140
<div class="container">
142141
<div class="row">
143142
<div class="col-12">
144-
<!-- <div class="col-12 col-lg-10 offset-lg-1"> e card-space nel wrapper>-->
145143
<div class="col-12 mb-3 mb-md-4">
146-
<!--start it-card-->
147-
<article class="it-card rounded shadow border px-5 py-4">
144+
<it-card shadow="md" it-class="px-5 py-4">
148145
<!--card first child is the title (link)-->
149-
<h3 class="it-card-title no_toc h4">Titolo del contenuto</h3>
146+
<h3 slot="title" class="h4">Titolo del contenuto</h3>
150147
<!--card body content-->
151-
<div class="it-card-body">
152-
<p class="it-card-text">
148+
<div slot="text">
149+
<p>
153150
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
154151
dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
155152
incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
156153
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
157154
</p>
158155
</div>
159-
<div class="it-card-footer border-0" aria-label="Link correlati:">
156+
<div slot="footer">
160157
<a href="#" class="it-card-link"
161158
>Scopri di più <span class="visually-hidden">su Titolo del contenuto</span></a
162159
>
163160
</div>
164-
</article>
165-
<!--end it-card-->
161+
</it-card>
166162
</div>
167163
</div>
168164
</div>

0 commit comments

Comments
 (0)