diff --git a/web/components/carousel/example.v b/web/components/carousel/example.v new file mode 100644 index 0000000..f4216db --- /dev/null +++ b/web/components/carousel/example.v @@ -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.
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' +" \ No newline at end of file diff --git a/web/components/carousel/html.v b/web/components/carousel/html.v new file mode 100644 index 0000000..0e95401 --- /dev/null +++ b/web/components/carousel/html.v @@ -0,0 +1,5 @@ +module carousel + +pub fn (carousel Carousel) html() string { + return $tmpl("templates/main.html") +} \ No newline at end of file diff --git a/web/components/carousel/model.v b/web/components/carousel/model.v new file mode 100644 index 0000000..568cb91 --- /dev/null +++ b/web/components/carousel/model.v @@ -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 +} + diff --git a/web/components/carousel/play.v b/web/components/carousel/play.v new file mode 100644 index 0000000..040f339 --- /dev/null +++ b/web/components/carousel/play.v @@ -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","
") + 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 +} \ No newline at end of file diff --git a/web/components/intro/templates/main.html b/web/components/carousel/templates/main.html similarity index 98% rename from web/components/intro/templates/main.html rename to web/components/carousel/templates/main.html index 38094c9..3c064cb 100644 --- a/web/components/intro/templates/main.html +++ b/web/components/carousel/templates/main.html @@ -45,7 +45,7 @@ data-dots-speed="800"................(milliseconds) -->