Skip to content

Commit 859a794

Browse files
committed
initial commit
0 parents  commit 859a794

11 files changed

+6942
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

Diff for: README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
An abstraction for working with modals in Vue.
2+
3+
This is an answer to a question "how should I work with modals in Vue?".
4+
In short, for each modal you should create two files: `modal-NAME.vue`
5+
and `modal_NAME.js`. The former should be an ordinary Vue component
6+
with all of HTML, JavaScript, and CSS in it, while the latter is
7+
necessary to represent your modal as simple function.
8+
9+
## Installation
10+
11+
```sh
12+
npm i @vbarbarosh/vue-modal
13+
```
14+
15+
## Usage
16+
17+
### `modal-hello.vue`
18+
19+
```vue
20+
<template>
21+
<div>
22+
<button v-on:click="modal.return(true)">Confirm</button>
23+
<button v-on:click="modal.return(false)">Cancel</button>
24+
</div>
25+
</template>
26+
27+
<script>
28+
const modal_hello = {
29+
props: ['value'],
30+
inject: ['modal'],
31+
};
32+
33+
export default modal_hello;
34+
</script>
35+
```
36+
37+
### `modal_hello.js`
38+
39+
```javascript
40+
import modal from '@vbarbarosh/vue-modal';
41+
42+
function modal_hello(value)
43+
{
44+
return modal('<modal-hello v-model="value" />', {data: {value}});
45+
}
46+
47+
export default modal_hello;
48+
```
49+
50+
### `app.js`
51+
52+
```javascript
53+
import Vue from 'vue';
54+
import modal_hello from './modal_hello.js';
55+
56+
Vue({
57+
el: '#app',
58+
methods: {
59+
hello: async function () {
60+
await modal_hello().promise();
61+
},
62+
}
63+
});
64+
```

Diff for: bin/build

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -o nounset -o errexit -o pipefail
6+
7+
script=`realpath $0`
8+
scriptdir=`dirname $script`
9+
scriptname=`basename $script`
10+
11+
cd $scriptdir/..
12+
13+
npm run build

Diff for: bin/release

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -o nounset -o errexit -o pipefail
6+
7+
script=`realpath $0`
8+
scriptdir=`dirname $script`
9+
scriptname=`basename $script`
10+
11+
cd $scriptdir/..
12+
13+
case "${1-}" in
14+
major|minor|patch)
15+
;;
16+
*)
17+
echo usage: release 'major|minor|patch' 2>&1
18+
exit 1
19+
;;
20+
esac
21+
22+
if test -n "`git status -s`"; then
23+
echo error: there is changes 2>&1
24+
exit 1
25+
fi
26+
27+
npm run test
28+
29+
# Increase a version without commiting it and making a tag
30+
# XXX This is a hack to disable commiting by substituting `true` for `git`
31+
npm version $1 --git=/bin/true
32+
# Rebuild dist
33+
rm -rf dist
34+
npm run build
35+
36+
version=$(node -e 'console.log(require("./package.json").version)')
37+
# Update version in docs
38+
sed -i 's:\(<sub><sub>v\)[0-9]\+\.[0-9]\+\.[0-9]\+\(</sub></sub>\):\1'$version'\2:' docs/index.html
39+
sed -i 's:\(https\://unpkg\.com/@vbarbarosh/vue-pager@\)[0-9]\+\.[0-9]\+\.[0-9]\+\(/dist/vue-pager.js\):\1'$version'\2:' docs/index.html
40+
41+
git add package.json package-lock.json dist docs/index.html
42+
git commit -m "release v$version"
43+
44+
# Create a tag
45+
git tag v$version
46+
47+
# Submit changes to github
48+
git push
49+
git push --tags
50+
51+
# Publish package on npm
52+
npm publish

Diff for: bin/test

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -o nounset -o errexit -o pipefail
6+
7+
script=`realpath $0`
8+
scriptdir=`dirname $script`
9+
scriptname=`basename $script`
10+
11+
cd $scriptdir/..
12+
13+
npm run test

0 commit comments

Comments
 (0)