Skip to content

Commit

Permalink
feat: configurable cols for feature-grid shortcode (#342)
Browse files Browse the repository at this point in the history
* feat: configurable cols for feature-grid shortcode

* chore: update css files

* chore: add hextra prefix to cards css var

* chore: rebuild css
  • Loading branch information
imfing authored Mar 31, 2024
1 parent 24fb13b commit 5080877
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
33 changes: 19 additions & 14 deletions assets/css/compiled/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,6 @@ video {
-moz-appearance: none;
appearance: none;
}
.hx-grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.hx-flex-col {
flex-direction: column;
}
Expand Down Expand Up @@ -2227,7 +2224,7 @@ article details > summary::before {
background-color: hsl(var(--primary-hue) var(--primary-saturation) 32% / 0.1);
}
.hextra-cards {
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--rows))), 1fr));
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
}
.hextra-card img {
-webkit-user-select: none;
Expand Down Expand Up @@ -2552,6 +2549,11 @@ nav .search-wrapper {
--tw-bg-opacity: 0.8;
}
}
@media (min-width: 1024px) {
.hextra-feature-grid {
grid-template-columns: repeat(var(--hextra-feature-grid-cols), minmax(0, 1fr))
}
}
html {
font-size: 1rem;
-webkit-font-smoothing: antialiased;
Expand Down Expand Up @@ -3381,6 +3383,12 @@ body {
transform: translate3d(0,-100%,0);
}
}
@media not all and (min-width: 640px) {

.max-sm\:hx-grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}
@media (min-width: 640px) {

.sm\:hx-block {
Expand All @@ -3395,17 +3403,20 @@ body {
width: 110%;
}

.sm\:hx-grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sm\:hx-items-start {
align-items: flex-start;
}

.sm\:hx-text-xl {
font-size: 1.25rem;
}

@media not all and (min-width: 1024px) {

.sm\:max-lg\:hx-grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
}
@media (min-width: 768px) {

Expand Down Expand Up @@ -3482,12 +3493,6 @@ body {
right: auto;
}
}
@media (min-width: 1024px) {

.lg\:hx-grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (min-width: 1280px) {

.xl\:hx-block {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/components/cards.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.hextra-cards {
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--rows))), 1fr));
grid-template-columns: repeat(auto-fill, minmax(max(250px, calc((100% - 1rem * 2) / var(--hextra-cards-grid-cols))), 1fr));
}

.hextra-card img {
Expand Down
5 changes: 5 additions & 0 deletions assets/css/components/hextra/feature-grid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.hextra-feature-grid {
@media (min-width: 1024px) {
grid-template-columns: repeat(var(--hextra-feature-grid-cols), minmax(0, 1fr));
}
}
1 change: 1 addition & 0 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import "components/navbar.css";
@import "components/scrollbar.css";
@import "components/code-copy.css";
@import "components/hextra/feature-grid.css";

html {
@apply hx-text-base hx-antialiased;
Expand Down
6 changes: 3 additions & 3 deletions exampleSite/hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"hextra-code-copy-btn",
"hextra-code-copy-btn-container",
"hextra-feature-card",
"hextra-feature-grid",
"hextra-filetree",
"hextra-filetree-folder",
"hextra-footer",
Expand Down Expand Up @@ -303,7 +304,6 @@
"hx-gap-x-1.5",
"hx-gap-y-2",
"hx-grid",
"hx-grid-cols-1",
"hx-group",
"hx-group/code",
"hx-group/copybtn",
Expand Down Expand Up @@ -509,7 +509,6 @@
"language-options",
"language-switcher",
"last-of-type:hx-mb-0",
"lg:hx-grid-cols-3",
"lntable",
"lntd",
"ltr:before:hx-left-0",
Expand Down Expand Up @@ -539,6 +538,7 @@
"max-md:[transform:translate3d(0,-100%,0)]",
"max-md:hx-hidden",
"max-md:hx-min-h-[340px]",
"max-sm:hx-grid-cols-1",
"max-xl:hx-hidden",
"md:hx-aspect-[1.1/1]",
"md:hx-h-[calc(100vh-var(--navbar-height)-var(--menu-height))]",
Expand Down Expand Up @@ -596,10 +596,10 @@
"sidebar-container",
"sm:hx-block",
"sm:hx-flex",
"sm:hx-grid-cols-2",
"sm:hx-items-start",
"sm:hx-text-xl",
"sm:hx-w-[110%]",
"sm:max-lg:hx-grid-cols-2",
"steps",
"subheading-anchor",
"success-icon",
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/cards.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ $rows := .Get "rows" | default "3" }}
{{- $cols := .Get "cols" | default 3 -}}

<div class="hextra-cards hx-mt-4 hx-gap-4 hx-grid not-prose" style="--rows: {{ $rows }};">
<div class="hextra-cards hx-mt-4 hx-gap-4 hx-grid not-prose" style="--hextra-cards-grid-cols: {{ $cols }};">
{{- .Inner -}}
</div>
9 changes: 6 additions & 3 deletions layouts/shortcodes/hextra/feature-grid.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{{- $style := .Get "style" -}}
{{- $cols := .Get "cols" | default 3 -}}
{{- $style := .Get "style" | default "" -}}

{{- $css := printf "--hextra-feature-grid-cols: %v; %s" $cols $style -}}


<div
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"
{{ with $style }}style="{{ . | safeCSS }}"{{ end }}
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"
{{ with $css }}style="{{ . | safeCSS }}"{{ end }}
>
{{ .Inner }}
</div>

0 comments on commit 5080877

Please sign in to comment.