-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jakob Engelbrecht <[email protected]>
- Loading branch information
1 parent
ca6bdc2
commit dc2fdf2
Showing
20 changed files
with
896 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...pp/examples/slides-example/slides-advanced-example/slides-advanced-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<kirby-slides | ||
[slidesOptions]="config" | ||
[slides]="slides" | ||
[showNavigation]="true" | ||
[title]="'Title'" | ||
(slideChange)="getDataFromActiveSlide($event)" | ||
#slidesInstance | ||
> | ||
<kirby-card *kirbySlide="let slide; let i = index" [hasPadding]="true"> | ||
<kirby-card-header [title]="slide.title" [subtitle]="slide.subtitle"></kirby-card-header> | ||
<div>{{ slide.cardContent }}</div> | ||
</kirby-card> | ||
<button kirby-button attentionLevel="3" size="xs" (click)="showAll()">See all</button> | ||
</kirby-slides> | ||
|
||
<button | ||
kirby-button | ||
(click)="slidesInstance.slideTo(3)" | ||
style="display: block; margin: 24px auto 0" | ||
> | ||
Activate slide no. 4 | ||
</button> |
46 changes: 46 additions & 0 deletions
46
.../app/examples/slides-example/slides-advanced-example/slides-advanced-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component } from '@angular/core'; | ||
import { KirbySwiperOptions, SelectedSlide } from '@kirbydesign/designsystem/slide'; | ||
import { ToastConfig, ToastController } from '@kirbydesign/designsystem/toast'; | ||
|
||
@Component({ | ||
styleUrls: ['../slides-example.shared.scss'], | ||
templateUrl: './slides-advanced-example.component.html', | ||
}) | ||
export class SlidesAdvancedExampleComponent { | ||
constructor(private toastController: ToastController) {} | ||
|
||
config: KirbySwiperOptions = { | ||
slidesPerView: 1.1, | ||
breakpoints: { | ||
768: { | ||
centeredSlides: false, | ||
slidesPerView: 2, | ||
slidesPerGroup: 1, | ||
}, | ||
}, | ||
}; | ||
|
||
slides = [...Array(9).keys()].map((number) => ({ | ||
title: `Slide ${number + 1}`, | ||
subtitle: `Subtitle ${number + 1}`, | ||
cardContent: `Lorem ipsum dolor sit amet consectetur adipisicing elit.`, | ||
})); | ||
|
||
getDataFromActiveSlide(selectedSlide: SelectedSlide) { | ||
const config: ToastConfig = { | ||
message: `Changed to ${selectedSlide.slide.title}`, | ||
messageType: 'success', | ||
durationInMs: 1000, | ||
}; | ||
this.toastController.showToast(config); | ||
} | ||
|
||
showAll() { | ||
const config: ToastConfig = { | ||
message: `See all... (your handler here)`, | ||
messageType: 'success', | ||
durationInMs: 2000, | ||
}; | ||
this.toastController.showToast(config); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
apps/cookbook/src/app/examples/slides-example/slides-code-snippets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { DesignTokenHelper } from '@kirbydesign/designsystem/helpers'; | ||
|
||
const desktopBreakpoint = parseInt(DesignTokenHelper.breakpoints.medium) - 1; | ||
const spaceBetween = parseInt(DesignTokenHelper.size('s')); | ||
const transitionDuration = parseInt(DesignTokenHelper.transitionDuration('long')); | ||
|
||
export const slidesDefaultConfig = `defaultConfig: KirbySwiperOptions = { | ||
centeredSlides: true, | ||
centeredSlidesBounds: true, | ||
slidesPerView: 1.2, | ||
slidesPerGroup: 1, | ||
breakpoints: { | ||
${desktopBreakpoint}: { | ||
centeredSlides: false, | ||
slidesPerView: 3, | ||
slidesPerGroup: 3, | ||
}, | ||
}, | ||
spaceBetween: ${spaceBetween}, | ||
speed: ${transitionDuration}, | ||
pagination: { | ||
el: '.pagination', | ||
type: 'bullets', | ||
}, | ||
navigation: { | ||
nextEl: '.swiper-button-prev', | ||
prevEl: '.swiper-button-next', | ||
}, | ||
on: { | ||
slideChange: (swiper) => { | ||
this.slideChange.emit({ | ||
slide: this.slides[swiper.activeIndex], | ||
index: swiper.activeIndex, | ||
}); | ||
}, | ||
}, | ||
};`; | ||
|
||
export const defaultExampleComponentHTML = `<kirby-slides [slides]="slides" [title]="'Title'" [showNavigation]="true"> | ||
<kirby-card *kirbySlide="let slide; let i = index" [hasPadding]="true"> | ||
<kirby-card-header [title]="slide.title" [subtitle]="slide.subtitle"></kirby-card-header> | ||
<div>{{ slide.cardContent }}</div> | ||
</kirby-card> | ||
</kirby-slides>`; | ||
|
||
export const advancedExampleComponentHTML = `<kirby-slides | ||
[slides]="slides" | ||
(slideChange)="getDataFromActiveSlide($event)" | ||
[slidesOptions]="customConfig" | ||
[showNavigation]="true" | ||
[title]="'Title'" | ||
#slidesInstance> | ||
<kirby-card *kirbySlide="let slide; let i = index" [hasPadding]="true"> | ||
<kirby-card-header [title]="slide.title" [subtitle]="slide.subtitle"></kirby-card-header> | ||
<div>{{ slide.cardContent }}</div> | ||
</kirby-card> | ||
<button kirby-button attentionLevel="3" size="xs" (click)="showAll()">See all</button> | ||
</kirby-slides> | ||
<button kirby-button (click)="slidesInstance.slideTo(3)" style="display: block; margin: 24px auto 0"> | ||
Activate slide no. 4 | ||
</button>`; | ||
|
||
export const customConfigExample = `customConfig: KirbySwiperOptions = { | ||
slidesPerView: 1.1, | ||
breakpoints: { | ||
768: { | ||
centeredSlides: false, | ||
slidesPerView: 2, | ||
slidesPerGroup: 1, | ||
}, | ||
}, | ||
};`; |
143 changes: 0 additions & 143 deletions
143
apps/cookbook/src/app/examples/slides-example/slides-example.component.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
apps/cookbook/src/app/examples/slides-example/slides-example.shared.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@use '@kirbydesign/core/src/scss/utils'; | ||
@use '../examples.shared'; | ||
|
||
:host { | ||
// We need to set these in the examples to ensure Slides on small screens | ||
// stretch to viewport edges, i.e. they are used to create negative margins | ||
// to counteract page padding (when used within kirby-page these vars are already set): | ||
--padding-start: #{utils.size('s')}; | ||
--padding-end: #{utils.size('s')}; | ||
} |
8 changes: 8 additions & 0 deletions
8
...rc/app/examples/slides-example/slides-simple-example/slides-simple-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<kirby-slides [slides]="slides" [title]="'Title'" [showNavigation]="true"> | ||
<kirby-card *kirbySlide="let slide; let i = index" [hasPadding]="true"> | ||
<kirby-card-header [title]="slide.title" [subtitle]="slide.subtitle"></kirby-card-header> | ||
<div class="card-content"> | ||
{{ slide.cardContent }} | ||
</div> | ||
</kirby-card> | ||
</kirby-slides> |
26 changes: 26 additions & 0 deletions
26
.../src/app/examples/slides-example/slides-simple-example/slides-simple-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component } from '@angular/core'; | ||
import { SelectedSlide } from '@kirbydesign/designsystem/slide'; | ||
import { ToastConfig, ToastController } from '@kirbydesign/designsystem/toast'; | ||
|
||
@Component({ | ||
styleUrls: ['../slides-example.shared.scss'], | ||
templateUrl: './slides-simple-example.component.html', | ||
}) | ||
export class SlidesSimpleExampleComponent { | ||
constructor(private toastController: ToastController) {} | ||
|
||
slides = [...Array(9).keys()].map((number) => ({ | ||
title: `Slide ${number + 1}`, | ||
subtitle: `Subtitle ${number + 1}`, | ||
cardContent: `Lorem ipsum dolor sit amet consectetur adipisicing elit.`, | ||
})); | ||
|
||
getDataFromActiveSlide(selectedSlide: SelectedSlide) { | ||
const config: ToastConfig = { | ||
message: `Changed to ${selectedSlide.slide.title}`, | ||
messageType: 'success', | ||
durationInMs: 1000, | ||
}; | ||
this.toastController.showToast(config); | ||
} | ||
} |
Oops, something went wrong.