Skip to content

Commit

Permalink
feat(CodeSandbox): add CodeSandbox bot (#17)
Browse files Browse the repository at this point in the history
* feat(CodeSandbox): Add CodeSandbox bot config

* fix(CodeSandbox): fix paths to CodeSandbox sandboxes

* fix(CodeSandbox): fix Jest tests

* fix(CodeSandbox): CodeSandbox sandobex cleanup
  • Loading branch information
Bartozzz authored May 3, 2020
1 parent bea6e23 commit cc348b2
Show file tree
Hide file tree
Showing 20 changed files with 51,919 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"sandboxes": ["/.codesandbox/sandbox/mixin", "/.codesandbox/sandbox/plugin"]
}
25,850 changes: 25,850 additions & 0 deletions .codesandbox/sandbox/mixin/package-lock.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .codesandbox/sandbox/mixin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "vue-pwa-install-mixin-sandbox",
"version": "0.1.0",
"description": "Vue.js example project with the PWA Install mixin",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@vue/cli-plugin-babel": "4.1.1",
"vue": "^2.6.11",
"vue-pwa-install": "../../../"
},
"devDependencies": {
"@vue/cli-service": "4.1.1",
"vue-template-compiler": "^2.6.11"
}
}
Binary file added .codesandbox/sandbox/mixin/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions .codesandbox/sandbox/mixin/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>codesandbox</title>
</head>
<body>
<noscript>
<strong>We're sorry but codesandbox doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
52 changes: 52 additions & 0 deletions .codesandbox/sandbox/mixin/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<div id="app">
<h1>Vue PWA Install – mixin</h1>

<button v-if="deferredPrompt" @onClick="promptInstall">
Add to home screen
</button>
</div>
</template>

<script>
import { VuePwaInstallMixin } from "vue-pwa-install";
export default {
name: "App",
mixins: [VuePwaInstallMixin],
data() {
return {
deferredPrompt: null,
};
},
methods: {
promptInstall() {
// Show the prompt:
this.deferredPrompt.prompt();
// Wait for the user to respond to the prompt:
this.deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === "accepted") {
console.log("User accepted the install prompt");
} else {
console.log("User dismissed the install prompt");
}
this.deferredPrompt = null;
});
},
},
created() {
this.$on("canInstall", (event) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt:
event.preventDefault();
// Stash the event so it can be triggered later:
this.deferredPrompt = event;
});
},
};
</script>
8 changes: 8 additions & 0 deletions .codesandbox/sandbox/mixin/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Vue from "vue";
import App from "./App.vue";

Vue.config.productionTip = false;

new Vue({
render: h => h(App)
}).$mount("#app");
Loading

0 comments on commit cc348b2

Please sign in to comment.