Skip to content

Commit

Permalink
add deck9/ui library and fix vue typescript integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilReinking committed Sep 23, 2021
1 parent c9b85fd commit 66f2e6e
Show file tree
Hide file tree
Showing 13 changed files with 648 additions and 730 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
'plugin:@typescript-eslint/recommended',
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint",
Expand All @@ -11,6 +12,9 @@ export default {
ecmaVersion: 2020,
parser: "@typescript-eslint/parser",
},
plugins: [
'@typescript-eslint',
],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
Expand Down
1,000 changes: 423 additions & 577 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@
"@inertiajs/inertia": "^0.10.0",
"@inertiajs/inertia-vue3": "^0.5.1",
"@inertiajs/progress": "^0.2.6",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/typography": "^0.3.0",
"@tailwindcss/forms": "^0.3.3",
"@tailwindcss/typography": "^0.4.1",
"@types/node": "^16.9.6",
"@types/webpack-env": "^1.16.2",
"@vue/compiler-sfc": "^3.0.5",
"@vue/compiler-sfc": "^3.2.16",
"axios": "^0.21",
"browser-sync": "^2.27.5",
"browser-sync-webpack-plugin": "^2.3.0",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"postcss": "^8.3.7",
"postcss-import": "^12.0.1",
"tailwindcss": "^2.0.1",
"ts-loader": "^9.2.6",
"typescript": "^4.4.3",
"vue": "^3.0.5",
"vue": "^3.2.16",
"vue-loader": "^16.1.2"
},
"dependencies": {
"@deck9/ui": "^0.3.6",
"@types/ziggy-js": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
Expand Down
8 changes: 4 additions & 4 deletions resources/js/Layouts/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
</div>
</template>

<script>
<script lang="ts">
import { defineComponent } from "vue";
import JetApplicationLogo from "@/Jetstream/ApplicationLogo.vue";
import JetBanner from "@/Jetstream/Banner.vue";
Expand Down Expand Up @@ -275,9 +275,9 @@ export default defineComponent({
},
methods: {
switchToTeam(team) {
switchToTeam(team :any) {
this.$inertia.put(
route("current-team.update"),
this.route("current-team.update"),
{
team_id: team.id,
},
Expand All @@ -288,7 +288,7 @@ export default defineComponent({
},
logout() {
this.$inertia.post(route("logout"));
this.$inertia.post(this.route("logout"));
},
},
});
Expand Down
184 changes: 48 additions & 136 deletions resources/js/Pages/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -1,155 +1,67 @@
<template>
<app-layout title="Dashboard">
<div class="py-12">
<div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center relative">
<h1 class="text-lg text-grey-900 font-bold font-heading">
Your Dashboard
</h1>
<create-chatbot class="absolute bottom-0 right-0"></create-chatbot>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 grid grid-cols-12">
<div class="col-span-8">
<div class="flex justify-between items-center relative">
<D9Button class="mb-6" label="Create new form" icon="user" iconPosition="right" />
</div>

<div
v-if="!forms.length || forms.length === 0"
class="
bg-grey-100
px-16
py-10
rounded
w-full
text-center
max-w-2xl
mx-auto
"
>
<h2
<div
v-if="!forms.length || forms.length === 0"
class="
text-center
font-heading font-black
text-3xl
leading-none
text-grey-900
pb-8
"
>
Create your first survey
</h2>
<p class="leading-loose text-grey-900 text-base">
You haven't created a survey yet. Click on "New survey" in the top
right corner to begin with a new survey. To get you started really
quickly you can watch the following introduction for the BotReach
editor.
</p>
</div>

<div v-else>
<a
class="
bg-white
bg-grey-100
px-16
py-10
rounded
border border-grey-300
flex
px-6
py-4
mb-2
hover:border-blue-300
transition-sm
no-underline
hover:no-underline
w-full
text-center
max-w-2xl
mx-auto
"
v-for="form in forms"
:href="route('forms.edit', form.uuid)"
>
<div class="w-1/2 flex items-center">
<div
class="
rounded-full
overflow-hidden
p-2
h-12
w-12
flex
items-center
justify-center
relative
"
:style="`background-color: ${form.brand_color};`"
>
<img
v-if="form.avatar"
class="absolute inset-0 block"
:src="`${form.avatar}?w=192&h=192&fit=crop`"
:alt="`${form.name} Avatar`"
/>
<span
v-else
class="text-sm font-black uppercase"
:style="`color: ${form.contrast_color}`"
>{{ form.initials }}</span
>
</div>
<div class="ml-6">
<h3 class="text-grey-900 font-bold mb-1 text-base">
{{ form.name }}
</h3>
<h2
class="
text-center
font-heading font-black
text-3xl
leading-none
text-grey-900
pb-8
"
>
Create your first survey
</h2>
<p class="leading-loose text-grey-900 text-base">
You haven't created a survey yet. Click on "New survey" in the top
right corner to begin with a new survey. To get you started really
quickly you can watch the following introduction for the BotReach
editor.
</p>
</div>

<div v-if="form.is_published" class="flex items-center">
<span
class="inline-block mr-1 w-3 h-3 rounded-full bg-green-500"
></span>
<span class="text-xs text-grey-500">Published</span>
</div>
<div v-else class="flex items-center">
<span
class="inline-block mr-1 w-3 h-3 rounded-full bg-grey-200"
></span>
<span class="text-xs text-grey-500">Unpublished</span>
</div>
</div>
</div>
<div class="w-full flex items-center justify-center">
<div class="leading-none mx-2">
<div
class="
text-xl
font-medium font-heading
text-grey-900
flex
items-center
"
>
{{ form.completion_rate }}%
</div>
<div class="text-grey-500 text-xs mt-1">Completion Rate</div>
</div>
<div class="leading-none mx-2">
<div class="text-xl font-medium font-heading text-grey-900">
{{ form.total_sessions }}
</div>
<div class="text-grey-500 text-xs mt-1">Total Sessions</div>
</div>
</div>
<div class="w-24 flex items-center justify-end">View</div>
</a>
<div v-else>
<FormListItem v-bind="{form}" v-for="form in forms" />
</div>
</div>
<div class="col-span-4"></div>
</div>
</div>
</app-layout>
</template>

<script>
import { defineComponent } from "vue";
<script lang="ts" setup>
import AppLayout from "@/Layouts/AppLayout.vue";
import FormListItem from "@/components/Dashboard/FormListItem.vue";
import { D9Button } from "@deck9/ui";
import { FormModel } from "@/types";
import { withDefaults } from "vue";
interface DashboardProps {
forms: Array<FormModel>;
}
export default defineComponent({
props: {
forms: {
type: Array,
default: () => [],
},
},
components: {
AppLayout,
},
const props = withDefaults(defineProps<DashboardProps>(), {
forms: () => [],
});
</script>
20 changes: 15 additions & 5 deletions resources/js/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { App, createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/inertia-vue3";
import { InertiaProgress } from "@inertiajs/progress";
import type { Config, RouteParamsWithQueryOverload } from "ziggy-js";
import { RouteParamsWithQueryOverload, Config, Router } from "ziggy-js";

const appName =
window.document.getElementsByTagName("title")[0]?.innerText || "Laravel";
declare function route(
name?: undefined,
params?: RouteParamsWithQueryOverload,
absolute?: boolean,
config?: Config,
): Router;

declare function route(
name: string,
Expand All @@ -13,14 +17,20 @@ declare function route(
config?: Config,
): string;

const appName =
window.document.getElementsByTagName("title")[0]?.innerText || "Laravel";

createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
createApp({ render: () => h(app, props) })
.use(plugin)
const vueApp = createApp({ render: () => h(app, props) })

vueApp.use(plugin)
.mixin({ methods: { route } })
.mount(el);

return vueApp as App
},
});

Expand Down
Loading

0 comments on commit 66f2e6e

Please sign in to comment.