Add icon tiles grid component
This commit is contained in:
parent
10258ad41e
commit
82b62a52e9
59
src/back/jdd-components/icon-tiles-grid/icon-tiles-grid.css
Normal file
59
src/back/jdd-components/icon-tiles-grid/icon-tiles-grid.css
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
.icon-tiles-grid {
|
||||||
|
container-type: inline-size;
|
||||||
|
|
||||||
|
&.icon-tiles-grid--bleed {
|
||||||
|
grid-column: bleed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-tiles-grid__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
width: max-content;
|
||||||
|
max-width: 100cqw;
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
|
@container (max-width: 900px) {
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@container (max-width: 600px) {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-tiles-grid__tile {
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 40px;
|
||||||
|
background-color: var(--tile-bg-color);
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: subgrid;
|
||||||
|
grid-row: span 3;
|
||||||
|
flex-flow: column;
|
||||||
|
gap: 32px;
|
||||||
|
min-height: 320px;
|
||||||
|
max-width: 400px;
|
||||||
|
|
||||||
|
&,
|
||||||
|
* {
|
||||||
|
color: var(--tile-fg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
|
||||||
|
* {
|
||||||
|
fill: var(--tile-fg-color) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
font-size: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
import { TempstreamJSX } from "tempstream";
|
||||||
|
import type { ComponentToHTMLArgs } from "@sealcode/jdd";
|
||||||
|
import { Component, ComponentArguments as Args, insert_nbsp } from "@sealcode/jdd";
|
||||||
|
import { getAllIconNames, icon } from "src/back/icons.js";
|
||||||
|
import { getColorVariables, getFgColorVariable } from "src/back/colors.js";
|
||||||
|
|
||||||
|
const component_arguments = {
|
||||||
|
title: new Args.ShortText(),
|
||||||
|
description: new Args.Markdown(),
|
||||||
|
bleed: new Args.Boolean(),
|
||||||
|
tiles: new Args.List(
|
||||||
|
new Args.Structured({
|
||||||
|
icon: new Args.Enum(getAllIconNames),
|
||||||
|
color: new Args.Enum(async () =>
|
||||||
|
getColorVariables().filter(
|
||||||
|
(e) => !e.includes("text") && !e.includes("link")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
name: new Args.ShortText(),
|
||||||
|
description: new Args.ShortText(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export class IconTilesGrid extends Component<typeof component_arguments> {
|
||||||
|
getArguments() {
|
||||||
|
return component_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
async toHTML({
|
||||||
|
args: { title, description, tiles, bleed },
|
||||||
|
classes,
|
||||||
|
jdd_context: { render_markdown, language },
|
||||||
|
}: ComponentToHTMLArgs<typeof component_arguments>): Promise<string> {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
class={[
|
||||||
|
"icon-tiles-grid",
|
||||||
|
{ "icon-tiles-grid--bleed": bleed },
|
||||||
|
...classes,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<h2>{title} • IconTilesGrid </h2>
|
||||||
|
<div>{render_markdown(language, description)}</div>
|
||||||
|
<section class="icon-tiles-grid__grid">
|
||||||
|
{tiles.map((tile) => (
|
||||||
|
<div
|
||||||
|
class="icon-tiles-grid__tile"
|
||||||
|
style={`--tile-bg-color: var(${tile.color}); --tile-fg-color: var(${getFgColorVariable(tile.color, 4.2)})`}
|
||||||
|
>
|
||||||
|
<div class="icon">{icon(tile.icon)}</div>
|
||||||
|
<div class="name">{insert_nbsp(tile.name)}</div>
|
||||||
|
<div class="description">{insert_nbsp(tile.name)}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user