Skip to content

Commit 8ab48af

Browse files
committed
Card: Fix issue with absolute url + icon path + reordered CSS
1 parent ed1e035 commit 8ab48af

File tree

4 files changed

+90
-67
lines changed

4 files changed

+90
-67
lines changed

assets/css/v2/style.css

Lines changed: 84 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,98 +1448,119 @@ h6:has(a):hover {
14481448
}
14491449

14501450
/* Landing page cards */
1451-
1452-
.homepage {
1453-
.card-grid {
1454-
grid-template-columns: 1fr;
1455-
1456-
@media (min-width: 70rem) {
1457-
grid-template-columns: repeat(12, 1fr);
1458-
}
1459-
}
1460-
1461-
.card-layout .card-grid .card {
1462-
padding: 1rem 2rem 2rem 2rem;
1463-
1464-
.lucide,
1465-
.card-brand-icon {
1466-
height: 40px;
1467-
width: auto;
1468-
}
1469-
}
1470-
}
1471-
14721451
.card-layout {
14731452
display: flex;
14741453
flex-direction: column;
14751454
gap: 1.5rem;
14761455

14771456
.card-section {
1478-
strong {
1479-
font-weight: 500;
1480-
font-size: var(--font-step-2);
1481-
display: block;
1482-
margin-bottom: 1rem;
1483-
}
1457+
display: flex;
1458+
flex-direction: column;
1459+
gap: 1.5rem;
14841460

14851461
&.featured-section {
14861462
/* Hide all the cards past 3 if it is a featured card section */
14871463
.card-section-content > *:nth-child(n + 4 of a.card) {
14881464
display: none;
14891465
}
14901466
}
1491-
}
1492-
1493-
.card {
1494-
color: oklch(var(--color-foreground));
1495-
text-decoration: none;
1496-
order: 2;
14971467

1498-
&.featured-card {
1499-
order: 1;
1468+
.card-section-title {
1469+
font-weight: 500;
1470+
font-size: var(--font-step-2);
1471+
display: block;
15001472
}
15011473

1502-
.card-container {
1474+
.card-section-content {
15031475
display: flex;
15041476
flex-direction: column;
1505-
gap: 0.5rem;
1506-
}
1507-
1508-
.card-header {
1509-
display: flex;
1510-
flex-direction: row;
15111477
gap: 1rem;
1512-
align-items: center;
1513-
color: oklch(var(--color-brand));
15141478

1515-
.card-brand-icon {
1516-
height: 20px;
1517-
width: auto;
1479+
&.card-grid {
1480+
display: grid;
1481+
grid-template-columns: repeat(var(--grid-columns), 1fr);
1482+
gap: 1.5rem;
1483+
1484+
@media (max-width: 55rem) {
1485+
grid-template-columns: 1fr;
1486+
}
1487+
1488+
.card {
1489+
border: 1px solid oklch(var(--color-codeblock-border));
1490+
box-shadow: 3px 3px 0px oklch(var(--color-shadow));
1491+
padding: 1rem;
1492+
order: 2;
1493+
1494+
&.featured-card {
1495+
order: 1;
1496+
}
1497+
}
15181498
}
15191499

1520-
h2 {
1521-
padding: 0;
1522-
margin: 0;
1523-
font-size: var(--font-step-1);
1500+
.card {
1501+
color: oklch(var(--color-foreground));
1502+
text-decoration: none;
1503+
1504+
.card-container {
1505+
display: flex;
1506+
flex-direction: column;
1507+
gap: 0.5rem;
1508+
}
1509+
1510+
.card-header {
1511+
display: flex;
1512+
flex-direction: row;
1513+
gap: 1rem;
1514+
align-items: center;
1515+
color: oklch(var(--color-brand));
1516+
1517+
img.card-brand-icon {
1518+
height: 1.5rem;
1519+
width: auto;
1520+
}
1521+
1522+
h2 {
1523+
padding: 0;
1524+
margin: 0;
1525+
font-size: var(--font-step-1);
1526+
}
1527+
}
15241528
}
15251529
}
15261530
}
15271531
}
15281532

1529-
/* Optional grid layout */
1530-
.card-grid {
1531-
display: grid;
1532-
grid-template-columns: repeat(var(--grid-columns), 1fr);
1533-
gap: 1.5rem;
1533+
.homepage .card-layout {
1534+
margin-bottom: 3rem;
1535+
gap: 3rem;
15341536

1535-
@media (max-width: 55rem) {
1536-
grid-template-columns: 1fr;
1537-
}
1537+
.card-section {
1538+
.card-section-content.card-grid {
1539+
grid-template-columns: 1fr;
15381540

1539-
.card {
1540-
border: 1px solid oklch(var(--color-codeblock-border));
1541-
box-shadow: 3px 3px 0px oklch(var(--color-shadow));
1542-
padding: 1rem;
1541+
@media (min-width: 70rem) {
1542+
grid-template-columns: repeat(12, 1fr);
1543+
grid-auto-rows: 1fr;
1544+
}
1545+
1546+
.card {
1547+
padding: 1rem 2rem 2rem 2rem;
1548+
1549+
.card-container {
1550+
height: 7rem;
1551+
justify-content: space-around;
1552+
1553+
.card-header {
1554+
justify-content: flex-start;
1555+
1556+
.card-brand-icon {
1557+
height: 40px;
1558+
width: auto;
1559+
}
1560+
}
1561+
}
1562+
}
1563+
}
15431564
}
15441565
}
15451566

exampleSite/content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Documentation for hugo theme
1010
{{<card title="Test Product" titleUrl="test-product/" icon="test-tubes" isLanding="true">}}
1111
See explanations and usages of shortcodes
1212
{{</card >}}
13-
{{<card title="NGINX Plus" titleUrl="nginx/" brandIcon="NGINX-Plus-product-icon-RGB" isLanding="true">}}
13+
{{<card title="NGINX Plus" titleUrl="nginx/" brandIcon="NGINX-Plus-product-icon-RGB.svg" isLanding="true">}}
1414
See a live example of theme components
1515
{{</card >}}
1616
{{</card-section>}}

layouts/shortcodes/card-section.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
{{- /* Validate that the parent is card-layout */ -}}
2424
{{ if eq .Parent.Name "card-layout"}}
25-
<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 }}">
25+
<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 }}">
2626
{{- if $title -}}
2727
<strong class="card-section-title">{{- $title -}}</strong>
2828
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsCards "true" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{ .Inner }}</div>

layouts/shortcodes/card.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
{{ end }}
3434

3535
{{- /* Build the url */ -}}
36+
{{ $url := printf "%s%s" .Page.Permalink $titleUrl }}
3637
{{ if eq (substr $titleUrl 0 1) "/" }}
3738
{{ $suggestedUrlFix := substr $titleUrl 1 }}
3839
{{ errorf "Please do not start the param 'titleUrl' with a forward slash. Got: '%s', use '%s' instead." $titleUrl $suggestedUrlFix }}
40+
{{ else if (strings.Contains $titleUrl "https") }}
41+
{{ $url = $titleUrl }}
3942
{{ end }}
40-
{{ $url := printf "%s%s" .Page.Permalink $titleUrl }}
4143

4244
{{- /* Validate that the parent is card-section and under 3 cards */ -}}
4345
{{- if (eq .Parent.Name "card-section") -}}
@@ -46,7 +48,7 @@
4648
{{- if $title -}}
4749
<div class="card-header">
4850
{{- if $brandIcon -}}
49-
<img class="card-brand-icon" src="/images/icons/{{ $brandIcon }}.svg">
51+
<img class="card-brand-icon" src="/images/icons/{{ $brandIcon }}">
5052
{{- else if $icon -}}
5153
{{ partial "lucide" (dict "context" . "icon" $icon) }}
5254
{{- end -}}

0 commit comments

Comments
 (0)