-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
505ff44
commit 3eaa617
Showing
37 changed files
with
522 additions
and
22 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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
packages/embla-carousel-docs/src/content/pages/get-started/ie11-support.md
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
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
103 changes: 103 additions & 0 deletions
103
packages/embla-carousel-docs/src/content/pages/get-started/svelte.md
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,103 @@ | ||
--- | ||
title: Svelte | ||
description: Learn how to setup Embla Carousel using Svelte. | ||
order: 3 | ||
date: 2021-02-21 | ||
--- | ||
|
||
# Svelte | ||
|
||
Start by installing the Embla Carousel **npm package** and add it to your dependencies. | ||
|
||
```shell | ||
npm install embla-carousel-svelte --save | ||
``` | ||
|
||
Embla Carousel provides the handy `emblaCarouselSvelte` action for seamless integration with Svelte. A minimal setup requires an **overflow wrapper** and a **scroll container**. Start by adding the following structure to your carousel: | ||
|
||
```html | ||
<script> | ||
import emblaCarouselSvelte from 'embla-carousel-svelte' | ||
</script> | ||
|
||
<div class="embla" use:emblaCarouselSvelte> | ||
<div class="embla__container"> | ||
<div class="embla__slide">Slide 1</div> | ||
<div class="embla__slide">Slide 2</div> | ||
<div class="embla__slide">Slide 3</div> | ||
</div> | ||
</div> | ||
``` | ||
|
||
## Styling the carousel | ||
|
||
The element with the classname `embla` is needed to cover the scroll overflow. Its child element with the `container` classname is the scroll body that scrolls the slides. Continue by adding the following **CSS** to these elements: | ||
|
||
```html | ||
<style> | ||
.embla { | ||
overflow: hidden; | ||
} | ||
.embla__container { | ||
display: flex; | ||
} | ||
.embla__slide { | ||
flex: 0 0 100%; | ||
} | ||
</style> | ||
``` | ||
|
||
## Accessing the carousel API | ||
|
||
The `emblaCarouselSvelte` action takes the Embla Carousel [options](/api/options/) as part of its parameter. Additionally, you can access the [API](/api/) by using the `init` event to store the carousel instance in a variable: | ||
|
||
```html{6-8, 10-13, 16} | ||
<script> | ||
import emblaCarouselSvelte from 'embla-carousel-svelte' | ||
let emblaApi | ||
const emblaConfig = { | ||
options: { loop: false }, | ||
} | ||
const onInit = (event) => { | ||
emblaApi = event.detail | ||
// Embla API is ready | ||
} | ||
</script> | ||
<div class="embla" use:emblaCarouselSvelte={emblaConfig} on:init={onInit}> | ||
<div class="embla__container"> | ||
<div class="embla__slide">Slide 1</div> | ||
<div class="embla__slide">Slide 2</div> | ||
<div class="embla__slide">Slide 3</div> | ||
</div> | ||
</div> | ||
``` | ||
|
||
## Adding plugins | ||
|
||
The `emblaCarouselSvelte` action parameter also accepts [plugins](/plugins/). Note that plugins need to be passed in an array like so: | ||
|
||
```html{3, 7} | ||
<script> | ||
import emblaCarouselSvelte from 'embla-carousel-svelte' | ||
import Autoplay from 'embla-carousel-autoplay' | ||
const emblaConfig = { | ||
options: { loop: false }, | ||
plugins: [Autoplay()], | ||
} | ||
</script> | ||
<div class="embla" use:emblaCarouselSvelte={emblaConfig}> | ||
<div class="embla__container"> | ||
<div class="embla__slide">Slide 1</div> | ||
<div class="embla__slide">Slide 2</div> | ||
<div class="embla__slide">Slide 3</div> | ||
</div> | ||
</div> | ||
``` | ||
|
||
Congratulations! You just created your first Embla Carousel component. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,5 @@ | ||
docs | ||
package.json | ||
package-lock.json | ||
yarn.lock | ||
node_modules |
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,20 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { jsx: true }, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:prettier/recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
rules: { | ||
'no-debugger': 2, | ||
'no-console': 2, | ||
'@typescript-eslint/no-inferrable-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
} |
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 @@ | ||
module.exports = require('../../.prettierrc.js') |
Oops, something went wrong.