fix compilation and organize

This commit is contained in:
timurgordon
2024-10-07 17:28:39 +02:00
parent b252f4c42c
commit 40eae56e09
13 changed files with 292 additions and 196 deletions

View File

@@ -0,0 +1,29 @@
module carousel
pub const example_heroscript="
!!intro1.new name:'myintro'
!!intro1.myintro_add
title: 'Sepia'
description: '
Made for photographers, photo studios, design agencies.
Create your own unique and beautiful photography website!
'
subtitle: 'Photography Portfolio Theme'
background_image: 'assets/img/intro/intro-10.jpg'
button_primary_text: 'Buy It Now!'
button_primary_url: 'https://example.com/learn-more'
button_secondary_text: 'Discover More'
button_secondary_url: 'albums-grid-fluid-2.html'
!!intro1.myintro_add
title: 'Sepia 2'
description: 'Made for photographers 2, photo studios, design agencies.<br>Create your own unique and beautiful photography website!'
subtitle: 'Photography Portfolio Theme'
background_image: 'assets/img/intro/intro-10.jpg'
button_primary_text: 'Buy It Now!'
button_primary_url: 'https://example.com/learn-more'
button_secondary_text: 'Discover More'
button_secondary_url: 'albums-grid-fluid-2.html'
"

View File

@@ -0,0 +1,5 @@
module carousel
pub fn (carousel Carousel) html() string {
return $tmpl("templates/main.html")
}

View File

@@ -0,0 +1,24 @@
module carousel
@[heap]
pub struct Carousel {
pub mut:
items []Item
}
pub struct Item {
pub mut:
title string
subtitle string
description string
background_image string
button_primary Button
button_secondary Button
}
pub struct Button {
pub mut:
text string
url string
}

View File

@@ -0,0 +1,60 @@
module carousel
import freeflowuniverse.crystallib.core.playbook {PlayBook}
@[params]
pub struct PlayParams{
pub mut:
args map[string]string
defaults bool
}
//will have all the results, key is in this case intro1.${name}
//this allows us to feed e.g. markdown to all renderers and then we get the data filled in what is found on page
pub fn play(mut plbook PlayBook, params PlayParams) !map[string]Carousel{
mut result:=map[string]Carousel{}
if plbook.actions.len == 0 && params.defaults {
plbook = playbook.new(text: example_heroscript)!
}
actions0 := plbook.find(filter: 'intro1.new')!
for action0 in actions0{
mut p0 := action0.params
name := p0.get_default('name','default')!
key:="intro1.${name}"
carousel := play_carousel(mut plbook, name)!
println('carousel ${name}\n${carousel}')
result[key]=carousel
}
return result
}
pub fn play_carousel(mut plbook PlayBook, name string) !Carousel {
mut carousel := Carousel{}
// Process add_item actions
actions := plbook.find(filter: 'intro1.${name}_add')!
for action in actions {
mut p := action.params
item := Item{
title: p.get('title')!
subtitle: p.get('subtitle')!
description: p.get('description')!.replace("\n","<br>")
background_image: p.get('background_image')!
button_primary: Button{
text: p.get('button_primary_text')!
url: p.get('button_primary_url')!
}
button_secondary: Button{
text: p.get('button_secondary_text')!
url: p.get('button_secondary_url')!
}
}
carousel.items << item
}
return carousel
}

View File

