├── .npmignore ├── .prettierrc ├── renovate.json ├── postcss.config.js ├── .browserslistrc ├── src ├── types │ ├── shims-vue.d.ts │ ├── vue-component-wrapper.d.ts │ ├── shims-tsx.d.ts │ └── item.ts ├── utils │ ├── sanitizer.ts │ ├── getSlideCursor.ts │ ├── http.ts │ └── parser.ts ├── development.ts ├── main.ts ├── components │ ├── SlideViewer.vue │ ├── ErrorView.vue │ ├── LoadingView.vue │ ├── SlideControl.vue │ └── LoadingIndicator.vue ├── Kamishibai.vue └── DevApp.vue ├── tests └── unit │ └── utils │ └── getSlideCursor.spec.ts ├── .gitignore ├── vue.config.js ├── public └── index.html ├── jest.config.js ├── tsconfig.json ├── LICENSE ├── CHANGELOG.md ├── package.json └── README.md /.npmignore: -------------------------------------------------------------------------------- 1 | tests/ 2 | public/ 3 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | last 2 Chrome versions 2 | > 2.5% 3 | not ie <= 12 4 | Firefox >= 61 5 | Edge >= 17 6 | -------------------------------------------------------------------------------- /src/types/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue' 3 | export default Vue 4 | } 5 | -------------------------------------------------------------------------------- /src/utils/sanitizer.ts: -------------------------------------------------------------------------------- 1 | import xss from 'xss' 2 | 3 | export function sanitizeAllTags(html: string): string { 4 | return xss(html) 5 | } 6 | -------------------------------------------------------------------------------- /src/types/vue-component-wrapper.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@vue/web-component-wrapper' { 2 | export default function wrap(Vue: any, Component: any): any 3 | } 4 | -------------------------------------------------------------------------------- /src/utils/getSlideCursor.ts: -------------------------------------------------------------------------------- 1 | export function getSlideCursor( 2 | pageLength: number, 3 | elementWidth: number, 4 | clientX: number 5 | ) { 6 | return ~~((clientX / elementWidth) * pageLength) + 1 7 | } 8 | -------------------------------------------------------------------------------- /src/development.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import DevApp from './DevApp.vue' 3 | 4 | Vue.config.productionTip = false 5 | Vue.config.errorHandler = () => { 6 | 7 | } 8 | 9 | new Vue({ 10 | render: h => h(DevApp) 11 | }).$mount('#app') 12 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | const { default: wrap } = require('@vue/web-component-wrapper') 3 | const { default: Kamishibai } = require('./Kamishibai.vue?shadow') 4 | 5 | window.customElements.define('kamishibai-viewer', wrap(Vue, Kamishibai)) 6 | -------------------------------------------------------------------------------- /tests/unit/utils/getSlideCursor.spec.ts: -------------------------------------------------------------------------------- 1 | import { getSlideCursor } from "@/utils/getSlideCursor"; 2 | 3 | describe('getSlideCursor.ts', () => { 4 | test('getSlideCursor', () => { 5 | expect(getSlideCursor(20, 520, 0)).toBe(1) 6 | expect(getSlideCursor(20, 520, 519)).toBe(20) 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /src/types/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VNode } from 'vue' 2 | 3 | declare global { 4 | namespace JSX { 5 | // tslint:disable no-empty-interface 6 | interface Element extends VNode {} 7 | // tslint:disable no-empty-interface 8 | interface ElementClass extends Vue {} 9 | interface IntrinsicElements { 10 | [elem: string]: any 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | const pkg = require('./package.json') 2 | let baseUrl = '/' 3 | 4 | if (process.env.BUILD_TYPE === 'lib') { 5 | baseUrl = `/kamishibai-viewer/dist/${pkg.version}/` 6 | } 7 | 8 | if (process.env.BUILD_TYPE === 'app') { 9 | baseUrl = `/kamishibai-viewer/` 10 | } 11 | 12 | if (process.env.VUE_TEST === '1') { 13 | baseUrl = baseUrl.replace('/kamishibai-viewer/', '/') 14 | } 15 | 16 | module.exports = { 17 | baseUrl 18 | } 19 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |
19 | Kamishibai is a under development library.
20 | Because breaking changes may be born, please be careful when using.
21 |
27 | This is a library for embedding slides of Qiita which is a Japanese
28 | technical document sharing site.
29 |
30 | demo:
31 | https://potato4d.github.io/kamishibai-viewer/dist/1.0.0/demo.html
35 |
41 | 42 | ※ As we are planning to publish to webcomponents.org, the URL may 43 | change! 44 | 45 |
46 |1. Load runtime on script tag
47 |49 |52 |<script src="https://unpkg.com/vue@2.5.21/dist/vue.min.js"></script>50 |<script src="https://potato4d.github.io/kamishibai/dist/1.0.0/kamishibai.min.js"></script>51 |
2. Write custom element tag for your HTML
54 |
56 | <kamishibai-viewer data-item-id="4ff5873776992f0511d6"></kamishibai-viewer>
57 |
58 | 3. Done!
60 |
77 | MIT @ HANATANI Takuma(@potato4d)
78 | email: mail@potato4d.me
79 |