Skip to content

Commit 5821798

Browse files
committed
added modal when deleteing
1 parent fb88660 commit 5821798

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ Browse and create mini step-by-step tutorial
44

55
[snippet.shoaibsharif.dev](https://snippet.shoaibsharif.dev)
66

7+
## Features
8+
9+
- Algolia search Integration with Vue InstantSearch
10+
- Nuxt.js with Laravel API integration with TailwindCSS
11+
- change editor mode based on extension (i.e. `*.js`, `*.ts`, `*.vue`)
12+
- change highlight mode based on extension
13+
- Search Animation using [`anime.js`](https://animejs.com/)
14+
- Customized TailwindCSS Modal using Promise
15+
- TailwindCSS dark Mode 🌓
16+
717
## Build Setup
818

919
```bash

components/Snippet/List.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,25 @@
4040
</template>
4141

4242
<script>
43+
import modal from "@/mixins/modal";
44+
4345
export default {
4446
props: {
4547
snippets: {
4648
required: true
4749
},
4850
showPublic: Boolean
4951
},
52+
mixins: [modal],
5053
methods: {
5154
visibilityChanged(isVisible) {
5255
if (!isVisible) return
5356
this.$emit('onVisible', "just updated")
5457
},
58+
5559
async deleteSnippet(snippet) {
60+
const confirm = await this.openModal()
61+
if (!confirm) return
5662
await this.$axios.$delete(`/api/snippets/${snippet.id}`);
5763
this.snippets = this.snippets.filter(s => s.id !== snippet.id);
5864
}

mixins/modal.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Vue from "vue";
2+
import Modal from "~/components/Modal";
3+
4+
export default {
5+
methods: {
6+
openModal() {
7+
return new Promise((resolve, reject) => {
8+
const mboxInstance = Vue.extend(Modal)
9+
const modalComponent = new mboxInstance().$mount()
10+
document.getElementById('__nuxt').appendChild(modalComponent.$el);
11+
modalComponent.$data.openModal = true
12+
modalComponent.$on('confirm', result => {
13+
return resolve(result)
14+
})
15+
16+
})
17+
},
18+
}
19+
}

nuxt.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default {
3737
},
3838
{
3939
rel: "stylesheet",
40-
href: "https://fonts.googleapis.com/css2?family=Nunito&display=swap"
40+
href: "https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;700&display=swap"
4141
}
4242
]
4343
},

pages/snippets/_id/edit.vue

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import Vue from "vue";
9999
import browseSnippet from "~/mixins/snippets/browseSnippet";
100100
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
101101
import pagetransition from "@/mixins/pagetransition";
102-
import Modal from '@/components/Modal.vue'
102+
import modal from "@/mixins/modal";
103103
104104
export default Vue.extend({
105105
@@ -158,7 +158,7 @@ export default Vue.extend({
158158
}, 1000)
159159
},
160160
},
161-
mixins: [browseSnippet, pagetransition],
161+
mixins: [browseSnippet, pagetransition, modal],
162162
async asyncData(ctx) {
163163
try {
164164
const snippet = await ctx.app.$axios.$get(`/api/snippets/${ctx.params.id}`)
@@ -202,18 +202,7 @@ export default Vue.extend({
202202
this.steps = this.steps.filter(s => s.id !== step.id);
203203
await this.$router.push({query: {step: previousStep?.id || this.steps[0].id}});
204204
},
205-
openModal() {
206-
return new Promise((resolve, reject) => {
207-
let mboxInstance = Vue.extend(Modal)
208-
let oComponent = new mboxInstance().$mount()
209-
document.getElementById('__nuxt').appendChild(oComponent.$el);
210-
oComponent.$data.openModal = true
211-
oComponent.$on('confirm', result => {
212-
return resolve(result)
213-
})
214-
215-
})
216-
},
205+
217206
stepWatcher() {
218207
return debounce(async function (step) {
219208
let {title, body, id} = step

0 commit comments

Comments
 (0)