From 774b25da72b8135c2e41e51bdda128045d58af92 Mon Sep 17 00:00:00 2001 From: Jon McClure Date: Tue, 29 Nov 2022 01:51:49 +0000 Subject: [PATCH] basic carousel --- package.json | 3 +- .../PhotoCarousel.stories.svelte | 82 +++++ .../PhotoCarousel/PhotoCarousel.svelte | 284 ++++++++++++++++++ .../PhotoCarousel/stories/docs/component.md | 21 ++ .../PhotoCarousel/stories/docs/withCustom.md | 27 ++ .../PhotoCarousel/stories/photos.json | 72 +++++ src/index.js | 1 + yarn.lock | 12 + 8 files changed, 501 insertions(+), 1 deletion(-) create mode 100644 src/components/PhotoCarousel/PhotoCarousel.stories.svelte create mode 100644 src/components/PhotoCarousel/PhotoCarousel.svelte create mode 100644 src/components/PhotoCarousel/stories/docs/component.md create mode 100644 src/components/PhotoCarousel/stories/docs/withCustom.md create mode 100644 src/components/PhotoCarousel/stories/photos.json diff --git a/package.json b/package.json index 7e837f5c..2b570c44 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "@fortawesome/free-brands-svg-icons": "^5.15.4", "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", + "@splidejs/svelte-splide": "^0.2.9", "@sveltejs/svelte-scroller": "^2.0.7", "bootstrap": "^5.2.0", "classnames": "^2.3.1", @@ -222,4 +223,4 @@ ".": "./dist/index.js" }, "svelte": "./dist/index.js" -} \ No newline at end of file +} diff --git a/src/components/PhotoCarousel/PhotoCarousel.stories.svelte b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte new file mode 100644 index 00000000..2a7ee363 --- /dev/null +++ b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte @@ -0,0 +1,82 @@ + + + + + + + + + + +

{credit}

+

{caption}

