├── src
├── eventBus.js
├── assets
│ └── css
│ │ ├── tailwind.css
│ │ └── tooltip.css
├── main.js
├── components
│ ├── examples
│ │ ├── ClosableInside.vue
│ │ ├── Alert.vue
│ │ └── SignInForm.vue
│ ├── common
│ │ ├── Button.vue
│ │ └── Modal.vue
│ └── ModalRoot.vue
└── App.vue
├── public
├── favicon.ico
└── index.html
├── babel.config.js
├── tailwind.js
├── postcss.config.js
├── .gitignore
├── README.md
└── package.json
/src/eventBus.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | export const ModalBus = new Vue()
4 |
--------------------------------------------------------------------------------
/src/assets/css/tailwind.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DJanoskova/Vue.js-Modal-context/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/tailwind.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | theme: {
3 | extend: {}
4 | },
5 | variants: {},
6 | plugins: []
7 | }
8 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "plugins": [
3 | require('tailwindcss')('tailwind.js'),
4 | require('autoprefixer')(),
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/.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/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 | import VTooltip from 'v-tooltip'
4 |
5 | import '@/assets/css/tailwind.css'
6 | import '@/assets/css/tooltip.css'
7 |
8 | Vue.use(VTooltip)
9 |
10 | Vue.config.productionTip = false
11 |
12 | new Vue({
13 | render: h => h(App),
14 | }).$mount('#app')
15 |
--------------------------------------------------------------------------------
/src/components/examples/ClosableInside.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | This dialog is closable from the inside of the component!
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
19 |
--------------------------------------------------------------------------------
/src/components/common/Button.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
23 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | modal-demo
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # modal-demo
2 |
3 | A demo project to show Modal window management in Vue.js using EventBus
4 |
5 | Article: https://medium.com/@danajanoskova/vue-js-manage-your-modal-window-s-effortlessly-using-eventbus-518977195eed
6 |
7 | Demo app: https://vue-modal-context.netlify.com/
8 |
9 | ## Project setup
10 | ```
11 | npm install
12 | ```
13 |
14 | ### Compiles and hot-reloads for development
15 | ```
16 | npm run serve
17 | ```
18 |
19 | ### Compiles and minifies for production
20 | ```
21 | npm run build
22 | ```
23 |
24 | ### Run your tests
25 | ```
26 | npm run test
27 | ```
28 |
29 | ### Lints and fixes files
30 | ```
31 | npm run lint
32 | ```
33 |
34 | ### Customize configuration
35 | See [Configuration Reference](https://cli.vuejs.org/config/).
36 |
--------------------------------------------------------------------------------
/src/components/examples/Alert.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ text }}
4 |
5 |
6 |
7 |
37 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "modal-demo",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "core-js": "^3.3.2",
12 | "v-tooltip": "^2.0.2",
13 | "vue": "^2.6.10"
14 | },
15 | "devDependencies": {
16 | "@vue/cli-plugin-babel": "^4.0.0",
17 | "@vue/cli-plugin-eslint": "^4.0.0",
18 | "@vue/cli-service": "^4.0.0",
19 | "babel-eslint": "^10.0.3",
20 | "eslint": "^5.16.0",
21 | "eslint-plugin-vue": "^5.0.0",
22 | "sass": "^1.19.0",
23 | "sass-loader": "^8.0.0",
24 | "tailwindcss": "^1.1.3",
25 | "vue-template-compiler": "^2.6.10"
26 | },
27 | "eslintConfig": {
28 | "root": true,
29 | "env": {
30 | "node": true
31 | },
32 | "extends": [
33 | "plugin:vue/essential",
34 | "eslint:recommended"
35 | ],
36 | "rules": {},
37 | "parserOptions": {
38 | "parser": "babel-eslint"
39 | }
40 | },
41 | "browserslist": [
42 | "> 1%",
43 | "last 2 versions"
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/src/components/examples/SignInForm.vue:
--------------------------------------------------------------------------------
1 |
2 |
30 |
31 |
--------------------------------------------------------------------------------
/src/components/ModalRoot.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
48 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
59 |
60 |
70 |
--------------------------------------------------------------------------------
/src/components/common/Modal.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
16 |
{{ title }}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
34 |
35 |
104 |
--------------------------------------------------------------------------------
/src/assets/css/tooltip.css:
--------------------------------------------------------------------------------
1 | .tooltip {
2 | display: block !important;
3 | z-index: 10000;
4 | }
5 |
6 | .tooltip .tooltip-inner {
7 | background: black;
8 | color: white;
9 | border-radius: 16px;
10 | padding: 5px 10px 4px;
11 | }
12 |
13 | .tooltip .tooltip-arrow {
14 | width: 0;
15 | height: 0;
16 | border-style: solid;
17 | position: absolute;
18 | margin: 5px;
19 | border-color: black;
20 | z-index: 1;
21 | }
22 |
23 | .tooltip[x-placement^="top"] {
24 | margin-bottom: 5px;
25 | }
26 |
27 | .tooltip[x-placement^="top"] .tooltip-arrow {
28 | border-width: 5px 5px 0 5px;
29 | border-left-color: transparent !important;
30 | border-right-color: transparent !important;
31 | border-bottom-color: transparent !important;
32 | bottom: -5px;
33 | left: calc(50% - 5px);
34 | margin-top: 0;
35 | margin-bottom: 0;
36 | }
37 |
38 | .tooltip[x-placement^="bottom"] {
39 | margin-top: 5px;
40 | }
41 |
42 | .tooltip[x-placement^="bottom"] .tooltip-arrow {
43 | border-width: 0 5px 5px 5px;
44 | border-left-color: transparent !important;
45 | border-right-color: transparent !important;
46 | border-top-color: transparent !important;
47 | top: -5px;
48 | left: calc(50% - 5px);
49 | margin-top: 0;
50 | margin-bottom: 0;
51 | }
52 |
53 | .tooltip[x-placement^="right"] {
54 | margin-left: 5px;
55 | }
56 |
57 | .tooltip[x-placement^="right"] .tooltip-arrow {
58 | border-width: 5px 5px 5px 0;
59 | border-left-color: transparent !important;
60 | border-top-color: transparent !important;
61 | border-bottom-color: transparent !important;
62 | left: -5px;
63 | top: calc(50% - 5px);
64 | margin-left: 0;
65 | margin-right: 0;
66 | }
67 |
68 | .tooltip[x-placement^="left"] {
69 | margin-right: 5px;
70 | }
71 |
72 | .tooltip[x-placement^="left"] .tooltip-arrow {
73 | border-width: 5px 0 5px 5px;
74 | border-top-color: transparent !important;
75 | border-right-color: transparent !important;
76 | border-bottom-color: transparent !important;
77 | right: -5px;
78 | top: calc(50% - 5px);
79 | margin-left: 0;
80 | margin-right: 0;
81 | }
82 |
83 | .tooltip.popover .popover-inner {
84 | background: #f9f9f9;
85 | color: black;
86 | padding: 24px;
87 | border-radius: 5px;
88 | box-shadow: 0 5px 30px rgba(black, .1);
89 | }
90 |
91 | .tooltip.popover .popover-arrow {
92 | border-color: #f9f9f9;
93 | }
94 |
95 | .tooltip[aria-hidden='true'] {
96 | visibility: hidden;
97 | opacity: 0;
98 | transition: opacity .15s, visibility .15s;
99 | }
100 |
101 | .tooltip[aria-hidden='false'] {
102 | visibility: visible;
103 | opacity: 1;
104 | transition: opacity .15s;
105 | }
106 |
--------------------------------------------------------------------------------