Skip to content

Commit

Permalink
feat: add navigation button size
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaraRMA committed Feb 26, 2024
1 parent 1dec40c commit 9e17961
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export namespace Components {
"freeMode"?: boolean;
"loop"?: boolean;
"navigation"?: boolean;
"navigationButtonSize"?: 'medium' | 'xxlarge';
"pagination"?: boolean;
"paginationClickable"?: boolean;
"paginationType"?: PaginationOptions['type'] | 'thumbnails';
Expand Down Expand Up @@ -503,6 +504,7 @@ declare namespace LocalJSX {
"freeMode"?: boolean;
"loop"?: boolean;
"navigation"?: boolean;
"navigationButtonSize"?: 'medium' | 'xxlarge';
"onAtomChange"?: (event: AtomCarouselCustomEvent<string>) => void;
"onAtomClickNext"?: (event: AtomCarouselCustomEvent<string>) => void;
"onAtomClickPrev"?: (event: AtomCarouselCustomEvent<string>) => void;
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/components/carousel/carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

::part(button-prev),
::part(button-next) {
background: var(--color-neutral-white);
border: 1px solid transparent;
background: var(--color-brand-secondary-regular);
border-radius: var(--border-radius-full);
box-shadow: var(--elevation-3);
color: var(--color-brand-secondary-regular);
height: var(--spacing-medium);
color: var(--color-neutral-white);
padding: var(--spacing-small);
transition:
border var(--transition-duration),
box-shadow var(--transition-duration),
opacity var(--transition-duration);
width: var(--spacing-medium);
will-change: border, box-shadow;

&:hover {
border-color: var(--color-brand-secondary-regular);
background: var(--color-brand-secondary-light-1);
}
}

Expand Down
20 changes: 12 additions & 8 deletions packages/core/src/components/carousel/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
Prop,
h,
} from '@stencil/core'
import 'swiper/swiper-element-bundle.js'
import { register } from 'swiper/element/bundle'
import { AutoplayOptions, PaginationOptions, Swiper } from 'swiper/types'
register()

import { renderThumbs } from './utils/render-thumbs'

Expand Down Expand Up @@ -59,12 +60,8 @@ export class AtomCarousel {
thumbnailImages?: string = ''
@Prop({ mutable: true })
videoIcons?: boolean = false

// If you need more info please read the ADR 0012 at Caveat sections
private injectStyles = [
'.swiper-button-disabled { opacity: 0 !important}',
'.swiper-pagination-custom { display: flex; justify-content: center; column-gap: var(--spacing-base); } ',
]
@Prop({ mutable: true })
navigationButtonSize?: 'medium' | 'xxlarge' = 'medium'

componentDidLoad() {
this.swiperEl = this.host.querySelector('swiper-container')
Expand Down Expand Up @@ -113,6 +110,13 @@ export class AtomCarousel {
Object.assign(this.swiperEl, params)
}
render() {
const injectStyles = [
'.swiper-button-disabled { opacity: 0 !important}',
'.swiper-pagination-custom { display: flex; justify-content: center; column-gap: var(--spacing-base); } ',
`.swiper-button-next { width: var(--spacing-${this.navigationButtonSize}); height: var(--spacing-${this.navigationButtonSize}); }`,
`.swiper-button-prev { width: var(--spacing-${this.navigationButtonSize}); height: var(--spacing-${this.navigationButtonSize}); }`,
]

return (
<Host>
<swiper-container
Expand All @@ -126,7 +130,7 @@ export class AtomCarousel {
free-mode={this.freeMode}
autoplay={this.autoplay}
autoplay-delay={this.autoplayDelay}
injectStyles={this.injectStyles}
injectStyles={injectStyles}
touch-start-prevent-default='false'
center-insufficient-slides={this.centerInsufficientSlides}
centered-slides={this.centeredSlides}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const createComponent = (args, itemClass: string) => {
: ''
}
${
args.navigationButtonSize !== undefined
? `navigationButtonSize="${args.navigationButtonSize}"`
: ''
}
${args.loop !== undefined ? `loop="${args.loop}"` : ''}
${args.autoplay !== undefined ? `autoplay="${args.autoplay}"` : ''}
${args.speed !== undefined ? `speed="${args.speed}"` : ''}
Expand Down

0 comments on commit 9e17961

Please sign in to comment.