Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions assets/css/v2/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,6 @@ h6:has(a):hover {
box-shadow: 3px 3px 0px oklch(var(--color-shadow));
padding: 1rem;
order: 2;

&.featured-card {
order: 1;
}
}
}

Expand Down
26 changes: 1 addition & 25 deletions exampleSite/content/test-product/cards/permitted.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ and will render as the following:
</div>

### Params
To support customization, there are also some params you can add to the shortcode `<card>` such as `title`, `titleUrl`, `icon`, `brandIcon`, `isFeaturedCard`, `isFullSize`.
To support customization, there are also some params you can add to the shortcode `<card>` such as `title`, `titleUrl`, `icon`, `brandIcon`, `isFullSize`.

* `title` (required) - Title of the card.
<br>
Expand All @@ -38,9 +38,6 @@ To support customization, there are also some params you can add to the shortcod
* `brandIcon` (optional) - Custom icon using image from `nginx-hugo-theme/static/images/icons`.
* Usage: `<card brandIcon="NGINX-App-Protect-WAF-product-icon"...>`
<br>
* `isFeaturedCard` (optional) - Boolean indicating whether or not the card should be the first one and full size. By default, false.
* Usage: `<card isFeaturedCard="true"...>`
<br>
* `isFullSize` (optional) - Boolean indicating whether or not the card should be full size. By default, cards are half sized.
* Usage: `<card isFullSize="true"...>`

Expand Down Expand Up @@ -96,25 +93,4 @@ Denoted by the param `isFeaturedSection` in the shortcode `<card-layout>`, this
{{</card >}}
{{</card-section>}}
{{</card-layout >}}
</div>

## Featured Card
Denoted by the param `isFeaturedCard` in the shortcode `<card>`, this will push the card up to very top of the section and make it full length.
<div data-testid="cards-test__featuredCard">
{{<card-layout >}}
{{<card-section showAsCards="true">}}
{{<card title="Everything" titleUrl="everything" icon="circle-dot-dashed">}}
All shortcodes in one page.
{{</card >}}
{{<card title="Call Out usages" titleUrl="call-out/all-callouts/" icon="message-square">}}
Examples for call-out shortcode
{{</card >}}
{{<card title="Code Block usages" titleUrl="code-blocks/code-blocks-highlighting/" icon="code" isFeaturedCard="true">}}
Examples for codeblock shortcode
{{</card >}}
{{<card title="Code Block usages" titleUrl="code-blocks/code-blocks-highlighting/" icon="code">}}
Examples for codeblock shortcode
{{</card >}}
{{</card-section>}}
{{</card-layout >}}
</div>
10 changes: 2 additions & 8 deletions layouts/shortcodes/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
{{- $titleUrl := .Get "titleUrl" | default "." -}}
{{- $icon := .Get "icon" | default "book-open" -}}
{{- $brandIcon := .Get "brandIcon" -}}
{{- $isFeaturedParam := .Get "isFeaturedCard" | default "false" }}
{{- $isFullSizeParam := .Get "isFullSize" | default "false" -}}
{{- $isLandingParam := .Get "isLanding" | default "false" }}

{{- /* Validate the parameter strictly */ -}}
{{- if not (in (slice "true" "false") $isFeaturedParam) -}}
{{- warnf "The '<card>' Shortcode parameter 'isFeaturedCard' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFeaturedParam -}}
{{- end -}}
{{- $isFeatured := cond (eq $isFeaturedParam "true") "true" "false" -}}

{{- if not (in (slice "true" "false") $isFullSizeParam) -}}
{{- warnf "The '<card>' Shortcode parameter 'isFullSize' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFullSizeParam -}}
{{- end -}}
Expand All @@ -24,7 +18,7 @@

{{- /* Set up the positioning */ -}}
{{ $dataGrid := "" }}
{{ if or (eq $isFullSize "true") (eq $isFeatured "true") }}
{{ if eq $isFullSize "true" }}
{{ $dataGrid = "wide"}}
{{ else if (eq $isLanding "true") }}
{{ $dataGrid = "third"}}
Expand All @@ -42,7 +36,7 @@

{{- /* Validate that the parent is card-section and under 3 cards */ -}}
{{- if (eq .Parent.Name "card-section") -}}
<a href="{{- $url -}}" alt="{{- $title -}}" class="card{{ if eq $isFeatured "true" }} featured-card{{ end }}" data-grid="{{ $dataGrid }}" data-testid="{{ if eq $isFeatured "true" }}card__featured-card{{else}}card{{ end }}">
<a href="{{- $url -}}" alt="{{- $title -}}" class="card" data-grid="{{ $dataGrid }}" data-testid="card">
<div class="card-container">
{{- if $title -}}
<div class="card-header">
Expand Down
21 changes: 0 additions & 21 deletions tests/src/cards.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,4 @@ test.describe('Testing for cards shortcode', () => {
}
expect(visibleCards.length).toBeLessThanOrEqual(3);
});

test('should test featured card', async ({ page }) => {
const section = await page.locator('data-testid=cards-test__featuredCard');
const featuredCard = await section.locator(
'data-testid=card__featured-card'
);
const cards = await (await section.locator('data-testid=card')).all();
const featuredCardOrder = await featuredCard.evaluate((el) => {
return window.getComputedStyle(el).getPropertyValue('order');
});

// Test featured card exist AND is the first one in the order
expect(await featuredCard.count()).toBeTruthy();
expect(featuredCardOrder).toBe('1');
for (const card of cards) {
const order = await card.evaluate((el) => {
return window.getComputedStyle(el).getPropertyValue('order');
});
expect(order).toBe('2');
}
});
});