Skip to content

Commit 9820aeb

Browse files
authored
Card: Remove the isFeaturedCard param from Cards shortcode (#318)
1 parent 0cdadd7 commit 9820aeb

File tree

4 files changed

+3
-58
lines changed

4 files changed

+3
-58
lines changed

assets/css/v2/style.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,10 +1485,6 @@ h6:has(a):hover {
14851485
box-shadow: 3px 3px 0px oklch(var(--color-shadow));
14861486
padding: 1rem;
14871487
order: 2;
1488-
1489-
&.featured-card {
1490-
order: 1;
1491-
}
14921488
}
14931489
}
14941490

exampleSite/content/test-product/cards/permitted.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ and will render as the following:
2727
</div>
2828

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

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

@@ -96,25 +93,4 @@ Denoted by the param `isFeaturedSection` in the shortcode `<card-layout>`, this
9693
{{</card >}}
9794
{{</card-section>}}
9895
{{</card-layout >}}
99-
</div>
100-
101-
## Featured Card
102-
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.
103-
<div data-testid="cards-test__featuredCard">
104-
{{<card-layout >}}
105-
{{<card-section showAsCards="true">}}
106-
{{<card title="Everything" titleUrl="everything" icon="circle-dot-dashed">}}
107-
All shortcodes in one page.
108-
{{</card >}}
109-
{{<card title="Call Out usages" titleUrl="call-out/all-callouts/" icon="message-square">}}
110-
Examples for call-out shortcode
111-
{{</card >}}
112-
{{<card title="Code Block usages" titleUrl="code-blocks/code-blocks-highlighting/" icon="code" isFeaturedCard="true">}}
113-
Examples for codeblock shortcode
114-
{{</card >}}
115-
{{<card title="Code Block usages" titleUrl="code-blocks/code-blocks-highlighting/" icon="code">}}
116-
Examples for codeblock shortcode
117-
{{</card >}}
118-
{{</card-section>}}
119-
{{</card-layout >}}
12096
</div>

layouts/shortcodes/card.html

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
{{- $titleUrl := .Get "titleUrl" | default "." -}}
33
{{- $icon := .Get "icon" | default "book-open" -}}
44
{{- $brandIcon := .Get "brandIcon" -}}
5-
{{- $isFeaturedParam := .Get "isFeaturedCard" | default "false" }}
65
{{- $isFullSizeParam := .Get "isFullSize" | default "false" -}}
76
{{- $isLandingParam := .Get "isLanding" | default "false" }}
87

98
{{- /* Validate the parameter strictly */ -}}
10-
{{- if not (in (slice "true" "false") $isFeaturedParam) -}}
11-
{{- warnf "The '<card>' Shortcode parameter 'isFeaturedCard' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFeaturedParam -}}
12-
{{- end -}}
13-
{{- $isFeatured := cond (eq $isFeaturedParam "true") "true" "false" -}}
14-
159
{{- if not (in (slice "true" "false") $isFullSizeParam) -}}
1610
{{- warnf "The '<card>' Shortcode parameter 'isFullSize' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFullSizeParam -}}
1711
{{- end -}}
@@ -24,7 +18,7 @@
2418

2519
{{- /* Set up the positioning */ -}}
2620
{{ $dataGrid := "" }}
27-
{{ if or (eq $isFullSize "true") (eq $isFeatured "true") }}
21+
{{ if eq $isFullSize "true" }}
2822
{{ $dataGrid = "wide"}}
2923
{{ else if (eq $isLanding "true") }}
3024
{{ $dataGrid = "third"}}
@@ -42,7 +36,7 @@
4236

4337
{{- /* Validate that the parent is card-section and under 3 cards */ -}}
4438
{{- if (eq .Parent.Name "card-section") -}}
45-
<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 }}">
39+
<a href="{{- $url -}}" alt="{{- $title -}}" class="card" data-grid="{{ $dataGrid }}" data-testid="card">
4640
<div class="card-container">
4741
{{- if $title -}}
4842
<div class="card-header">

tests/src/cards.spec.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,4 @@ test.describe('Testing for cards shortcode', () => {
4747
}
4848
expect(visibleCards.length).toBeLessThanOrEqual(3);
4949
});
50-
51-
test('should test featured card', async ({ page }) => {
52-
const section = await page.locator('data-testid=cards-test__featuredCard');
53-
const featuredCard = await section.locator(
54-
'data-testid=card__featured-card'
55-
);
56-
const cards = await (await section.locator('data-testid=card')).all();
57-
const featuredCardOrder = await featuredCard.evaluate((el) => {
58-
return window.getComputedStyle(el).getPropertyValue('order');
59-
});
60-
61-
// Test featured card exist AND is the first one in the order
62-
expect(await featuredCard.count()).toBeTruthy();
63-
expect(featuredCardOrder).toBe('1');
64-
for (const card of cards) {
65-
const order = await card.evaluate((el) => {
66-
return window.getComputedStyle(el).getPropertyValue('order');
67-
});
68-
expect(order).toBe('2');
69-
}
70-
});
7150
});

0 commit comments

Comments
 (0)