Skip to content

Commit

Permalink
Update carousel support vue 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jambonnn committed Apr 2, 2021
0 parents commit 7e88a09
Show file tree
Hide file tree
Showing 27 changed files with 4,192 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
current node
last 2 versions and > 2%
ie > 10
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.DS_Store
node_modules
*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"insertPragma": false,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2021 - Jambon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
259 changes: 259 additions & 0 deletions README.md

Large diffs are not rendered by default.

237 changes: 237 additions & 0 deletions demo/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<template>
<div id="hero" style="margin-top: 50px; margin-bottom: 50px">
<h1 style="text-align: center">
Vue Concise Carousel is SSR and CSR friendly.
</h1>
<p class="action" style="text-align: center">
<a class="button" href="#install">GET STARTED</a>
<a
class="button white"
href="https://github.com/jambonn/vue-concise-carousel#readme"
>
GITHUB
</a>
</p>
<div id="example">
<carousel
:per-page-custom="[
[480, 1],
[768, 4],
]"
:center-mode="true"
:navigation-enabled="false"
>
<slide v-for="index in slideCount" :key="index">
<img
style="width: 100%"
src="https://via.placeholder.com/1080.png/09f/fff"
/>
</slide>
</carousel>
</div>
<div id="install" class="container">
<h2
id="installation"
style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em"
>
Installation
</h2>
<h3>yarn/npm</h3>
<pre
class="language-bash"
><code class="language-bash"><span class="token comment"># npm</span>
<span class="token function">npm</span> i @jambonn/vue-concise-carousel
<span class="token comment"># yarn</span>
<span class="token function">yarn</span> <span class="token function">add</span> @jambonn/vue-concise-carousel</code></pre>
</div>
<div id="quick-start" class="container">
<h2 style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em">
Quick Start
</h2>
<p>
See
<a href="https://github.com/jambonn/vue-concise-carousel#configuration">
Configuration
</a>
to learn advanced usage.
</p>
<pre
class="language-html"
><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>carousel</span> <span class="token attr-name">:center-mode</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>true<span class="token punctuation">"</span></span> <span class="token attr-name">:navigation-enabled</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>false<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>carousel</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
<span class="token keyword">import</span> { Carousel, Slide } <span class="token keyword">from</span> <span class="token string">'@jambonn/vue-concise-carousel'</span>
<span class="token keyword">import</span> <span class="token string">'@jambonn/vue-concise-carousel/dist/vue-concise-carousel.css'</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
name<span class="token punctuation">:</span> <span class="token string">'ConciseCarouselComponent'</span><span class="token punctuation">,</span>
components<span class="token punctuation">:</span> <span class="token punctuation">{</span> Carousel, Slide <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span></code></pre>
</div>
<div id="example-full" class="container">
<h2 style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em">
Examples
</h2>
<example-basic />
<example-responsive />
<example-scroll-per-page />
</div>
<div id="license" class="container">
<h2 style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em">
License
</h2>
<p>
This software is licensed under the
<a
href="https://github.com/jambonn/vue-concise-carousel/blob/next/LICENSE.md"
>
MIT
</a>
.
</p>
</div>
</div>
</template>
<script>
import ExampleBasic from './ExampleBasic.vue'
import ExampleResponsive from './ExampleResponsive.vue'
import ExampleScrollPerPage from './ExampleScrollPerPage.vue'
export default {
name: 'App',
components: { ExampleBasic, ExampleResponsive, ExampleScrollPerPage },
setup() {
return { slideCount: 6 }
},
}
</script>

<style lang="css">
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
font-size: 16px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #34495e;
background-color: #fff;
margin: 0;
}
.container {
width: 100%;
padding: 12px;
margin-right: auto;
margin-left: auto;
}
@media (min-width: 960px) {
.container {
max-width: 900px;
}
}
@media (min-width: 1264px) {
.container {
max-width: 1185px;
}
}
pre[class*='language-'] {
background: #2d2d2d;
padding: 1em;
margin: 0.5em 0;
overflow: auto;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
line-height: 1.5;
tab-size: 4;
hyphens: none;
}
code {
color: #bd4147;
white-space: pre;
word-break: normal;
background: transparent;
overflow: visible;
padding: 0;
border: 0;
display: inline;
line-height: inherit;
margin: 0;
}
code:before,
code:after {
content: ' ';
letter-spacing: -1px;
}
.token.block-comment,
.token.cdata,
.token.comment,
.token.doctype,
.token.prolog {
color: #999;
}
.token.boolean,
.token.function,
.token.number {
color: #f08d49;
}
.token.punctuation {
color: #ccc;
}
.token.attr-value,
.token.char,
.token.regex,
.token.string,
.token.variable {
color: #7ec699;
}
.token.attr-name,
.token.deleted,
.token.namespace,
.token.tag {
color: #e2777a;
}
.token.atrule,
.token.builtin,
.token.important,
.token.keyword,
.token.selector {
color: #cc99cd;
}
a {
text-decoration: none;
}
.button {
padding: 0.75em 2em;
border-radius: 2em;
display: inline-block;
color: #fff;
background-color: #34495e;
transition: all 0.15s ease;
box-sizing: border-box;
border: 1px solid #34495e;
}
.button.white {
background-color: #fff;
color: #34495e;
}
.action .button:first-child {
margin-right: 1em;
}
.action .button {
margin: 1em 0;
font-size: 1.05em;
font-weight: 600;
letter-spacing: 0.1em;
}
</style>
41 changes: 41 additions & 0 deletions demo/ExampleBasic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div class="content">
<h3 style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em">
1. Basic
</h3>
<p>No options configured, 10 slides added to the carousel.</p>
<div class="example-basic" style="margin-bottom: 50px">
<div class="preview">
<carousel>
<slide v-for="index in 10" :key="index">
<img
style="width: 100%"
src="https://via.placeholder.com/1080.png/09f/fff"
/>
</slide>
</carousel>
</div>
<div class="template">
<pre
class="language-html"
><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>carousel</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>carousel</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
</code></pre>
</div>
</div>
</div>
</template>

<script>
export default {
name: 'ExampleBasic',
}
</script>
50 changes: 50 additions & 0 deletions demo/ExampleResponsive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div class="content">
<h3 style="border-bottom: 1px solid #eaecef; padding-bottom: 0.3em">
2. Responsive
</h3>
<p>
Configured breakpoints: 2 slides on mobile (&lt;= 480px), 3 slides on
tablet (&lt;= 768).
</p>
<div class="example-responsive" style="margin-bottom: 50px">
<div class="preview">
<carousel
:per-page-custom="[
[480, 2],
[768, 3],
]"
>
<slide v-for="index in 10" :key="index">
<img
style="width: 100%"
src="https://via.placeholder.com/1080.png/09f/fff"
/>
</slide>
</carousel>
</div>
<div class="template">
<p>Template</p>
<pre
class="language-html"
><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>carousel</span> <span class="token attr-name">:per-page-custom</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>[[480, 2], [768, 3]]<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slide</span><span class="token punctuation">&gt;</span></span>4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slide</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>carousel</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
</code></pre>
</div>
</div>
</div>
</template>

<script>
export default {
name: 'ExampleResponsive',
}
</script>
Loading

0 comments on commit 7e88a09

Please sign in to comment.