MkShowcase
Node for showing a html-based image grid.¶
Description
Manages row / column positioning. Mainly intended for MkCards, but can also include other markdown (there are limits though.) When adding MkCards, then addtional CSS is required.
Example: From TOML format¶
Jinja
Python
<div class="row">
<div class="column">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Some title 1" style="width:200px,height:200px">
<div class="overlay">Some **markdown**</div>
</div>
<p>
<button>Some title 1</button>
</p>
</div>
</div>
<div class="column">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/301" alt="Some title 2" style="width:200px,height:200px">
<div class="overlay">Some **markdown**</div>
</div>
<p>
<button>Some title 2</button>
</p>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Some title 1" style="width:200px,height:200px">
<div class="overlay">Some **markdown**</div>
</div>
<p>
<button>Some title 1</button>
</p>
</div>
</div>
<div class="column">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/301" alt="Some title 2" style="width:200px,height:200px">
<div class="overlay">Some **markdown**</div>
</div>
<p>
<button>Some title 2</button>
</p>
</div>
</div>
</div>
Example: Manual¶
Jinja
{% set url = "https://phil65.github.io/mknodes/" %}
{% set img_url = "https://picsum.photos/300" %}
{{ ["Title 0" | MkCard(target=url, image=img_url, caption="Caption 0"),
"Title 1" | MkCard(target=url, image=img_url, caption="Caption 1"),
"Title 2" | MkCard(target=url, image=img_url, caption="Caption 2"),
"Title 3" | MkCard(target=url, image=img_url, caption="Caption 3"),
"Title 4" | MkCard(target=url, image=img_url, caption="Caption 4"),
"Title 5" | MkCard(target=url, image=img_url, caption="Caption 5")] | MkShowcase }}
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 0" style="width:200px,height:200px">
<div class="overlay">Caption 0</div>
</div>
<p>
<button>Title 0</button>
</p>
</div>
</a>
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 1" style="width:200px,height:200px">
<div class="overlay">Caption 1</div>
</div>
<p>
<button>Title 1</button>
</p>
</div>
</a>
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 2" style="width:200px,height:200px">
<div class="overlay">Caption 2</div>
</div>
<p>
<button>Title 2</button>
</p>
</div>
</a>
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 3" style="width:200px,height:200px">
<div class="overlay">Caption 3</div>
</div>
<p>
<button>Title 3</button>
</p>
</div>
</a>
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 4" style="width:200px,height:200px">
<div class="overlay">Caption 4</div>
</div>
<p>
<button>Title 4</button>
</p>
</div>
</a>
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 5" style="width:200px,height:200px">
<div class="overlay">Caption 5</div>
</div>
<p>
<button>Title 5</button>
</p>
</div>
</a>
<div class="row">
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 0" style="width:200px,height:200px">
<div class="overlay">Caption 0</div>
</div>
<p>
<button>Title 0</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 1" style="width:200px,height:200px">
<div class="overlay">Caption 1</div>
</div>
<p>
<button>Title 1</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 2" style="width:200px,height:200px">
<div class="overlay">Caption 2</div>
</div>
<p>
<button>Title 2</button>
</p>
</div>
</a>
</div>
</div><div class="row">
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 3" style="width:200px,height:200px">
<div class="overlay">Caption 3</div>
</div>
<p>
<button>Title 3</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 4" style="width:200px,height:200px">
<div class="overlay">Caption 4</div>
</div>
<p>
<button>Title 4</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 5" style="width:200px,height:200px">
<div class="overlay">Caption 5</div>
</div>
<p>
<button>Title 5</button>
</p>
</div>
</a>
</div>
</div>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 0" style="width:200px,height:200px">
<div class="overlay">Caption 0</div>
</div>
<p>
<button>Title 0</button>
</p>
</div>
<p></a></p>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 1" style="width:200px,height:200px">
<div class="overlay">Caption 1</div>
</div>
<p>
<button>Title 1</button>
</p>
</div>
<p></a></p>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 2" style="width:200px,height:200px">
<div class="overlay">Caption 2</div>
</div>
<p>
<button>Title 2</button>
</p>
</div>
<p></a></p>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 3" style="width:200px,height:200px">
<div class="overlay">Caption 3</div>
</div>
<p>
<button>Title 3</button>
</p>
</div>
<p></a></p>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 4" style="width:200px,height:200px">
<div class="overlay">Caption 4</div>
</div>
<p>
<button>Title 4</button>
</p>
</div>
<p></a></p>
<p><a href="https://phil65.github.io/mknodes/"></p>
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 5" style="width:200px,height:200px">
<div class="overlay">Caption 5</div>
</div>
<p>
<button>Title 5</button>
</p>
</div>
<p></a></p>
<div class="row">
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 0" style="width:200px,height:200px">
<div class="overlay">Caption 0</div>
</div>
<p>
<button>Title 0</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 1" style="width:200px,height:200px">
<div class="overlay">Caption 1</div>
</div>
<p>
<button>Title 1</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 2" style="width:200px,height:200px">
<div class="overlay">Caption 2</div>
</div>
<p>
<button>Title 2</button>
</p>
</div>
</a>
</div>
</div>
<div class="row">
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 3" style="width:200px,height:200px">
<div class="overlay">Caption 3</div>
</div>
<p>
<button>Title 3</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 4" style="width:200px,height:200px">
<div class="overlay">Caption 4</div>
</div>
<p>
<button>Title 4</button>
</p>
</div>
</a>
</div>
<div class="column">
<a href="https://phil65.github.io/mknodes/">
<div class="card">
<div class="showcase-container">
<img src="https://picsum.photos/300" alt="Title 5" style="width:200px,height:200px">
<div class="overlay">Caption 5</div>
</div>
<p>
<button>Title 5</button>
</p>
</div>
</a>
</div>
</div>
MkContainer
╰── MkCard('Title 0', 'https://picsum.photos/300', caption='Caption 0', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 1', 'https://picsum.photos/300', caption='Caption 1', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 2', 'https://picsum.photos/300', caption='Caption 2', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 3', 'https://picsum.photos/300', caption='Caption 3', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 4', 'https://picsum.photos/300', caption='Caption 4', target='https://phil65.github.io/mknodes/')
├── MkCard('Title 5', 'https://picsum.photos/300', caption='Caption 5', target='https://phil65.github.io/mknodes/')
╰── MkShowcase([MkCard('Title 0', 'https://p...//phil65.github.io/mknodes/'), MkCard('Title 1', 'https://p...//phil65.github.io/mknodes/'), MkCard('Title 2', 'https://p...//phil65.github.io/mknodes/'), MkCard('Title 3', 'https://p...//phil65.github.io/mknodes/'), MkCard('Title 4', 'https://p...//phil65.github.io/mknodes/'), MkCard('Title 5', 'https://p...//phil65.github.io/mknodes/')])
╰── MkCard('Title 0', 'https://picsum.photos/300', caption='Caption 0', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 1', 'https://picsum.photos/300', caption='Caption 1', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 2', 'https://picsum.photos/300', caption='Caption 2', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 3', 'https://picsum.photos/300', caption='Caption 3', target='https://phil65.github.io/mknodes/')
╰── MkCard('Title 4', 'https://picsum.photos/300', caption='Caption 4', target='https://phil65.github.io/mknodes/')
├── MkCard('Title 5', 'https://picsum.photos/300', caption='Caption 5', target='https://phil65.github.io/mknodes/')
Name | Children | Inherits |
---|---|---|
MkContainer mknodes.basenodes.mkcontainer A node containing other MkNodes. |
graph TD
94721306002384["mkshowcase.MkShowcase"]
94721311697232["mkcontainer.MkContainer"]
94721308848336["mknode.MkNode"]
94721311766592["node.Node"]
140564252373184["builtins.object"]
94721311697232 --> 94721306002384
94721308848336 --> 94721311697232
94721311766592 --> 94721308848336
140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mkshowcase/metadata.toml
[metadata]
icon = "mdi:view-grid"
name = "MkShowcase"
[examples.toml]
title = "From TOML format"
jinja = """
{{
'
["Card 1"]
title = "Some title 1"
image = "https://picsum.photos/300"
caption = "Some **markdown**"
["Card 2"]
title = "Some title 2"
image = "https://picsum.photos/301"
caption = "Some **markdown**"
' | load_toml | MkShowcase
}}
"""
[examples.cards]
title = "Manual"
python = """
import mknodes as mk
node = mk.MkShowcase()
for i in range(6):
node.add_card(
target="https://phil65.github.io/mknodes/",
title=f"Title {i}",
image="https://picsum.photos/300",
caption=f"Caption {i}",
)
node
"""
jinja = """
{% set url = "https://phil65.github.io/mknodes/" %}
{% set img_url = "https://picsum.photos/300" %}
{{ ["Title 0" | MkCard(target=url, image=img_url, caption="Caption 0"),
"Title 1" | MkCard(target=url, image=img_url, caption="Caption 1"),
"Title 2" | MkCard(target=url, image=img_url, caption="Caption 2"),
"Title 3" | MkCard(target=url, image=img_url, caption="Caption 3"),
"Title 4" | MkCard(target=url, image=img_url, caption="Caption 4"),
"Title 5" | MkCard(target=url, image=img_url, caption="Caption 5")] | MkShowcase }}
"""
[output.markdown]
template = """
{% for items in node.items | batch(node.column_count) %}
<div class="row">
{% for item in items %}
<div class="column">
{{ item | string | indent(first=True) }} </div>
{% endfor %}
</div>{% endfor %}
"""