50 |
51 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/docs/awsm.opt.min.css:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";
2 |
3 | /*!
4 | * awsm.css v3.0.4 (https://igoradamenko.github.io/awsm.css/)
5 | * Optimized for https://os.kytta.dev/vue-tinybox
6 | * (c) 2015 Igor Adamenko
7 | * MIT License
8 | */html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Helvetica Neue,Arial,sans-serif;font-size:100%;line-height:1.4;background:#fff;color:#000;-webkit-overflow-scrolling:touch}body{margin:1.2em;font-size:1rem}@media (min-width:20rem){body{font-size:calc(.875rem + .625vw)}}@media (min-width:40rem){body{font-size:1.125rem}}body article,body footer,body header,body main{position:relative;max-width:40rem;margin:0 auto}body>header{margin-bottom:3.5em}body>header h1{margin:0;font-size:1.5em}body>header p{margin:0;font-size:.85em}body>footer{margin-top:6em;padding-bottom:1.5em;text-align:center;font-size:.8rem;color:#aaa}nav{margin:1em 0}nav ul{list-style:none;margin:0;padding:0}nav li{display:inline-block;margin-right:1em;margin-bottom:.25em}nav a:visited{color:#0064c1}nav a:hover{color:#f00000}ul{margin-top:0;padding-top:0;padding-left:2.5em}ul li+li{margin-top:.25em}p{margin:1em 0;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto}p:first-child{margin-top:0}p:last-child{margin-bottom:0}p img{float:right;margin-bottom:.5em;margin-left:.5em}aside{margin:.5em 0;font-style:italic;color:#aaa}@media (min-width:65rem){aside{position:absolute;right:-12.5rem;width:9.375rem;max-width:9.375rem;margin:0;padding-left:.5em;font-size:.8em;border-left:1px solid #f2f2f2}}h1,h2,h3{margin:1.25em 0 0;line-height:1.2}h2:focus>a[href^="#"][id]:empty,h2:hover>a[href^="#"][id]:empty{opacity:1}h1+p,h2+p,h3+p{margin-top:.5em}h2>a[href^="#"][id]:empty{position:absolute;left:-.65em;opacity:0;text-decoration:none;font-weight:400;line-height:1;color:#aaa}@media (min-width:40rem){h2>a[href^="#"][id]:empty{left:-.8em}}h2>a[href^="#"][id]:empty:focus,h2>a[href^="#"][id]:empty:hover,h2>a[href^="#"][id]:empty:target{opacity:1;box-shadow:none;color:#000}h2>a[href^="#"][id]:empty:target:focus{outline:none}h2>a[href^="#"][id]:empty:before{content:"§ "}h1{font-size:2.5em}h2{font-size:1.75em}h3{font-size:1.25em}article+article{margin-top:4em}a{color:#0064c1}a:visited{color:#8d39d0}a:active,a:hover{outline-width:0}a:hover{color:#f00000}img{display:block;max-width:100%;margin:0 auto}code{font-family:Consolas,Lucida Console,Monaco,monospace;font-style:normal}pre{overflow-x:auto;font-size:.8em;background:linear-gradient(rgba(0,0,0,.15),rgba(0,0,0,.15)) 0 0,linear-gradient(rgba(0,0,0,.15),rgba(0,0,0,.15)) 100% 0;background-attachment:scroll,scroll;background-size:1px 100%,1px 100%;background-repeat:no-repeat,no-repeat}pre>code{display:inline-block;overflow-x:visible;box-sizing:border-box;min-width:100%;border-right:3px solid #fff;border-left:1px solid #fff}::selection{background:rgba(0,100,193,.25)}
9 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to vue-tinybox
2 |
3 | Thank you for deciding to contribute to vue-tinybox! There are some things you need to know before starting.
4 |
5 | - [I want to propose a feature or file a bug without writing code](#i-want-to-propose-a-feature-or-file-a-bug-without-writing-code)
6 | - [I want to implement a feature or fix a bug myself](#i-want-to-implement-a-feature-or-fix-a-bug-myself)
7 | - [Branch naming](#branch-naming)
8 | - [Node version](#node-version)
9 | - [Package manager](#package-manager)
10 | - [Dev environment](#dev-environment)
11 | - [Testing](#testing)
12 | - [ESLint](#eslint)
13 | - [size-limit](#size-limit)
14 | - [Pull request](#pull-request)
15 |
16 | ## I want to propose a feature or file a bug without writing code
17 |
18 | If you want to ask a question, propose a new feature or tell us about a bug, you should [create a new issue](https://github.com/kytta/vue-tinybox/issues/new/choose) on the matter. Please make sure to pick the appropriate template and add as much information as you can. The more you tell me, the quicker can I resolve your issue :)
19 |
20 | ## I want to implement a feature or fix a bug myself
21 |
22 | There are rules I follow when I develop vue-tinybox, and I'd like other contributors to follow them too.
23 |
24 | ### Branch naming
25 |
26 | After forking this repo, please create a separate branch for every proposed feature. This is not enforced, but it helps a lot when navigating the PRs. Allowed are automatic names (e.g. 'patch-1') created when using GitHub's online editor.
27 |
28 | ### Node version
29 |
30 | All development should be done on the latest stable Node version with a set major number. Usually, it's the latest LTS release. Right now it is Node 14. You can always check the "Node.js CI" GitHub Action for the used version number. Use nvm if you want to install many Node versions.
31 |
32 | ### Package manager
33 |
34 | When developing or testing vue-tinybox, use Yarn v1 only. NPM and PNPM will not take Yarn's lockfile into account.
35 |
36 | ### Dev environment
37 |
38 | At the moment there are no automatic tests. To help with manual testing, I have created a test page. To have the package be built every time you edit code and to be able to see the changes, run `yarn dev`. This will launch a static file server in the background on port 8629 (TNBX). The webpage will not auto-reload, however — you should do it yourself. The webpage offers useful controls to test the package.
39 |
40 | ### Testing
41 |
42 | Testing consists of two steps: linting and checking the size. To run all tests, run `yarn test`.
43 |
44 | #### ESLint
45 |
46 | I use [ESLint](https://eslint.org/) to lint the code. Setting up an integration with your editor is quite helpful. You don't have to do it — CI will lint your code anyway. Please note that I **do not** accept unlinted code.
47 |
48 | You can run `yarn test:lint` to lint the code yourself.
49 |
50 | #### size-limit
51 |
52 | To keep the package size under control I use [size-limit](https://github.com/ai/size-limit). It is very important for me to keep the package small. Don't worry, if your edits make it go over the limit. Submit the pull request, and we'll figure out the solution together :)
53 |
54 | You can run `yarn test:size` to check the built bundle size.
55 |
56 | ### Pull request
57 |
58 | After your work is done, you can submit a pull request. There are some automated checks. One is from a GitHub Action — it executes `yarn test`. Another one is from Codacy — it checks the code quality. Please fix the issues detected by Codacy!
59 |
60 | ---
61 |
62 | After you submitted your issue or pull request, I will reach out to you and get the needed things done. Don't hesitate commenting on my decisions if you find them incorrect or unclear.
63 |
64 | If you have any questions, you can always contact me at [me@kytta.dev](mailto:me@kytta.dev)
65 |
66 | Thank you once again for participating in the life of vue-tinybox!
67 |
68 | -- _Nikita Karamov_
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-tinybox
2 |
3 |
4 |
5 | A slick, yet tiny lightbox gallery for Vue.js
6 |
7 | - **Slick.** No excessive design. Pictures, thumbnails, controls.
8 | - **Tiny.** Dependency-free. 3 KB minified and gzipped.
9 | - **Adaptive.** Works on computers. Works on tablets. Works on phones.
10 |
11 | ## Demo
12 |
13 | Observe the live demo here: [os.kytta.dev/vue-tinybox](https://os.kytta.dev/vue-tinybox)
14 |
15 | ## Basic usage
16 |
17 | ```html
18 |
19 | ```
20 |
21 | ## Install
22 |
23 | ### Browsers
24 |
25 | 1. Include the link to Tinybox in `` alongside Vue.js:
26 |
27 | ```html
28 |
29 |
30 | ```
31 |
32 | 2. Tinybox will auto-install upon detecting the global Vue instance. You can use
33 | it right away.
34 |
35 | ### Node environment
36 |
37 | 1. Install the Tinybox package:
38 |
39 | ```sh
40 | npm install vue-tinybox
41 | # or
42 | yarn add vue-tinybox
43 | ```
44 |
45 | 2. Register it as you usually would:
46 |
47 | ```js
48 | import Tinybox from "vue-tinybox";
49 | // or
50 | const Tinybox = require("vue-tinybox");
51 |
52 | Vue.component("Tinybox", Tinybox);
53 | //or
54 | Vue.use(Tinybox);
55 | //or
56 | new Vue({
57 | components: { Tinybox },
58 | // ...
59 | });
60 | ```
61 |
62 | ## API
63 |
64 | ### Image object
65 |
66 | An `Image` object is an object with following fields:
67 |
68 | | Field name | Type | Description |
69 | | ----------- | -------- | ---------------------------------------------------------------- |
70 | | `src` | `String` | Image URL |
71 | | `thumbnail` | `String` | (optional) Thumbnail URL. If omitted, the image URL will be used |
72 | | `caption` | `String` | (optional) Caption text to be overlayed on the image |
73 | | `alt` | `String` | (optional) Alt text. If omitted, the caption will be used |
74 |
75 | ### Props
76 |
77 | | Prop name | Type | Default | Description |
78 | | ----------- | --------- | ------- | ------------------------------------------------------------- |
79 | | `images` | `Array` | `[]` | List of either image URLs or [`Image`](#image-object) objects |
80 | | `loop` | `Boolean` | `false` | Indicates whether the images should loop |
81 | | `no-thumbs` | `Boolean` | `false` | When enabled, the thumbnails are hidden |
82 |
83 | ### `v-model`
84 |
85 | You can use `v-model` on a `Number` variable, which will hold the index of the
86 | image currently open. If no image is open (i.e. Tinybox is closed), the value
87 | becomes `null`.
88 |
89 | Instead of `v-model` you can use the `index` prop and `change` event:
90 |
91 | ```html
92 |
93 |
94 |
95 |
96 | {index = i}" />
97 | ```
98 |
99 | ### Events
100 |
101 | | Event name | Payload | Description |
102 | | ------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------ |
103 | | `change` | index of the image changed to | Is emitted on any image change (thumbnail navigation, prev/next, close) |
104 | | `prev`/`next` | index of the image changed to | Is emitted specifically when the user clicks "Prev"/"Next" or presses Left/Right arrow key |
105 | | `close` | index of the image Tinybox was closed at | Is emitted specifically when the user clicks "Close" or presses the Esc key |
106 |
107 | Events can come in handy for business logic cases:
108 |
109 | ```html
110 |
118 | ```
119 |
120 | ```js
121 | export default {
122 | // ...
123 | methods: {
124 | onChange(index) {
125 | console.log("User navigated to the photo: ", index);
126 | },
127 | onPrevious(index) {
128 | console.log("User clicked 'previous' to switch to: ", index);
129 | },
130 | onNext(index) {
131 | console.log("User clicked 'previous' to switch to: ", index);
132 | },
133 | onClose(index) {
134 | console.log("User closed TinyBox on this photo: ", index);
135 | },
136 | },
137 | };
138 | ```
139 |
140 | ## Browser support
141 |
142 | | ![Chrome][chrome] | ![Firefox][firefox] | ![Safari][safari] | ![MS Edge][edge] | ![Internet Explorer][ie] |
143 | | :---------------: | :-----------------: | :---------------: | :--------------: | :----------------------: |
144 | | **21+** | **28+** | **7+** | **16+** | **11** |
145 |
146 | [chrome]: https://github.com/alrra/browser-logos/raw/master/src/chrome/chrome_48x48.png
147 | [firefox]: https://github.com/alrra/browser-logos/raw/master/src/firefox/firefox_48x48.png
148 | [safari]: https://github.com/alrra/browser-logos/raw/master/src/safari/safari_48x48.png
149 | [edge]: https://github.com/alrra/browser-logos/raw/master/src/edge/edge_48x48.png
150 | [ie]: https://github.com/alrra/browser-logos/raw/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png
151 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
13 |
14 |
15 |
16 | vue-tinybox | A slick, yet tiny lightbox gallery for Vue.js
17 |
18 |
19 |
20 |
21 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
43 |
44 |
vue-tinybox
45 |
A slick, yet tiny lightbox gallery for Vue.js
46 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | What is it?
73 |
74 |
75 |
Tinybox is a simple lightbox gallery for Vue.js.
76 |
77 |
78 | While being not as customizable as some other lightboxes, Tinybox is
79 | very slick and lightweight (3 KB minzipped). Tinybox is great on
80 | mobile devices too: it supports swipe gestures and changes its size
81 | responsively.
82 |