@@ -0,0 +1,85 @@
<!-- Begin intro section -->
<section id="tt-intro" class="slideshow-intro">
<div class="tt-intro-inner"> <!-- add/remove class "tt-wrap" to enable/disable element boxed layout (class "tt-boxed" is required in <body> tag! ) -->
<div class="gl-carousel-wrap no-padding"> <!-- Optional: use class "no-padding" to disable paddings -->
<!-- Begin content carousel (https://owlcarousel2.github.io/OwlCarousel2/)
====================================================================
* Use class "nav-outside" for outside nav (requires boxed layout).
* Use class "nav-outside-top" for outside top nav (requires enough space at the top of the carousel).
* Use class "nav-bottom-right" for bottom right nav.
* Use class "nav-rounded" for rounded nav.
* Use class "nav-light" to enable nav light style.
* Use class "dots-outside" for outside dots (requires enough space at the bottom of the carousel).
* Use class "dots-left", "dots-right" or "dots-center-right" to align dots.
* Use class "dots-rounded" for rounded dots.
* Use class "owl-mousewheel" to enable mousewheel support.
* Use class "cursor-grab" to enable cursor grab icon (no effect on links!).
* Use class "cc-hover-light", "cc-hover-dark" or "cc-hover-zoom" to enable carousel items hover effect.
* Use class "cc-height-1", "cc-height-2", "cc-height-3", "cc-height-4", "cc-height-5", "cc-height-6" or "cc-height-full" to set carousel height (do not use with data-autoheight="true"!!!).
* Use class "cc-height-m" to set full height for small screens (do not use with data-autoheight="true"!!!).
================================================================
* Available carousel data attributes:
data-items="5".......................(items visible on desktop)
data-tablet-landscape="4"............(items visible on mobiles)
data-tablet-portrait="3".............(items visible on mobiles)
data-mobile-landscape="2"............(items visible on tablets)
data-mobile-portrait="1".............(items visible on tablets)
data-loop="true".....................(true/false)
data-margin="10".....................(space between items)
data-center="true"...................(true/false)
data-start-position="0"..............(item start position)
data-animate-in="fadeIn".............(fade-in animation)
data-animate-out="fadeOut"...........(fade-out animation)
data-mouse-drag="false"..............(true/false)
data-touch-drag="false"..............(true/false)
data-autoheight="true"...............(true/false)
data-autoplay="true".................(true/false)
data-autoplay-timeout="5000".........(milliseconds)
data-autoplay-hover-pause="true".....(true/false)
data-autoplay-speed="800"............(milliseconds)
data-drag-end-speed="800"............(milliseconds)
data-nav="true"......................(true/false)
data-nav-speed="800".................(milliseconds)
data-dots="false"....................(true/false)
data-dots-speed="800"................(milliseconds)
-->
<div class="owl-carousel cc-height-5 cursor-grab dots-right bg-dark" data-items="1" data-loop="true" data-nav="true" data-nav-speed="500" data-dots-speed="500" data-autoplay="true" data-autoplay-timeout="8000" data-autoplay-speed="500" data-autoplay-hover-pause="true">
@for item in carousel.items
<!-- Begin carousel item -->
<div class="cc-item">
<!-- Element cover -->
<span class="cover bg-transparent-3-dark"></span>
<!-- cc image -->
<div class="cc-image bg-image" style="background-image: url(@{item.background_image}); background-position: 50% 50%;"></div>
<!-- Begin intro caption
=========================
* Position classes: "top-left", "top-center", "top-right", "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right".
* Size classes: "intro-caption-xs", "intro-caption-sm", "intro-caption-lg", "intro-caption-xlg", "intro-caption-xxlg".
-->
<div class="intro-caption caption-animate intro-caption-xxlg center-left">
<h1 class="intro-title">@{item.title}</h1>
<h2 class="intro-subtitle">@{item.subtitle}</h2>
<p class="intro-description max-width-650">
@{item.description}
</p>
<div class="margin-top-30">
<a href="@{item.button_primary.url}" class="btn btn-primary margin-top-5 margin-right-10" target="_blank">@{item.button_primary.text}</a>
<a href="@{item.button_secondary.url}" class="btn btn-white-bordered margin-top-5">@{item.button_secondary.text}</a>
</div>
</div>
<!-- End intro caption -->
</div>
<!-- End carousel item -->
@end
</div>
<!-- End content carousel -->
</div> <!-- /.gl-carousel-wrap -->
</div> <!-- /.tt-intro-inner -->
</section>
<!-- End intro section -->