astro-swiper 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Pascal Brand
2
+ // MIT License
3
+
4
+ export * from "./src"
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "astro-swiper",
3
- "version": "0.0.1",
4
- "description": "Astro component for swiper",
3
+ "version": "0.1.0",
4
+ "description": "Astro component for swiper, dedicated to slider / carousel / photo swiper / slide",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/pascal-brand38/astro-swiper.git"
@@ -18,5 +15,18 @@
18
15
  "bugs": {
19
16
  "url": "https://github.com/pascal-brand38/astro-swiper/issues"
20
17
  },
21
- "homepage": "https://github.com/pascal-brand38/astro-swiper#readme"
18
+ "homepage": "https://github.com/pascal-brand38/astro-swiper#readme",
19
+ "exports": "./index.ts",
20
+ "files": [
21
+ "index.ts",
22
+ "src/**"
23
+ ],
24
+ "devDependencies": {
25
+ "@types/node": "^24.0.0",
26
+ "astro": "^5.9.2",
27
+ "typescript": "^5.8.3"
28
+ },
29
+ "dependencies": {
30
+ "swiper": "^11.2.8"
31
+ }
22
32
  }
@@ -0,0 +1,52 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { AstroSwiperType } from './index'
8
+
9
+ type Props = AstroSwiperType
10
+
11
+
12
+ const {
13
+ options={},
14
+ class: className = '',
15
+ ...props
16
+ } = Astro.props;
17
+
18
+ const swiperId = 'astro-swiper-' + Math.random().toString(36).slice(2, 11)
19
+
20
+ ---
21
+
22
+ <!-- Slider main container -->
23
+ <astro-swiper
24
+ class={`swiper ${swiperId} ${className}`}
25
+ {...props}
26
+ data-options={JSON.stringify(options)}
27
+ data-id={swiperId}>
28
+ <slot/>
29
+ </astro-swiper>
30
+
31
+
32
+ <script>
33
+ import Swiper from 'swiper/bundle'
34
+ import { register } from 'swiper/element/bundle';
35
+
36
+
37
+ class AstroSwiper extends HTMLElement {
38
+ constructor() {
39
+ super();
40
+ register();
41
+
42
+
43
+ // Read the message from the data attribute.
44
+ const options = JSON.parse(this.dataset.options || '')
45
+ const id = this.dataset.id // to have more than 1 swiper in a single page
46
+
47
+ const swiper = new Swiper(`.${id}`, options)
48
+ }
49
+ }
50
+
51
+ customElements.define('astro-swiper', AstroSwiper);
52
+ </script>
@@ -0,0 +1,24 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <!-- next button -->
20
+ <div
21
+ class={`swiper-button-next ${className}`}
22
+ {...props}>
23
+ <slot/>
24
+ </div>
@@ -0,0 +1,24 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <!-- prev button -->
20
+ <div
21
+ class={`swiper-button-prev ${className}`}
22
+ {...props}>
23
+ <slot/>
24
+ </div>
@@ -0,0 +1,23 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <div
20
+ class={`swiper-pagination ${className}`}
21
+ {...props}>
22
+ <slot/>
23
+ </div>
@@ -0,0 +1,23 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <div
20
+ class={`swiper-scrollbar ${className}`}
21
+ {...props}>
22
+ <slot/>
23
+ </div>
@@ -0,0 +1,24 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <!-- a single slide -->
20
+ <div
21
+ class={`swiper-slide ${className}`}
22
+ {...props}>
23
+ <slot/>
24
+ </div>
@@ -0,0 +1,24 @@
1
+ ---
2
+ // Copyright (c) Pascal Brand
3
+ // MIT License
4
+
5
+ import 'swiper/css/bundle'
6
+
7
+ import type { HTMLAttributes } from 'astro/types'
8
+
9
+ type Props = HTMLAttributes<"div">
10
+
11
+ const {
12
+ class: className = '',
13
+ ...props
14
+ } = Astro.props;
15
+
16
+
17
+ ---
18
+
19
+ <!-- Slider wrapper, containing all the slides -->
20
+ <div
21
+ class={`swiper-wrapper ${className}`}
22
+ {...props}>
23
+ <slot/>
24
+ </div>
package/src/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Pascal Brand
2
+ // MIT License
3
+
4
+ import type { SwiperOptions } from 'swiper/types'
5
+
6
+ import type { HTMLAttributes } from 'astro/types'
7
+
8
+ export interface AstroSwiperType extends HTMLAttributes<"div"> {
9
+ options?: SwiperOptions,
10
+ }
11
+
12
+ export { default as Swiper } from './components/Swiper.astro'
13
+ export { default as SwiperButtonNext } from './components/SwiperButtonNext.astro'
14
+ export { default as SwiperButtonPrev } from './components/SwiperButtonPrev.astro'
15
+ export { default as SwiperPagination } from './components/SwiperPagination.astro'
16
+ export { default as SwiperScrollbar } from './components/SwiperScrollbar.astro'
17
+ export { default as SwiperSlide } from './components/SwiperSlide.astro'
18
+ export { default as SwiperWrapper } from './components/SwiperWrapper.astro'