Skip to content

Commit 18271d1

Browse files
committed
Cards: Removed showAsSingleRow option
1 parent 19c0abd commit 18271d1

File tree

3 files changed

+4
-52
lines changed

3 files changed

+4
-52
lines changed

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,14 @@ To support customization, there are also some params you can add to the shortcod
3939
* `isFullSize` (optional) - Boolean indicating whether or not the card should be full size. By default, cards are half sized.
4040
* Usage: `<card isFullSize="true"...>`
4141

42-
For the `<card-section>`, there are some params you can add such as `title`, `isFeaturedSection`, and `showAsSingleRow`.
42+
For the `<card-section>`, there are some params you can add such as `title` and `isFeaturedSection`.
4343
* `title` - Title of the section.
4444
<br>
4545
* `isFeaturedSection` (optional) - Boolean indicating whether or not the section is a featured one - will discuss later down the page. By default, false.
46-
<br>
47-
* `showAsSingleRow` (optional) - Boolean indicating whether or not the cards in the section should appear without borders + one card per row. By default, false.
4846

4947
### Additional Information
5048
While it may come immediate, you can't use a `<card>` shortcode on its own in your markdown or else the build will fail. This is because if you call a card, there is no way to structure it in a writer-friendly customizable way.
5149

52-
## Show as single row
53-
As you can see from the above example in 'General usage', it renders as a block with borders, aka a card. To change the appearance and render without the borders and move to one card per row, use the param `showAsSingleRow` in the shortcode `<card-section>`. The usage as seen below:
54-
```plaintext
55-
<card-section showAsSingleRow="true">
56-
<card title="SOME_TITLE">SOME CONTENT icon="SOME_LUCIDE_ICON">SOME CONTENT<\card>
57-
...
58-
<card>...<\card>
59-
</card-section>
60-
```
61-
and will render as the following:
62-
<div data-testid="cards-test__showAsSingleRow">
63-
{{<card-section showAsSingleRow="true">}}
64-
{{<card title="SOME_TITLE_1">}}
65-
SOME CONTENT 1
66-
{{</card >}}
67-
{{<card title="SOME_TITLE_2">}}
68-
SOME CONTENT 2
69-
{{</card >}}
70-
{{</card-section>}}
71-
</div>
72-
7350
## Featured Section
7451
Denoted by the param `isFeaturedSection` in the shortcode `<card-section>`, this block of cards can contain only up to three cards. The usage as seen below:
7552
```plaintext
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
{{ $title := .Get "title" }}
22
{{ $isFeaturedSectionParam := .Get "isFeaturedSection" | default "false" }}
3-
{{ $showAsSingleRowParam := .Get "showAsSingleRow" | default "false"}}
43

5-
{{- /* Validate the parameter strictly */ -}}
6-
{{- if not (in (slice "true" "false") $showAsSingleRowParam) -}}
7-
{{- warnf "The '<card-section>' Shortcode parameter 'showAsSingleRow' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsSingleRowParam -}}
8-
{{- end -}}
9-
{{- $showAsSingleRow := cond (eq $showAsSingleRowParam "true") "true" "false" -}}
10-
{{- $current := .Page.Scratch.Get "showAsSingleRow" | default (dict) -}}
11-
{{- $newShowAsSingleRow := dict ($title | default "main") ($showAsSingleRow) -}}
12-
{{- .Page.Scratch.Set "showAsSingleRow" (merge $current ($newShowAsSingleRow)) -}}
134
{{- /* Limit the cards if it is a featured section */ -}}
145
{{- if not (in (slice "true" "false") $isFeaturedSectionParam) -}}
156
{{- warnf "The '<card-section>' Shortcode parameter 'isFeaturedSection' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isFeaturedSectionParam -}}
167
{{- end -}}
178
{{- $isFeaturedSection := cond (eq $isFeaturedSectionParam "true") "true" "false" -}}
18-
{{- $class := "card-grid" -}}
9+
{{- $class := "card-section-content card-grid" -}}
1910

2011
{{- /* Get number of cards */ -}}
2112
{{ $cardCount := len (findRE "<div\\s+class=\"card\"[\\s\\S]*?>" .Inner) }}
22-
2313
<div class="card-section{{if eq $isFeaturedSection "true"}} featured-section{{ end }}" data-testid="{{if eq $isFeaturedSection "true"}}card-section__featured-section{{else}}card-section{{ end }}">
2414
{{- if $title -}}
2515
<strong class="card-section-title">{{- $title -}}</strong>
26-
<div class="card-section-content{{ if eq $showAsSingleRow "false" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsSingleRow "false" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{ .Inner }}</div>
16+
<div class="{{ $class }}" data-testid="card-section-content__card-grid">{{ .Inner }}</div>
2717
{{ else }}
28-
<div class="card-section-content{{ if eq $showAsSingleRow "false" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsSingleRow "false" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{ .Inner }}</div>
18+
<div class="{{ $class }}" data-testid="card-section-content__card-grid">{{ .Inner }}</div>
2919
{{ end }}
3020
</div>

tests/src/cards.spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ test.describe('Testing for cards shortcode', () => {
1111
const showAsCardCode = await section.locator(
1212
'data-testid=card-section-content'
1313
);
14-
const basicCode = await section.locator(
15-
'data-testid=card-section-content__card-grid'
16-
);
17-
18-
expect(await showAsCardCode.count()).toBe(0);
19-
expect(await basicCode.count()).toBeTruthy();
20-
});
21-
22-
test('should test showAsSingleRow section', async ({ page }) => {
23-
const section = await page.locator(
24-
'data-testid=cards-test__showAsSingleRow'
25-
);
26-
const showAsCardCode = await section.locator(
27-
'data-testid=card-section-content__card-grid'
28-
);
2914

3015
expect(await showAsCardCode.count()).toBe(0);
3116
});

0 commit comments

Comments
 (0)