Merge pull request #13 from vadimkorr/feature/#12_Add-style-prefixes

Feature/#12 Add style prefixes
This commit is contained in:
Vadim
2021-01-27 19:57:08 +03:00
committed by GitHub
4 changed files with 35 additions and 33 deletions

View File

@@ -1,5 +1,6 @@
<script> <script>
import { NEXT, PREV } from '../../direction' import { NEXT, PREV } from '../../direction'
/** /**
* Indicates direction of the arrow ('next', 'prev') * Indicates direction of the arrow ('next', 'prev')
*/ */
@@ -12,14 +13,14 @@
</script> </script>
<div <div
class="circle" class="sc-carousel-arrow__circle"
class:disabled class:sc-carousel-arrow__circle_disabled={disabled}
on:click on:click
> >
<i <i
class="arrow" class="sc-carousel-arrow__arrow"
class:next={direction === NEXT} class:sc-carousel-arrow__arrow-next={direction === NEXT}
class:prev={direction === PREV} class:sc-carousel-arrow__arrow-prev={direction === PREV}
></i> ></i>
</div> </div>
@@ -27,7 +28,7 @@
:root { :root {
--size: 2px --size: 2px
} }
.circle { .sc-carousel-arrow__circle {
width: 20px; width: 20px;
height: 20px; height: 20px;
border-radius: 50%; border-radius: 50%;
@@ -38,25 +39,25 @@
transition: opacity 100ms ease; transition: opacity 100ms ease;
cursor: pointer; cursor: pointer;
} }
.circle:hover { .sc-carousel-arrow__circle:hover {
opacity: 0.9; opacity: 0.9;
} }
.arrow { .sc-carousel-arrow__arrow {
border: solid #1e1e1e; border: solid #1e1e1e;
border-width: 0 var(--size) var(--size) 0; border-width: 0 var(--size) var(--size) 0;
padding: var(--size); padding: var(--size);
position: relative; position: relative;
} }
.next { .sc-carousel-arrow__arrow-next {
transform: rotate(-45deg); transform: rotate(-45deg);
left: calc(var(--size) / -2); left: calc(var(--size) / -2);
} }
.prev { .sc-carousel-arrow__arrow-prev {
transform: rotate(135deg); transform: rotate(135deg);
right: calc(var(--size) / -2); right: calc(var(--size) / -2);
} }
.disabled, .sc-carousel-arrow__circle_disabled,
.disabled:hover { .sc-carousel-arrow__circle_disabled:hover {
opacity: 0.5; opacity: 0.5;
} }
</style> </style>

View File

@@ -179,11 +179,11 @@
} }
</script> </script>
<div class="main-container"> <div class="sc-carousel__carousel-container">
<div class="carousel-container"> <div class="sc-carousel__content-container">
{#if arrows} {#if arrows}
<slot name="prev" {showPrevPage}> <slot name="prev" {showPrevPage}>
<div class="arrow-container"> <div class="sc-carousel__arrow-container">
<Arrow <Arrow
direction="prev" direction="prev"
disabled={!infinite && originalCurrentPageIndex === 0} disabled={!infinite && originalCurrentPageIndex === 0}
@@ -193,10 +193,11 @@
</slot> </slot>
{/if} {/if}
<div <div
class="content-container" class="sc-carousel__pages-window"
bind:this={pageWindowElement} bind:this={pageWindowElement}
> >
<div <div
class="sc-carousel__pages-container"
use:swipeable="{{ thresholdProvider: () => pageWidth/3 }}" use:swipeable="{{ thresholdProvider: () => pageWidth/3 }}"
on:start={handleSwipeStart} on:start={handleSwipeStart}
on:move={handleSwipeMove} on:move={handleSwipeMove}
@@ -213,7 +214,7 @@
</div> </div>
{#if arrows} {#if arrows}
<slot name="next" {showNextPage}> <slot name="next" {showNextPage}>
<div class="arrow-container"> <div class="sc-carousel__arrow-container">
<Arrow <Arrow
direction="next" direction="next"
disabled={!infinite && originalCurrentPageIndex === originalPagesCount - 1} disabled={!infinite && originalCurrentPageIndex === originalPagesCount - 1}
@@ -240,30 +241,30 @@
</div> </div>
<style> <style>
.main-container { .sc-carousel__carousel-container {
display: flex; display: flex;
width: 100%; width: 100%;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.carousel-container { .sc-carousel__content-container {
position: relative; position: relative;
display: flex; display: flex;
width: 100%; width: 100%;
} }
.content-container { .sc-carousel__pages-window {
flex: 1; flex: 1;
display: flex; display: flex;
overflow: hidden; overflow: hidden;
box-sizing: border-box; box-sizing: border-box;
} }
.content-container > div { .sc-carousel__pages-container {
width: 100%; width: 100%;
display: flex; /* to put child elements in one row */ display: flex; /* to put child elements in one row */
transition-timing-function: ease-in-out; transition-timing-function: ease-in-out;
transition-property: transform; transition-property: transform;
} }
.arrow-container { .sc-carousel__arrow-container {
padding: 5px; padding: 5px;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;

View File

@@ -20,10 +20,10 @@
} }
</script> </script>
<div class="main-container"> <div class="sc-carousel-dot__container">
<div <div
class="dot" class="sc-carousel-dot__dot"
class:current="{active}" class:sc-carousel-dot__dot_current={active}
style=" style="
height: {$size}px; height: {$size}px;
width: {$size}px; width: {$size}px;
@@ -33,14 +33,14 @@
</div> </div>
<style> <style>
.main-container { .sc-carousel-dot__container {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 16px; height: 16px;
width: 16px; width: 16px;
} }
.dot { .sc-carousel-dot__dot {
background-color: #5d5d5d; background-color: #5d5d5d;
border-radius: 50%; border-radius: 50%;
display: inline-block; display: inline-block;
@@ -48,10 +48,10 @@
cursor: pointer; cursor: pointer;
transition: opacity 100ms ease; transition: opacity 100ms ease;
} }
.dot:hover { .sc-carousel-dot__dot:hover {
opacity: 0.9; opacity: 0.9;
} }
.current { .sc-carousel-dot__dot_current {
opacity: 0.7; opacity: 0.7;
} }
</style> </style>

View File

@@ -19,9 +19,9 @@
} }
</script> </script>
<div class="main-container"> <div class="sc-carousel-dots__container">
{#each Array(pagesCount) as _, pageIndex (pageIndex)} {#each Array(pagesCount) as _, pageIndex (pageIndex)}
<div class="dot-container"> <div class="sc-carousel-dots__dot-container">
<Dot <Dot
active={currentPageIndex === pageIndex} active={currentPageIndex === pageIndex}
on:click={() => handleDotClick(pageIndex)} on:click={() => handleDotClick(pageIndex)}
@@ -34,11 +34,11 @@
:root { :root {
--dot-size: 10px; --dot-size: 10px;
} }
.main-container { .sc-carousel-dots__container {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.dot-container { .sc-carousel-dots__dot-container {
height: calc(var(--dot-size) + 10px); height: calc(var(--dot-size) + 10px);
width: calc(var(--dot-size) + 10x); width: calc(var(--dot-size) + 10x);
display: flex; display: flex;