Skip to content

Commit

Permalink
Merge pull request #20 from AnimalFoodBank:feature/20231104-vue-forms
Browse files Browse the repository at this point in the history
Update UI with Tailwind themes
  • Loading branch information
delano authored Nov 6, 2023
2 parents eed62bf + 64f16d2 commit f45ee89
Show file tree
Hide file tree
Showing 16 changed files with 4,731 additions and 724 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ local_settings.py
tmp/*
node_modules/

# Vite/Vue
.vite/

**/tmp
1 change: 1 addition & 0 deletions apps/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AFB - Animal Food Bank</title>

</head>
<body>
<div id="app"></div>
Expand Down
7 changes: 5 additions & 2 deletions apps/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "afb-ui",
"version": "0.1.0",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "vue-tsc --noEmit && vite build",
"dev": "vite",
Expand All @@ -13,6 +15,7 @@
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.6",
"@types/vue-router": "^2.0.0",
"@vueform/vueform": "^1.5.4",
"vue": "^3.3.7",
"vue-router": "^4.2.5",
"vue-service": "^1.0.3"
Expand All @@ -29,7 +32,7 @@
"tailwindcss": "^3.3.5",
"typescript": "^4.4.4",
"vitawind": "^2.0.0",
"vite": "^2.7.2",
"vue-tsc": "^0.29.8"
"vite": "^4.5.0",
"vue-tsc": "1.2.0"
}
}
14 changes: 8 additions & 6 deletions apps/ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
<a href="/"><img class="block h-8 w-8" src="@/assets/img/afb_icon_colour.png" alt="Animal Food Bank logo" /></a>
</div>
<div class="hidden lg:ml-10 lg:block">
<div class="flex space-x-4 ">
<nav class="pl-0 ml-0">
<div class="flex space-x-4 ">

<router-link v-for="item in navigation"
:key="item.name" :to="item.href" >{{ item.name }}
</router-link>
<router-link v-for="item in navigation"
:key="item.name" :to="item.href" class="nav-link rounded-md py-2 px-3 text-sm font-medium text-white hover:bg-indigo-500 hover:bg-opacity-75">{{ item.name }}
</router-link>

</div>
</div>
</nav>
</div>
</div>
<div class="flex flex-1 justify-center px-2 lg:ml-6 lg:justify-end">
Expand Down Expand Up @@ -172,7 +174,7 @@ const user = {
const navigation = [
{ name: 'Dashboard', href: '/dashboard', current: true },
{ name: 'About', href: '/about', current: false },
{ name: 'Requests', href: '/request', current: false },
{ name: 'Requests', href: '/requests', current: false },
]

const userNavigation = [
Expand Down
12 changes: 12 additions & 0 deletions apps/ui/src/components/NewRequestForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>

</template>

<script lang="ts">
export default {
}
</script>
3 changes: 3 additions & 0 deletions apps/ui/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ declare module '*.vue' {
const component: DefineComponent<{}, {}, any>
export default component
}
interface Window {
google: any;
}
13 changes: 12 additions & 1 deletion apps/ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ import App from './App.vue'
import './index.css'
import router from './router'

createApp(App).use(router).mount('#app')
// import Vueform from '@vueform/vueform'
// import vueformConfig from './../vueform.config'
import { Plugin } from 'vue'


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

// Attach Vueform and its config
// app.use(Vueform as any, vueformConfig)

app.mount('#app')
14 changes: 9 additions & 5 deletions apps/ui/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ type Route = {
path: string;
name: string;
component: any;
alias?: string;
}


const defaultRoute: Route = {
path: '/',
component: DashboardView,
name: 'DashboardView',
alias: '/dashboard',
};

const routes: Route[] = [
{
path: '/dashboard',
component: DashboardView,
name: 'DashboardView',
},
defaultRoute,
{
path: '/requests',
component: MakeRequestView,
Expand Down
3 changes: 3 additions & 0 deletions apps/ui/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

declare module '@vueform/vueform/themes/tailwind';
declare module '@vueform/vueform/locales/en';
282 changes: 273 additions & 9 deletions apps/ui/src/views/MakeRequestView.vue

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions apps/ui/tailwind.config.js → apps/ui/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ module.exports = {
"./src/views/*.{vue,html,js,ts,jsx,tsx}",
"./src/components/*.{vue,html,js,ts,jsx,tsx}",
"../afbcore/templates/**/*.html",
"../afbcore/templates/*.html"
"../afbcore/templates/*.html",
// './vueform.config.ts', // or where `vueform.config.js` is located
// './node_modules/@vueform/vueform/themes/tailwind/**/*.vue',
// './node_modules/@vueform/vueform/themes/tailwind/**/*.{ts,js,tsx,jsx}',
],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/aspect-ratio')
require('@tailwindcss/aspect-ratio'),
// require('@vueform/vueform/tailwind')
],
}
4 changes: 3 additions & 1 deletion apps/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"lib": ["esnext", "dom"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules"]
}
31 changes: 18 additions & 13 deletions apps/ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueform from '@vueform/vueform/vite'
import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
base: "/",
// root: "src/",
resolve: {
alias: {
"@": "src",
Expand All @@ -18,7 +20,9 @@ export default defineConfig({
disableGlobbing: false,
},
},
plugins: [vue()],
plugins: [
vue(),
],
// https://github.com/MrBin99/django-vite#vitejs
// https://vitejs.dev/guide/backend-integration.html
build: {
Expand All @@ -31,16 +35,17 @@ export default defineConfig({
cssCodeSplit: true,

manifest: true,
// As this is in SSR and not in SPA, you don't have an index.html that
// ViteJS can use to determine which files to compile. You need to
// tell it directly.
rollupOptions: {
input: "src/main.ts",
// See: https://ilikerobots.medium.com/django-vue-vite-rest-not-required-ca63cfa558fd
// output: {
// dir: '../<your_django_app_dir>/static/vue/',
// entryFileNames: '[name].js',
// }
},

// // As this is in SSR and not in SPA, you don't have an index.html that
// // ViteJS can use to determine which files to compile. You need to
// // tell it directly.
// rollupOptions: {
// input: "src/main.ts",
// // See: https://ilikerobots.medium.com/django-vue-vite-rest-not-required-ca63cfa558fd
// // output: {
// // dir: '../<your_django_app_dir>/static/vue/',
// // entryFileNames: '[name].js',
// // }
// },
},
});
4 changes: 4 additions & 0 deletions apps/ui/volar.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

// re: Volar Takeover Mode and other oddities
//
// https://vuejs.org/guide/typescript/overview.html#volar-takeover-mode
10 changes: 10 additions & 0 deletions apps/ui/vueform.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// vueform.config.js

import en from '@vueform/vueform/locales/en';
import tailwind from '@vueform/vueform/themes/tailwind';

export default {
theme: tailwind,
locales: { en },
locale: 'en',
}
Loading

0 comments on commit f45ee89

Please sign in to comment.