Skip to content

Commit 5080877

Browse files
authored
feat: configurable cols for feature-grid shortcode (#342)
* feat: configurable cols for feature-grid shortcode * chore: update css files * chore: add hextra prefix to cards css var * chore: rebuild css
1 parent 24fb13b commit 5080877

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed

assets/css/compiled/main.css

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,6 @@ video {
836836
-moz-appearance: none;
837837
appearance: none;
838838
}
839-
.hx-grid-cols-1 {
840-
grid-template-columns: repeat(1, minmax(0, 1fr));
841-
}
842839
.hx-flex-col {
843840
flex-direction: column;
844841
}
@@ -2227,7 +2224,7 @@ article details > summary::before {
22272224
background-color: hsl(var(--primary-hue) var(--primary-saturation) 32% / 0.1);
22282225
}
22292226
.hextra-cards {
2230-
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--rows))), 1fr));
2227+
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
22312228
}
22322229
.hextra-card img {
22332230
-webkit-user-select: none;
@@ -2552,6 +2549,11 @@ nav .search-wrapper {
25522549
--tw-bg-opacity: 0.8;
25532550
}
25542551
}
2552+
@media (min-width: 1024px) {
2553+
.hextra-feature-grid {
2554+
grid-template-columns: repeat(var(--hextra-feature-grid-cols), minmax(0, 1fr))
2555+
}
2556+
}
25552557
html {
25562558
font-size: 1rem;
25572559
-webkit-font-smoothing: antialiased;
@@ -3381,6 +3383,12 @@ body {
33813383
transform: translate3d(0,-100%,0);
33823384
}
33833385
}
3386+
@media not all and (min-width: 640px) {
3387+
3388+
.max-sm\:hx-grid-cols-1 {
3389+
grid-template-columns: repeat(1, minmax(0, 1fr));
3390+
}
3391+
}
33843392
@media (min-width: 640px) {
33853393

33863394
.sm\:hx-block {
@@ -3395,17 +3403,20 @@ body {
33953403
width: 110%;
33963404
}
33973405

3398-
.sm\:hx-grid-cols-2 {
3399-
grid-template-columns: repeat(2, minmax(0, 1fr));
3400-
}
3401-
34023406
.sm\:hx-items-start {
34033407
align-items: flex-start;
34043408
}
34053409

34063410
.sm\:hx-text-xl {
34073411
font-size: 1.25rem;
34083412
}
3413+
3414+
@media not all and (min-width: 1024px) {
3415+
3416+
.sm\:max-lg\:hx-grid-cols-2 {
3417+
grid-template-columns: repeat(2, minmax(0, 1fr));
3418+
}
3419+
}
34093420
}
34103421
@media (min-width: 768px) {
34113422

@@ -3482,12 +3493,6 @@ body {
34823493
right: auto;
34833494
}
34843495
}
3485-
@media (min-width: 1024px) {
3486-
3487-
.lg\:hx-grid-cols-3 {
3488-
grid-template-columns: repeat(3, minmax(0, 1fr));
3489-
}
3490-
}
34913496
@media (min-width: 1280px) {
34923497

34933498
.xl\:hx-block {

assets/css/components/cards.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.hextra-cards {
2-
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--rows))), 1fr));
2+
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
33
}
44

55
.hextra-card img {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.hextra-feature-grid {
2+
@media (min-width: 1024px) {
3+
grid-template-columns: repeat(var(--hextra-feature-grid-cols), minmax(0, 1fr));
4+
}
5+
}

assets/css/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@import "components/navbar.css";
1010
@import "components/scrollbar.css";
1111
@import "components/code-copy.css";
12+
@import "components/hextra/feature-grid.css";
1213

1314
html {
1415
@apply hx-text-base hx-antialiased;

exampleSite/hugo_stats.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
"hextra-code-copy-btn",
217217
"hextra-code-copy-btn-container",
218218
"hextra-feature-card",
219+
"hextra-feature-grid",
219220
"hextra-filetree",
220221
"hextra-filetree-folder",
221222
"hextra-footer",
@@ -303,7 +304,6 @@
303304
"hx-gap-x-1.5",
304305
"hx-gap-y-2",
305306
"hx-grid",
306-
"hx-grid-cols-1",
307307
"hx-group",
308308
"hx-group/code",
309309
"hx-group/copybtn",
@@ -509,7 +509,6 @@
509509
"language-options",
510510
"language-switcher",
511511
"last-of-type:hx-mb-0",
512-
"lg:hx-grid-cols-3",
513512
"lntable",
514513
"lntd",
515514
"ltr:before:hx-left-0",
@@ -539,6 +538,7 @@
539538
"max-md:[transform:translate3d(0,-100%,0)]",
540539
"max-md:hx-hidden",
541540
"max-md:hx-min-h-[340px]",
541+
"max-sm:hx-grid-cols-1",
542542
"max-xl:hx-hidden",
543543
"md:hx-aspect-[1.1/1]",
544544
"md:hx-h-[calc(100vh-var(--navbar-height)-var(--menu-height))]",
@@ -596,10 +596,10 @@
596596
"sidebar-container",
597597
"sm:hx-block",
598598
"sm:hx-flex",
599-
"sm:hx-grid-cols-2",
600599
"sm:hx-items-start",
601600
"sm:hx-text-xl",
602601
"sm:hx-w-[110%]",
602+
"sm:max-lg:hx-grid-cols-2",
603603
"steps",
604604
"subheading-anchor",
605605
"success-icon",

layouts/shortcodes/cards.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{{ $rows := .Get "rows" | default "3" }}
1+
{{- $cols := .Get "cols" | default 3 -}}
22

3-
<div class="hextra-cards hx-mt-4 hx-gap-4 hx-grid not-prose" style="--rows: {{ $rows }};">
3+
<div class="hextra-cards hx-mt-4 hx-gap-4 hx-grid not-prose" style="--hextra-cards-grid-cols: {{ $cols }};">
44
{{- .Inner -}}
55
</div>
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
{{- $style := .Get "style" -}}
1+
{{- $cols := .Get "cols" | default 3 -}}
2+
{{- $style := .Get "style" | default "" -}}
3+
4+
{{- $css := printf "--hextra-feature-grid-cols: %v; %s" $cols $style -}}
25

36

47
<div
5-
class="hx-grid sm:hx-grid-cols-2 lg:hx-grid-cols-3 hx-grid-cols-1 hx-gap-4 hx-w-full not-prose"
6-
{{ with $style }}style="{{ . | safeCSS }}"{{ end }}
8+
class="hextra-feature-grid hx-grid sm:max-lg:hx-grid-cols-2 max-sm:hx-grid-cols-1 hx-gap-4 hx-w-full not-prose"
9+
{{ with $css }}style="{{ . | safeCSS }}"{{ end }}
710
>
811
{{ .Inner }}
912
</div>

0 commit comments

Comments
 (0)