Skip to content

Improve composition #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
parser: "@typescript-eslint/parser",
extends: ["prettier"],
plugins: ["@typescript-eslint", "prettier"],
rules: {
"prettier/prettier": ["error"],
},
};
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
trailingComma: "es5",
arrowParens: "avoid",
};
3 changes: 3 additions & 0 deletions examples/vue2-demo/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
23 changes: 23 additions & 0 deletions examples/vue2-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions examples/vue2-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# vue2 + composition-api + Supabase

## Getting Started

- Run `yarn install` to pull all the required dependencies
- Create a `.env` file on the root of this project i.e. `../vue3-vite-demo/.env`
- Add the variable `VUE_APP_SUPABSE_URL` and set its value
- Add the variable `VUE_APP_SUPABASE_KEY` and set its value
- Run `yarn serve`

## How `yarn serve` works

The scripts starts by looking for and removing any tarballs on the root directory of this project. The next step, the root project _vue-supabase_ is packed into a tarball, the version is then removed from the name. The script then uses that tarball to install _vue-supabase_ as a dependency.
5 changes: 5 additions & 0 deletions examples/vue2-demo/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
29 changes: 29 additions & 0 deletions examples/vue2-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "vue2-demo",
"version": "0.1.0",
"private": true,
"scripts": {
"clean": "rimraf ./*.tgz",
"pack-parent": "cd ../.. && npm pack --pack-destination=examples/vue2-demo",
"rename-tarball": "rename *.tgz vue-supabase",
"install-tarball": "yarn add ./vue-supabase.tgz",
"serve": "yarn clean && yarn pack-parent && yarn rename-tarball && yarn install-tarball && vue-cli-service serve"
},
"dependencies": {
"@vue/composition-api": "^1.2.4",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-supabase": "./vue-supabase.tgz"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"rename-cli": "^6.2.1",
"rimraf": "^3.0.2",
"typescript": "~4.1.5",
"vue-template-compiler": "^2.6.11"
}
}
Binary file added examples/vue2-demo/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/vue2-demo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<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><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> 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>
29 changes: 29 additions & 0 deletions examples/vue2-demo/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Welcome to Your Vue.js + TypeScript + Supabase App" />
</div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import HelloWorld from "./components/HelloWorld.vue";

@Component({
components: {
HelloWorld,
},
})
export default class App extends Vue {}
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Binary file added examples/vue2-demo/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions examples/vue2-demo/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br />
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener"
>vue-cli documentation</a
>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"
>babel</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript"
target="_blank"
rel="noopener"
>typescript</a
>
</li>
</ul>
<h3>Essential Links</h3>
<ul>
<li>
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
</li>
<li>
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"
>Forum</a
>
</li>
<li>
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"
>Community Chat</a
>
</li>
<li>
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
>Twitter</a
>
</li>
<li>
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
</li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li>
<a href="https://router.vuejs.org" target="_blank" rel="noopener"
>vue-router</a
>
</li>
<li>
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-devtools#vue-devtools"
target="_blank"
rel="noopener"
>vue-devtools</a
>
</li>
<li>
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
>vue-loader</a
>
</li>
<li>
<a
href="https://github.com/vuejs/awesome-vue"
target="_blank"
rel="noopener"
>awesome-vue</a
>
</li>
</ul>
</div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";

@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string;

mounted() {
console.log("mounted with supabase: ", !!this.$supabase);
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
13 changes: 13 additions & 0 deletions examples/vue2-demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue from "vue";
import App from "./App.vue";
import VueSupabase from "vue-supabase";

Vue.config.productionTip = false;
Vue.use(VueSupabase, {
supabaseUrl: process.env.VUE_APP_SUPABASE_URL,
supabaseKey: process.env.VUE_APP_SUPABASE_KEY,
});

new Vue({
render: h => h(App),
}).$mount("#app");
13 changes: 13 additions & 0 deletions examples/vue2-demo/src/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue, { VNode } from 'vue'

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}
4 changes: 4 additions & 0 deletions examples/vue2-demo/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
40 changes: 40 additions & 0 deletions examples/vue2-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Loading