1+ create table if not exists tab_example_cards as
2+ select ' Leaf' as title, ' Leaf_1_web' as img, ' f4' as prefix, ' green' as color union all
3+ select ' Caterpillar' , ' Caterpillar_of_box_tree_moth%2C_Germany_2019' , ' a9' , ' green' union all
4+ select ' Butterfly' , ' Common_brimstone_butterfly_(Gonepteryx_rhamni)_male' , ' 6a' , ' green' union all
5+ select ' Flower' , ' Red-poppy-flower_-_West_Virginia_-_ForestWander' , ' fd' , ' red' union all
6+ select ' Bird' , ' Summer_tanager_(Piranga_rubra)_male_Copan_3' , ' dd' , ' red' union all
7+ select ' Medusa' , ' Aurelia_aurita_2' , ' 5c' , ' blue' ;
8+
9+ select ' tab' as component, true as center;
10+ select ' Show all cards' as title, ' All things are beautiful' as description, ' ?' as link, $tab is null as active;
11+ select format(' Show %s cards' , color) as title,
12+ format(' %s things are beautiful' , color) as description,
13+ format(' ?tab=%s' , color) as link,
14+ $tab= color as active,
15+ case $tab when color then color end as color -- only show the color when the tab is active
16+ from tab_example_cards
17+ group by color;
18+
19+
20+ select ' card' as component;
21+ select title,
22+ format(' https://upload.wikimedia.org/wikipedia/commons/thumb/%s/%s/%s.jpg/640px-%s.jpg' , substr(prefix,1 ,1 ), prefix, img, img) as top_image,
23+ color
24+ from tab_example_cards
25+ where $tab is null or $tab = color;
26+
27+ select ' text' as component, ' See [source code on GitHub](https://github.com/lovasoa/SQLpage/blob/main/examples/official-site/examples/tabs.sql)' as contents_md;
0 commit comments