Skip to content

Commit

Permalink
feat: add vue-at demo for gh119 & misc
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Apr 19, 2020
1 parent 3b168f2 commit db5073a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
1 change: 1 addition & 0 deletions public/code/index.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- hello-world.jsx
- vue-at-gh119.js
- vue-at-element-2.x-input.js
- vue-at-element-1.x-input.js
- vue-threejs.js
Expand Down
49 changes: 49 additions & 0 deletions public/code/vue-at-gh119.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// await loadJs('https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js')
await loadJs('https://unpkg.com/vue@2.6.11/dist/vue.min.js')

// await loadJs('https://unpkg.com/vue-at')
await loadJsForceUmd({
url: 'https://unpkg.com/vue-at@2.5.0-beta.2/dist/vue-at.js',
name: 'VueAt',
})

appendCss(`
.container { padding: 20px }
.editor { margin-top:20px; padding:4px 8px; height:120px; border:solid 1px gray; white-space:pre-wrap }
.atwho-remove { cursor: pointer }
`)

window.atwhoRemoveItem = target => {
let tag = target.parentNode.parentNode
tag.parentNode.removeChild(tag)
}

let App = {
components: { At: VueAt },
template: `
<div class="container">
<h1>Demo for vue-at#119</h1>
<div v-for="link in links">
<a target="_blank" :href="link">{{link}}</a>
</div>
<at :members="members" v-model="input">
<template v-slot:embeddedItem="s">
<span><span class="tag">[ @{{ s.current }} <span class="atwho-remove" onclick="atwhoRemoveItem(this)">×</span> ]</span></span>
</template>
<div class="editor" contenteditable></div>
</at>
</div>
`,
data() {
return {
links: [
'https://github.com/fritx/vue-at',
'https://github.com/fritx/vue-at/issues/119',
],
members: [
'fritx', 'linguokang', 'huangruichang'
],
input: '<span data-at-embedded="" contenteditable="false"> <span class="tag">[ @fritx <span onclick="atwhoRemoveItem(this)" class="atwho-remove">×</span> ]</span> </span> <span data-at-embedded="" contenteditable="false"> <span class="tag">[ @huangruichang <span onclick="atwhoRemoveItem(this)" class="atwho-remove">×</span> ]</span> </span> '
}
}
}
Binary file added public/code/vue-at-gh119.js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 3 additions & 8 deletions public/code/vue-threejs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// await loadJs('https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js')
await loadJs('https://unpkg.com/vue@2.6.11/dist/vue.min.js')

// await loadJs('https://unpkg.com/three@0.115.0/build/three.min.js')
await loadJs('https://unpkg.com/three@0.81.2/build/three.min.js')
// await loadJs('https://unpkg.com/three@0.81.2/build/three.min.js')
await loadJs('https://unpkg.com/three@0.115.0/build/three.min.js')

// await loadJs('https://unpkg.com/vue-threejs@0.2.0-alpha.1/lib/VueThreejs.umd.min.js')
await loadJs('https://unpkg.com/vue-threejs@0.2.0-alpha.1/lib/VueThreejs.umd.js')
Expand Down Expand Up @@ -42,9 +42,6 @@ let App = {
}
}
},
created() {
this.handleResize = _.debounce(this.handleResize, 2000)
},
mounted() {
mountNode.addEventListener('resize', this.handleResize)
},
Expand All @@ -56,8 +53,6 @@ let App = {
this.ui.rotation.x += 0.01
this.ui.rotation.y += 0.01
},
handleResize() {
triggerPreview()
}
handleResize: _.debounce(triggerPreview, 2000)
}
}
2 changes: 1 addition & 1 deletion src/playground/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export let Playground: React.FC = () => {
return (
<div className="page-playground">
<Helmet>
<title>Playground</title>
<title>Playground{file ? ` - ${file}` : ''}</title>
<style>{`html { overflow: hidden } #root { height: 100% }`}</style>
<script>{preview}</script>
</Helmet>
Expand Down

0 comments on commit db5073a

Please sign in to comment.