+
+
+ + diff --git a/src/components/PhotoCarousel/PhotoCarousel.svelte b/src/components/PhotoCarousel/PhotoCarousel.svelte new file mode 100644 index 00000000..47679958 --- /dev/null +++ b/src/components/PhotoCarousel/PhotoCarousel.svelte @@ -0,0 +1,284 @@ + + + + + + + + diff --git a/src/components/PhotoCarousel/stories/docs/component.md b/src/components/PhotoCarousel/stories/docs/component.md new file mode 100644 index 00000000..c85a042f --- /dev/null +++ b/src/components/PhotoCarousel/stories/docs/component.md @@ -0,0 +1,21 @@ +A simple, accessible photo carousel with lazy-loading and mobile swipe built in. + +```svelte + + + +``` diff --git a/src/components/PhotoCarousel/stories/docs/withCustom.md b/src/components/PhotoCarousel/stories/docs/withCustom.md new file mode 100644 index 00000000..849ee394 --- /dev/null +++ b/src/components/PhotoCarousel/stories/docs/withCustom.md @@ -0,0 +1,27 @@ +Use named slots to style your own custom credits and/or captions. + +```svelte + +

{credit}

+

{caption}

+
+ + +``` diff --git a/src/components/PhotoCarousel/stories/photos.json b/src/components/PhotoCarousel/stories/photos.json new file mode 100644 index 00000000..543f86d2 --- /dev/null +++ b/src/components/PhotoCarousel/stories/photos.json @@ -0,0 +1,72 @@ +[ + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T194630Z_544493697_UP1E.jpeg", + "caption": "Spain's Sergio Busquets and Aymeric Laporte react before a Germany goal is disallowed following a VAR review.", + "credit": "REUTERS/Molly Darlington" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T194619Z_2007900040_UP1.jpeg", + "caption": "Spain's Sergio Busquets fouls Germany's Jamal Musiala before being shown yellow card.", + "credit": "REUTERS/Kai Pfaffenbach" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T194619Z_635809122_UP1E.jpeg", + "caption": "Spain's Sergio Busquets is shown a yellow card by referee Danny Desmond Makkelie.", + "credit": "REUTERS/Albert Gea" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T191015Z_1293757566_UP1.jpeg", + "caption": "Spain's Sergio Busquets in action with Germany's Thomas Muller.", + "credit": "REUTERS/John Sibley" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T181411Z_1_MTZXEIBR0QNN.jpeg", + "caption": "Spain fans inside the stadium before the match.", + "credit": "REUTERS/Albert Gea" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T194827Z_345059331_UP1E.jpeg", + "caption": "Spain's Gavi.", + "credit": "REUTERS/Fabrizio Bensch" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T175149Z_1_MTZXEIBR0PMD.jpeg", + "caption": "", + "credit": "REUTERS/John Sibley" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T203232Z_890709671_UP1E.jpeg", + "caption": "Spain's Alvaro Morata scores their first goal.", + "credit": "REUTERS/Kai Pfaffenbach" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T203612Z_1399473226_UP1.jpeg", + "caption": "Spain's Alvaro Morata celebrates scoring their first goal.", + "credit": "REUTERS/Molly Darlington" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T204305Z_1795686896_UP1.jpeg", + "caption": "Germany's Niclas Fullkrug scores their first goal.", + "credit": "REUTERS/Molly Darlington" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T204528Z_151067034_UP1E.jpeg", + "caption": "Germany's Niclas Fullkrug celebrates scoring their first goal.", + "credit": "REUTERS/Molly Darlington" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T205041Z_2076149593_UP1.jpeg", + "caption": "Spain coach Luis Enrique.", + "credit": "REUTERS/John Sibley" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T205604Z_1468073277_UP1.jpeg", + "caption": "Germany's Manuel Neuer applauds fans after the match.", + "credit": "REUTERS/Kai Pfaffenbach" + }, + { + "src": "https://graphics.thomsonreuters.com/cdn/django-tools/media/graphics-gallery/galleries/world-cup-2022/spain-germany-11-27/2022-11-27T205854Z_408619749_UP1E.jpeg", + "caption": "Spain players applaud fans after the match.", + "credit": "REUTERS/Albert Gea" + } +] \ No newline at end of file diff --git a/src/index.js b/src/index.js index b77d3e76..01235f24 100644 --- a/src/index.js +++ b/src/index.js @@ -12,6 +12,7 @@ export { default as Headline } from './components/Headline/Headline.svelte'; export { default as Hero } from './components/Hero/Hero.svelte'; export { default as NoteText } from './components/NoteText/NoteText.svelte'; export { default as PaddingReset } from './components/PaddingReset/PaddingReset.svelte'; +export { default as PhotoCarousel } from './components/PhotoCarousel/PhotoCarousel.svelte'; export { default as PhotoPack } from './components/PhotoPack/PhotoPack.svelte'; export { default as PymChild } from './components/PymChild/PymChild.svelte'; export { pymChildStore } from './components/PymChild/stores.js'; diff --git a/yarn.lock b/yarn.lock index 3fa5a6a6..5d6b5a85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1526,6 +1526,18 @@ estree-walker "^2.0.1" picomatch "^2.2.2" +"@splidejs/splide@^4.1.3": + version "4.1.4" + resolved "https://registry.yarnpkg.com/@splidejs/splide/-/splide-4.1.4.tgz#02d029360569e7d75d28357a9727fc48322015a3" + integrity sha512-5I30evTJcAJQXt6vJ26g2xEkG+l1nXcpEw4xpKh0/FWQ8ozmAeTbtniVtVmz2sH1Es3vgfC4SS8B2X4o5JMptA== + +"@splidejs/svelte-splide@^0.2.9": + version "0.2.9" + resolved "https://registry.yarnpkg.com/@splidejs/svelte-splide/-/svelte-splide-0.2.9.tgz#35659e305da61c32e3d65878c37c50e02d9a1cba" + integrity sha512-04ekJnDIJKEAhklKQMhkg4Yx0Ihtkk18eA9JeHPON0lDTngQxlOYdEYTJWH2UON45VxmVqoLHv04I++JphO36w== + dependencies: + "@splidejs/splide" "^4.1.3" + "@storybook/addon-actions@6.5.9": version "6.5.9" resolved "https://registry.yarnpkg.com/@storybook/addon-actions/-/addon-actions-6.5.9.tgz#d50d65631403e1a5b680961429d9c0d7bd383e68"