Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ui): reorganize imports #1802

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/src/renderer/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ElementI18nMap, useSettingsStore } from '@mqttx/ui'
import { ElementI18nMap } from '@mqttx/ui/i18n'
import { useSettingsStore } from '@mqttx/ui/stores'

const settingsStore = useSettingsStore()
console.log('MQTTX Desktop App init...')
Expand Down
8 changes: 6 additions & 2 deletions apps/desktop/src/renderer/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { i18n, pinia, useSettingsStore } from '@mqttx/ui'
import { i18n } from '@mqttx/ui/i18n'
import { useSettingsStore } from '@mqttx/ui/stores'
import { createPinia } from 'pinia'
import { createApp } from 'vue'

import App from './App.vue'
import { router } from './router'

import '@mqttx/ui/dist/style.css'
import '@mqttx/ui/styles.scss'
import './assets/scss/main.scss'

// Create Vue
const app = createApp(App)

const pinia = createPinia()

app.use(router).use(pinia)

// I18n
Expand Down
6 changes: 5 additions & 1 deletion apps/desktop/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import baseConfig from '@mqttx/tailwind-config/base.config'

const config: Config = {
presets: [baseConfig],
content: ['./src/renderer/index.html', './src/renderer/src/**/*.{vue,js,ts,jsx,tsx}'],
content: [
'./src/renderer/index.html',
'./src/renderer/src/**/*.{vue,js,ts,jsx,tsx}',
'../../packages/ui/src/**/*.{vue,js,ts,jsx,tsx}',
],
}

export default config
1 change: 1 addition & 0 deletions apps/desktop/tsconfig.web.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"moduleResolution": "bundler",
"paths": {
"@renderer/*": ["src/renderer/src/*"]
},
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ElementI18nMap, useSettingsStore } from '@mqttx/ui'
import { ElementI18nMap } from '@mqttx/ui/i18n'
import { useSettingsStore } from '@mqttx/ui/stores'

const settingsStore = useSettingsStore()
console.log('MQTTX Web App init...')
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { i18n, pinia, useSettingsStore } from '@mqttx/ui'
import { i18n } from '@mqttx/ui/i18n'
import { useSettingsStore } from '@mqttx/ui/stores'
import { createPinia } from 'pinia'
import { createApp } from 'vue'

import App from './App.vue'
import { router } from './router'

import '@mqttx/ui/dist/style.css'
import '@mqttx/ui/styles.scss'
import './assets/scss/main.scss'

// Create Vue
const app = createApp(App)

const pinia = createPinia()

app.use(router).use(pinia)

// I18n
Expand Down
6 changes: 5 additions & 1 deletion apps/web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { Config } from 'tailwindcss'
import baseConfig from '@mqttx/tailwind-config/base.config'

const config: Config = {
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
content: [
'./index.html',
'./src/**/*.{vue,js,ts,jsx,tsx}',
'../../packages/ui/src/**/*.{vue,js,ts,jsx,tsx}',
],
presets: [baseConfig],
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"repository": "https://github.com/emqx/MQTTX",
"scripts": {
"prepare": "husky install",
"postinstall": "pnpm run generate:ui",
"dev": "turbo run dev",
"dev:desktop": "turbo run dev --filter @mqttx/desktop",
"dev:web": "turbo run dev --filter @mqttx/web",
Expand Down
18 changes: 12 additions & 6 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"name": "@mqttx/ui",
"type": "module",
"version": "0.0.0",
"exports": {
".": "./src/index.ts",
"./i18n": "./src/i18n/index.ts",
"./stores": "./src/stores/index.ts",
"./styles.scss": "./src/styles/index.scss"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand All @@ -14,12 +20,12 @@
"test:dev": "vitest"
},
"peerDependencies": {
"@element-plus/icons-vue": "^2.1.0",
"element-plus": "^2.4.1",
"pinia": "^2.1.7",
"vue": "^3.3.4",
"vue-i18n": "9",
"vue-router": "4"
"@element-plus/icons-vue": "^2.3.1",
"element-plus": "^2.8.7",
"pinia": "^2.2.6",
"vue": "^3.5.12",
"vue-i18n": "^10.0.4",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@mqttx/core": "workspace:*",
Expand Down
10 changes: 5 additions & 5 deletions packages/ui/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Lang } from 'mqttx'
import ElementPlusEN from 'element-plus/dist/locale/en.mjs'
import ElementPlusHU from 'element-plus/dist/locale/hu.mjs'
import ElementPlusJA from 'element-plus/dist/locale/ja.mjs'
import ElementPlusTR from 'element-plus/dist/locale/tr.mjs'
import ElementPlusZH from 'element-plus/dist/locale/zh-cn.mjs'
import ElementPlusEN from 'element-plus/es/locale/lang/en'
import ElementPlusHU from 'element-plus/es/locale/lang/hu'
import ElementPlusJA from 'element-plus/es/locale/lang/ja'
import ElementPlusTR from 'element-plus/es/locale/lang/tr'
import ElementPlusZH from 'element-plus/es/locale/lang/zh-cn'
import { createI18n } from 'vue-i18n'

export const ElementI18nMap: Record<Lang, any> = {
Expand Down
3 changes: 0 additions & 3 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import MainView from './components/common/MainView.vue'
import SplitView from './components/common/SplitView.vue'
import ConnectionDetailsView from './components/connections/DetailsView.vue'
import ConnectionListView from './components/connections/ListView.vue'
import 'element-plus/dist/index.css'
import './styles/index.scss'
import './assets/fonts/iconfont'

export const pinia = createPinia()

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@forward './tailwind.scss';
// FIXME: fix iconfont
@forward '../assets/fonts/iconfont.css';
// @forward '../assets/fonts/iconfont.css';
@forward './normalize.scss';
@forward './connections.scss';

Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
declare module 'element-plus/dist/locale/*.mjs'
Loading
Loading