Skip to content

Commit 76f865f

Browse files
chore: upgrade frappe-ui
1 parent e3f5e70 commit 76f865f

File tree

9 files changed

+716
-186
lines changed

9 files changed

+716
-186
lines changed

frontend/components.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* eslint-disable */
2+
// @ts-nocheck
3+
// Generated by unplugin-vue-components
4+
// Read more: https://github.com/vuejs/core/pull/3399
5+
// biome-ignore lint: disable
6+
export {}
7+
8+
/* prettier-ignore */
9+
declare module 'vue' {
10+
export interface GlobalComponents {
11+
RouterLink: typeof import('vue-router')['RouterLink']
12+
RouterView: typeof import('vue-router')['RouterView']
13+
}
14+
}

frontend/index.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
</head>
99
<body>
1010
<div id="app"></div>
11-
<div id="modals"></div>
12-
<div id="popovers"></div>
13-
14-
<script>
15-
window.csrf_token = '{{ frappe.session.csrf_token }}'
16-
</script>
1711
<script type="module" src="/src/main.js"></script>
1812
</body>
1913
</html>

frontend/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "frappe-ui-frontend",
33
"private": true,
44
"version": "0.0.0",
5+
"type": "module",
56
"scripts": {
67
"dev": "vite",
78
"build": "vite build --base=/assets/linklite/frontend/ && yarn copy-html-entry",
@@ -10,9 +11,9 @@
1011
},
1112
"dependencies": {
1213
"feather-icons": "^4.29.2",
13-
"frappe-ui": "^0.1.98",
14-
"vue": "^3.5.12",
15-
"vue-router": "^4.4.5",
14+
"frappe-ui": "^0.1.168",
15+
"vue": "^3.5.13",
16+
"vue-router": "^4.5.0",
1617
"vue-sonner": "^1.3.0"
1718
},
1819
"devDependencies": {

frontend/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

frontend/src/main.js

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
1-
import './index.css'
1+
import { createApp } from "vue"
22

3-
import { createApp } from 'vue'
4-
import router from './router'
5-
import App from './App.vue'
3+
import App from "./App.vue"
4+
import router from "./router"
5+
import { initSocket } from "./socket"
66

77
import {
8-
Button,
9-
Card,
10-
Input,
11-
setConfig,
12-
frappeRequest,
13-
resourcesPlugin,
14-
} from 'frappe-ui'
8+
Alert,
9+
Badge,
10+
Button,
11+
Dialog,
12+
ErrorMessage,
13+
FormControl,
14+
Input,
15+
TextInput,
16+
frappeRequest,
17+
pageMetaPlugin,
18+
resourcesPlugin,
19+
setConfig,
20+
} from "frappe-ui"
1521

16-
let app = createApp(App)
22+
import "./index.css"
1723

18-
setConfig('resourceFetcher', frappeRequest)
24+
const globalComponents = {
25+
Button,
26+
TextInput,
27+
Input,
28+
FormControl,
29+
ErrorMessage,
30+
Dialog,
31+
Alert,
32+
Badge,
33+
}
34+
35+
const app = createApp(App)
36+
37+
setConfig("resourceFetcher", frappeRequest)
1938

2039
app.use(router)
2140
app.use(resourcesPlugin)
41+
app.use(pageMetaPlugin)
42+
43+
const socket = initSocket()
44+
app.config.globalProperties.$socket = socket
2245

23-
app.component('Button', Button)
24-
app.component('Card', Card)
25-
app.component('Input', Input)
46+
for (const key in globalComponents) {
47+
app.component(key, globalComponents[key])
48+
}
2649

27-
app.mount('#app')
50+
app.mount("#app")

frontend/src/socket.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { io } from "socket.io-client"
2+
import { socketio_port } from "../../../../sites/common_site_config.json"
3+
4+
let socket = null
5+
export function initSocket() {
6+
const host = window.location.hostname
7+
const siteName = window.site_name
8+
const port = window.location.port ? `:${socketio_port}` : ""
9+
const protocol = port ? "http" : "https"
10+
const url = `${protocol}://${host}${port}/${siteName}`
11+
12+
socket = io(url, {
13+
withCredentials: true,
14+
reconnectionAttempts: 5,
15+
})
16+
return socket
17+
}
18+
19+
export function useSocket() {
20+
return socket
21+
}

frontend/tailwind.config.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
module.exports = {
2-
presets: [require('frappe-ui/src/utils/tailwind.config')],
3-
content: [
4-
'./index.html',
5-
'./src/**/*.{vue,js,ts,jsx,tsx}',
6-
'./node_modules/frappe-ui/src/components/**/*.{vue,js,ts,jsx,tsx}',
7-
],
8-
theme: {
9-
extend: {},
10-
},
11-
plugins: [],
1+
import frappeUIPreset from 'frappe-ui/src/tailwind/preset'
2+
3+
export default {
4+
presets: [frappeUIPreset],
5+
content: [
6+
"./index.html",
7+
"./src/**/*.{vue,js,ts,jsx,tsx}",
8+
"./node_modules/frappe-ui/src/components/**/*.{vue,js,ts,jsx,tsx}",
9+
],
10+
theme: {
11+
extend: {},
12+
},
13+
plugins: [],
1214
}

frontend/vite.config.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
1-
import path from 'path'
2-
import { defineConfig } from 'vite'
3-
import vue from '@vitejs/plugin-vue'
4-
import frappeui from 'frappe-ui/vite'
1+
import path from "node:path"
2+
import vue from "@vitejs/plugin-vue"
3+
import frappeui from "frappe-ui/vite"
4+
import { defineConfig } from "vite"
55

66
// https://vitejs.dev/config/
77
export default defineConfig({
8-
plugins: [frappeui(), vue()],
9-
resolve: {
10-
alias: {
11-
'@': path.resolve(__dirname, 'src'),
12-
},
13-
},
14-
build: {
15-
outDir: `../${path.basename(path.resolve('..'))}/public/frontend`,
16-
emptyOutDir: true,
17-
target: 'es2015',
18-
},
19-
optimizeDeps: {
20-
include: ['frappe-ui > feather-icons', 'showdown', 'engine.io-client'],
21-
},
8+
plugins: [
9+
frappeui({
10+
frappeProxy: true,
11+
jinjaBootData: true,
12+
lucideIcons: true,
13+
buildConfig: {
14+
indexHtmlPath: "../linklite/www/frontend.html",
15+
emptyOutDir: true,
16+
sourcemap: true,
17+
},
18+
}),
19+
vue(),
20+
],
21+
build: {
22+
chunkSizeWarningLimit: 1500,
23+
outDir: "../linklite/public/frontend",
24+
emptyOutDir: true,
25+
target: "es2015",
26+
sourcemap: true,
27+
},
28+
resolve: {
29+
alias: {
30+
"@": path.resolve(__dirname, "src"),
31+
"tailwind.config.js": path.resolve(__dirname, "tailwind.config.js"),
32+
},
33+
},
34+
optimizeDeps: {
35+
include: ["feather-icons", "showdown", "highlight.js/lib/core"],
36+
},
37+
server: {
38+
allowedHosts: true,
39+
},
2240
})

0 commit comments

Comments
 (0)