Skip to content

Commit

Permalink
feat: chatwoot vue example
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Sep 21, 2022
1 parent c835143 commit 10acdf5
Show file tree
Hide file tree
Showing 19 changed files with 1,207 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/vue/chatwoot/.gitignore
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions examples/vue/chatwoot/.vscode/extensions.json
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
16 changes: 16 additions & 0 deletions examples/vue/chatwoot/README.md
@@ -0,0 +1,16 @@
# Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)

## Type Support For `.vue` Imports in TS

Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:

1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.

You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
14 changes: 14 additions & 0 deletions examples/vue/chatwoot/components.d.ts
@@ -0,0 +1,14 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module '@vue/runtime-core' {
export interface GlobalComponents {
HButton: typeof import('./src/components/HButton.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
13 changes: 13 additions & 0 deletions examples/vue/chatwoot/index.html
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions examples/vue/chatwoot/package.json
@@ -0,0 +1,25 @@
{
"name": "chatwoot",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"@huntersofbook/chatwoot-vue": "^0.2.0",
"vue": "^3.2.37"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.1.0",
"autoprefixer": "^10.4.12",
"postcss": "^8.4.16",
"tailwindcss": "^3.1.8",
"typescript": "^4.6.4",
"unplugin-vue-components": "^0.22.7",
"vite": "^3.1.0",
"vue-tsc": "^0.40.4"
}
}
6 changes: 6 additions & 0 deletions examples/vue/chatwoot/postcss.config.cjs
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions examples/vue/chatwoot/public/vite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions examples/vue/chatwoot/src/App.vue
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { useChatWoot } from '@huntersofbook/chatwoot-vue'
const {
isModalVisible,
toggle,
toggleBubbleVisibility,
popoutChatWindow,
...more
} = useChatWoot()
</script>

<template>
<div class="mx-auto w-full max-w-4xl mt-20">
<div class="grid gap-10 grid-cols-3">
<div class="col-span-full bg-gray-200 p-4">
isModalVisible: <span class="font-black"> {{ isModalVisible }}</span>
</div>
<HButton @click="toggle('open')">toggle open</HButton>
<HButton @click="toggle('close')">toggle close</HButton>

<HButton @click="toggleBubbleVisibility('hide')"
>toggleBubbleVisibility-hide</HButton
>
<HButton @click="toggleBubbleVisibility('show')"
>toggleBubbleVisibility-show</HButton
>
<HButton @click="popoutChatWindow()">popoutChatWindow</HButton>
</div>
</div>
</template>
1 change: 1 addition & 0 deletions examples/vue/chatwoot/src/assets/vue.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions examples/vue/chatwoot/src/components/HButton.vue
@@ -0,0 +1,9 @@
<template>
<button
v-bind="$attrs"
type="button"
class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
<slot />
</button>
</template>
21 changes: 21 additions & 0 deletions examples/vue/chatwoot/src/main.ts
@@ -0,0 +1,21 @@
import { createChatWoot } from '@huntersofbook/chatwoot-vue'
import { createApp } from 'vue'

import './style.css'
import App from './App.vue'

const chatwoot = createChatWoot({
init: {
websiteToken: 'b6BejyTTuxF4yPt61ZTZHjdB'
},
settings: {
locale: 'en',
position: 'left',
launcherTitle: 'Hello Chat'
}
})

const app = createApp(App)
app.use(chatwoot)

app.mount('#app')
3 changes: 3 additions & 0 deletions examples/vue/chatwoot/src/style.css
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
7 changes: 7 additions & 0 deletions examples/vue/chatwoot/src/vite-env.d.ts
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />

declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
8 changes: 8 additions & 0 deletions examples/vue/chatwoot/tailwind.config.cjs
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx,vue}'],
theme: {
extend: {}
},
plugins: []
}
18 changes: 18 additions & 0 deletions examples/vue/chatwoot/tsconfig.json
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions examples/vue/chatwoot/tsconfig.node.json
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
13 changes: 13 additions & 0 deletions examples/vue/chatwoot/vite.config.ts
@@ -0,0 +1,13 @@
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
Components({
/* options */
})
]
})

0 comments on commit 10acdf5

Please sign in to comment.