From 3eaa6173e3574a65d949e459f47c533788962ae1 Mon Sep 17 00:00:00 2001
From: David Jerleke
diff --git a/packages/embla-carousel-auto-height/package.json b/packages/embla-carousel-auto-height/package.json index e832eb207..c9ff84258 100644 --- a/packages/embla-carousel-auto-height/package.json +++ b/packages/embla-carousel-auto-height/package.json @@ -22,7 +22,8 @@ "javascript", "typescript", "react", - "vue" + "vue", + "svelte" ], "unpkg": "embla-carousel-auto-height.umd.js", "main": "embla-carousel-auto-height.cjs.js", diff --git a/packages/embla-carousel-autoplay/README.md b/packages/embla-carousel-autoplay/README.md index 63295826b..4343850da 100644 --- a/packages/embla-carousel-autoplay/README.md +++ b/packages/embla-carousel-autoplay/README.md @@ -5,6 +5,8 @@
+diff --git a/packages/embla-carousel-autoplay/package.json b/packages/embla-carousel-autoplay/package.json index 95c251b66..6a46cd378 100644 --- a/packages/embla-carousel-autoplay/package.json +++ b/packages/embla-carousel-autoplay/package.json @@ -22,7 +22,8 @@ "javascript", "typescript", "react", - "vue" + "vue", + "svelte" ], "unpkg": "embla-carousel-autoplay.umd.js", "main": "embla-carousel-autoplay.cjs.js", diff --git a/packages/embla-carousel-class-names/README.md b/packages/embla-carousel-class-names/README.md index 712d92776..41a8e5bd9 100644 --- a/packages/embla-carousel-class-names/README.md +++ b/packages/embla-carousel-class-names/README.md @@ -5,6 +5,8 @@
+diff --git a/packages/embla-carousel-class-names/package.json b/packages/embla-carousel-class-names/package.json index f04de4afa..672f9ca1d 100644 --- a/packages/embla-carousel-class-names/package.json +++ b/packages/embla-carousel-class-names/package.json @@ -22,7 +22,8 @@ "javascript", "typescript", "react", - "vue" + "vue", + "svelte" ], "unpkg": "embla-carousel-class-names.umd.js", "main": "embla-carousel-class-names.cjs.js", diff --git a/packages/embla-carousel-docs/README.md b/packages/embla-carousel-docs/README.md index 5eb5b7b1b..89c10aad3 100644 --- a/packages/embla-carousel-docs/README.md +++ b/packages/embla-carousel-docs/README.md @@ -5,6 +5,8 @@
+diff --git a/packages/embla-carousel-docs/src/content/pages/api/options.md b/packages/embla-carousel-docs/src/content/pages/api/options.md index afa53a16c..a37df5d6e 100644 --- a/packages/embla-carousel-docs/src/content/pages/api/options.md +++ b/packages/embla-carousel-docs/src/content/pages/api/options.md @@ -175,6 +175,16 @@ import emblaCarouselVue from 'embla-carousel-vue' emblaCarouselVue.globalOptions = { loop: true } ``` +### Svelte global options + +**Svelte** users can set global options by assigning them to the `emblaCarouselSvelte` action: + +```js +import emblaCarouselSvelte from 'embla-carousel-svelte' + +emblaCarouselSvelte.globalOptions = { loop: true } +``` + Make sure to assign global options **before** initializing any carousel. You should **only assign it once**, because re-assigning global options can lead to confusing code and unexpected behaviour. ## Option priority diff --git a/packages/embla-carousel-docs/src/content/pages/get-started/cdn.md b/packages/embla-carousel-docs/src/content/pages/get-started/cdn.md index 413862e59..67d59113d 100644 --- a/packages/embla-carousel-docs/src/content/pages/get-started/cdn.md +++ b/packages/embla-carousel-docs/src/content/pages/get-started/cdn.md @@ -1,7 +1,7 @@ --- title: CDN description: Learn how to setup Embla Carousel using a CDN. -order: 4 +order: 5 date: 2021-02-21 --- @@ -39,7 +39,6 @@ The wrapping element with the classname `embla` is needed to cover the scroll ov display: flex; } .embla__slide { - position: relative; flex: 0 0 100%; } ``` diff --git a/packages/embla-carousel-docs/src/content/pages/get-started/ie11-support.md b/packages/embla-carousel-docs/src/content/pages/get-started/ie11-support.md index ed021850f..0f5c410f4 100644 --- a/packages/embla-carousel-docs/src/content/pages/get-started/ie11-support.md +++ b/packages/embla-carousel-docs/src/content/pages/get-started/ie11-support.md @@ -1,7 +1,7 @@ --- title: IE11 description: How to add Internet Explorer 11 support to Embla Carousel. -order: 4 +order: 6 date: 2021-02-21 --- diff --git a/packages/embla-carousel-docs/src/content/pages/get-started/module.md b/packages/embla-carousel-docs/src/content/pages/get-started/module.md index 9545415f9..de1fad90e 100644 --- a/packages/embla-carousel-docs/src/content/pages/get-started/module.md +++ b/packages/embla-carousel-docs/src/content/pages/get-started/module.md @@ -39,7 +39,6 @@ The wrapping element with the classname `embla` is needed to cover the scroll ov display: flex; } .embla__slide { - position: relative; flex: 0 0 100%; } ``` diff --git a/packages/embla-carousel-docs/src/content/pages/get-started/react.md b/packages/embla-carousel-docs/src/content/pages/get-started/react.md index 5165383c4..5b36b571e 100644 --- a/packages/embla-carousel-docs/src/content/pages/get-started/react.md +++ b/packages/embla-carousel-docs/src/content/pages/get-started/react.md @@ -48,7 +48,6 @@ The hook gives us a **ref** to attach to our wrapping element with the classname display: flex; } .embla__slide { - position: relative; flex: 0 0 100%; } ``` diff --git a/packages/embla-carousel-docs/src/content/pages/get-started/svelte.md b/packages/embla-carousel-docs/src/content/pages/get-started/svelte.md new file mode 100644 index 000000000..3f457e80b --- /dev/null +++ b/packages/embla-carousel-docs/src/content/pages/get-started/svelte.md @@ -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 + + +
diff --git a/packages/embla-carousel-react/package.json b/packages/embla-carousel-react/package.json
index b5a468ea1..690e5d8ba 100644
--- a/packages/embla-carousel-react/package.json
+++ b/packages/embla-carousel-react/package.json
@@ -22,7 +22,8 @@
"javascript",
"typescript",
"react",
- "vue"
+ "vue",
+ "svelte"
],
"unpkg": "embla-carousel-react.umd.js",
"main": "embla-carousel-react.cjs.js",
diff --git a/packages/embla-carousel-svelte/.eslintignore b/packages/embla-carousel-svelte/.eslintignore
new file mode 100644
index 000000000..f5efc98ab
--- /dev/null
+++ b/packages/embla-carousel-svelte/.eslintignore
@@ -0,0 +1,5 @@
+docs
+package.json
+package-lock.json
+yarn.lock
+node_modules
diff --git a/packages/embla-carousel-svelte/.eslintrc.js b/packages/embla-carousel-svelte/.eslintrc.js
new file mode 100644
index 000000000..1fc3eb041
--- /dev/null
+++ b/packages/embla-carousel-svelte/.eslintrc.js
@@ -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',
+ },
+}
diff --git a/packages/embla-carousel-svelte/.prettierrc.js b/packages/embla-carousel-svelte/.prettierrc.js
new file mode 100644
index 000000000..5100fc98a
--- /dev/null
+++ b/packages/embla-carousel-svelte/.prettierrc.js
@@ -0,0 +1 @@
+module.exports = require('../../.prettierrc.js')
diff --git a/packages/embla-carousel-svelte/README.md b/packages/embla-carousel-svelte/README.md
new file mode 100644
index 000000000..a8fff152d
--- /dev/null
+++ b/packages/embla-carousel-svelte/README.md
@@ -0,0 +1,69 @@
+
+
+ + +
+ ++ + + + + + +
+ + ++ The Svelte version of Embla Carousel. +
+ +
+
+ Installation
+
+
+
+ API Reference
+
+
+
+ Examples
+
+
+ Copyright © 2019-present, David Jerleke.
+ Embla is MIT licensed 💖.
+
+ · · · +
+ ++ Thanks BrowserStack. +
+ ++ + + +
diff --git a/packages/embla-carousel-svelte/jest.config.js b/packages/embla-carousel-svelte/jest.config.js new file mode 100644 index 000000000..161ccbc1f --- /dev/null +++ b/packages/embla-carousel-svelte/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + transform: { + '^.+\\.(t|j)sx?$': 'ts-jest', + }, + testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + testEnvironment: 'jsdom', +} diff --git a/packages/embla-carousel-svelte/package.json b/packages/embla-carousel-svelte/package.json new file mode 100644 index 000000000..a1fd2bbb3 --- /dev/null +++ b/packages/embla-carousel-svelte/package.json @@ -0,0 +1,66 @@ +{ + "name": "embla-carousel-svelte", + "version": "7.0.0-rc05", + "author": "David Jerleke", + "description": "A lightweight carousel library with fluid motion and great swipe precision", + "repository": { + "type": "git", + "url": "git+https://github.com/davidjerleke/embla-carousel" + }, + "bugs": { + "url": "https://github.com/davidjerleke/embla-carousel/issues" + }, + "homepage": "https://www.embla-carousel.com", + "license": "MIT", + "keywords": [ + "slider", + "carousel", + "slideshow", + "gallery", + "lightweight", + "touch", + "javascript", + "typescript", + "react", + "vue", + "svelte" + ], + "unpkg": "embla-carousel-svelte.umd.js", + "main": "embla-carousel-svelte.cjs.js", + "module": "embla-carousel-svelte.esm.js", + "browser": "embla-carousel-svelte.umd.js", + "types": "index.d.ts", + "sideEffects": false, + "files": [ + "embla-carousel-svelte*", + "components/**/*", + "index.d.ts" + ], + "scripts": { + "test": "echo \"Info: no tests specified\" && exit 0", + "build": "rollup -c", + "start": "rollup -c --watch", + "eslint:report": "eslint \"src/**/*.{js,tsx,ts}\"", + "eslint:fix": "eslint \"src/**/*.{js,tsx,ts}\" --fix" + }, + "devDependencies": { + "@types/jest": "^27.4.0", + "@typescript-eslint/eslint-plugin": "^5.10.2", + "@typescript-eslint/parser": "^5.10.2", + "eslint": "^8.8.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^4.0.0", + "jest": "^27.5.0", + "prettier": "2.5.1", + "rollup": "^2.68.0", + "svelte": "^3.49.0", + "ts-jest": "^27.1.3", + "typescript": "^4.5.5" + }, + "dependencies": { + "embla-carousel": "7.0.0-rc05" + }, + "peerDependencies": { + "svelte": "^3.49.0" + } +} diff --git a/packages/embla-carousel-svelte/rollup.config.js b/packages/embla-carousel-svelte/rollup.config.js new file mode 100644 index 000000000..6cf67f8a2 --- /dev/null +++ b/packages/embla-carousel-svelte/rollup.config.js @@ -0,0 +1,50 @@ +import packageJson from './package.json' +import { + CONFIG_BABEL, + CONFIG_TYPESCRIPT, + CONFIG_GLOBALS as CONFIG_GLOBALS_DEFAULT, + babel, + typescript, + resolve, + terser, + kebabToPascalCase, +} from '../../rollup.config' + +const CONFIG_GLOBALS = { + ...CONFIG_GLOBALS_DEFAULT, + react: 'React', +} + +export default [ + { + input: 'src/index.ts', + output: [ + { + file: `${packageJson.name}.cjs.js`, + format: 'cjs', + globals: CONFIG_GLOBALS, + strict: true, + sourcemap: true, + exports: 'auto', + }, + { + file: `${packageJson.name}.esm.js`, + format: 'esm', + globals: CONFIG_GLOBALS, + strict: true, + sourcemap: true, + }, + { + file: `${packageJson.name}.umd.js`, + format: 'umd', + globals: CONFIG_GLOBALS, + strict: true, + sourcemap: false, + name: kebabToPascalCase(packageJson.name), + plugins: [terser()], + }, + ], + plugins: [resolve(), typescript(CONFIG_TYPESCRIPT), babel(CONFIG_BABEL)], + external: Object.keys(CONFIG_GLOBALS), + }, +] diff --git a/packages/embla-carousel-svelte/src/components/index.ts b/packages/embla-carousel-svelte/src/components/index.ts new file mode 100644 index 000000000..86524f962 --- /dev/null +++ b/packages/embla-carousel-svelte/src/components/index.ts @@ -0,0 +1,62 @@ +import { ActionReturn } from 'svelte/action' +import { arePluginsEqual, canUseDOM } from './utils' +import EmblaCarousel, { + EmblaCarouselType, + EmblaOptionsType, + EmblaPluginType, +} from 'embla-carousel' + +type EmblaCarouselParameterType = { + options: EmblaOptionsType + plugins: EmblaPluginType[] +} + +export type EmblaCarouselSvelteType = ActionReturn
diff --git a/packages/embla-carousel-vue/package.json b/packages/embla-carousel-vue/package.json
index 091985dd6..a506510ca 100644
--- a/packages/embla-carousel-vue/package.json
+++ b/packages/embla-carousel-vue/package.json
@@ -22,7 +22,8 @@
"javascript",
"typescript",
"react",
- "vue"
+ "vue",
+ "svelte"
],
"unpkg": "embla-carousel-vue.umd.js",
"main": "embla-carousel-vue.cjs.js",
diff --git a/packages/embla-carousel-vue/src/components/index.ts b/packages/embla-carousel-vue/src/components/index.ts
index 79f6e0c3f..a47860f3a 100644
--- a/packages/embla-carousel-vue/src/components/index.ts
+++ b/packages/embla-carousel-vue/src/components/index.ts
@@ -19,17 +19,17 @@ function emblaCarouselVue(
const storedOptions = ref(isRef(options) ? options.value : options)
const storedPlugins = ref(isRef(plugins) ? plugins.value : plugins)
const emblaNode = ref
diff --git a/packages/embla-carousel/package.json b/packages/embla-carousel/package.json index 782626459..06a0dccd0 100644 --- a/packages/embla-carousel/package.json +++ b/packages/embla-carousel/package.json @@ -22,7 +22,8 @@ "javascript", "typescript", "react", - "vue" + "vue", + "svelte" ], "unpkg": "embla-carousel.umd.js", "main": "embla-carousel.cjs.js", diff --git a/yarn.lock b/yarn.lock index f6c47cd1a..97190d809 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8116,6 +8116,28 @@ __metadata: languageName: unknown linkType: soft +"embla-carousel-svelte@workspace:packages/embla-carousel-svelte": + version: 0.0.0-use.local + resolution: "embla-carousel-svelte@workspace:packages/embla-carousel-svelte" + dependencies: + "@types/jest": ^27.4.0 + "@typescript-eslint/eslint-plugin": ^5.10.2 + "@typescript-eslint/parser": ^5.10.2 + embla-carousel: 7.0.0-rc05 + eslint: ^8.8.0 + eslint-config-prettier: ^8.3.0 + eslint-plugin-prettier: ^4.0.0 + jest: ^27.5.0 + prettier: 2.5.1 + rollup: ^2.68.0 + svelte: ^3.49.0 + ts-jest: ^27.1.3 + typescript: ^4.5.5 + peerDependencies: + svelte: ^3.49.0 + languageName: unknown + linkType: soft + "embla-carousel-vue@workspace:packages/embla-carousel-vue": version: 0.0.0-use.local resolution: "embla-carousel-vue@workspace:packages/embla-carousel-vue" @@ -17902,6 +17924,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"svelte@npm:^3.49.0": + version: 3.49.0 + resolution: "svelte@npm:3.49.0" + checksum: 5b7cb8dbf6b6581b50fab1de63cbcb81816081a1240b03e234b299268fff2f3237bf8f92b683a848f95453353b5694dfe26fa05a55da185a4bb0cd8b80d87dd4 + languageName: node + linkType: hard + "svg-react-loader@npm:^0.4.6": version: 0.4.6 resolution: "svg-react-loader@npm:0.4.6"