feat(web): adopt vuesax icons and shared skeleton loading

Replace the inline SVG icon set with the vuesax linear pack, add skeleton primitives for loading states, and keep page scroll inside the app shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-05 14:46:35 +03:30
co-authored by Cursor
parent 41f310f3a2
commit 6c6e32e099
133 changed files with 9069 additions and 7416 deletions
+307 -37
View File
@@ -8,8 +8,20 @@ import type { BusinessField, OrganizationMembershipDto } from '@mento/shared';
import UiIcon from '@/components/UiIcon.vue';
import UiModal from '@/components/ui/UiModal.vue';
defineProps<{
compact?: boolean;
const props = withDefaults(
defineProps<{
compact?: boolean;
variant?: 'default' | 'workspace';
}>(),
{
compact: false,
variant: 'default',
},
);
const emit = defineEmits<{
open: [];
close: [];
}>();
const auth = useAuthStore();
@@ -28,10 +40,28 @@ const menuStyle = ref<Record<string, string>>({});
let ignoreDocClickUntil = 0;
const currentName = computed(
() => auth.user?.organizationName || orgs.value.find((o) => o.id === auth.user?.organizationId)?.name || 'محیط کاری',
() =>
auth.user?.organizationName ||
orgs.value.find((o) => o.id === auth.user?.organizationId)?.name ||
'محیط کاری',
);
const currentSubtitle = computed(() => {
const current = orgs.value.find((o) => o.id === auth.user?.organizationId);
if (current?.orgRoleName) return current.orgRoleName;
if (auth.user?.role) return USER_ROLE_LABELS[auth.user.role];
return 'محیط کاری';
});
const currentInitial = computed(() => {
const name = currentName.value.trim();
return name ? name.charAt(0) : 'م';
});
const canSwitch = computed(() => orgs.value.length > 1);
const isWorkspace = computed(() => props.variant === 'workspace');
/** در حالت workspace منو همیشه باز می‌شود (لیست org + محیط جدید)؛ در حالت پیش‌فرض فقط وقتی بیش از یکی باشد */
const menuEnabled = computed(() => isWorkspace.value || canSwitch.value);
function apiError(e: unknown, fallback: string) {
if (axios.isAxiosError(e)) {
@@ -49,34 +79,62 @@ async function loadOrgs() {
}
}
function closeMenu() {
if (!open.value) return;
open.value = false;
emit('close');
}
async function toggle() {
if (!canSwitch.value) return;
if (!menuEnabled.value) return;
error.value = '';
if (open.value) {
open.value = false;
closeMenu();
return;
}
ignoreDocClickUntil = Date.now() + 400;
open.value = true;
emit('open');
await nextTick();
placeMenu();
await loadOrgs();
await nextTick();
placeMenu();
}
function placeMenu() {
const btn = rootEl.value?.querySelector('button');
if (!(btn instanceof HTMLElement)) return;
const box = btn.getBoundingClientRect();
const minWidth = Math.round(Math.max(box.width, isWorkspace.value ? 240 : 200));
const sidebar = document.getElementById('app-sidebar');
const rail = sidebar?.getBoundingClientRect();
// لبهٔ راست منو = لبهٔ چپ سایدبار − ۴px
const edge = rail?.left ?? box.left;
const beside = {
right: 'auto',
left: `${Math.round(edge - 4)}px`,
transform: 'translateX(-100%)',
minWidth: `${minWidth}px`,
};
if (isWorkspace.value) {
menuStyle.value = {
...beside,
top: `${Math.round(box.top)}px`,
bottom: 'auto',
};
return;
}
menuStyle.value = {
bottom: `${Math.round(window.innerHeight - box.top + 6)}px`,
right: `${Math.round(window.innerWidth - box.right)}px`,
minWidth: `${Math.round(Math.max(box.width, 200))}px`,
...beside,
top: 'auto',
bottom: `${Math.round(window.innerHeight - box.bottom)}px`,
};
}
async function choose(org: OrganizationMembershipDto) {
if (org.id === auth.user?.organizationId) {
open.value = false;
closeMenu();
return;
}
loading.value = true;
@@ -91,7 +149,7 @@ async function choose(org: OrganizationMembershipDto) {
}
function openCreate() {
open.value = false;
closeMenu();
newName.value = '';
newField.value = 'personal';
error.value = '';
@@ -123,9 +181,11 @@ function onDocClick(event: MouseEvent) {
const target = event.target;
if (!(target instanceof Node)) return;
if (rootEl.value?.contains(target) || menuEl.value?.contains(target)) return;
open.value = false;
closeMenu();
}
defineExpose({ close: closeMenu });
onMounted(() => {
void loadOrgs();
document.addEventListener('click', onDocClick);
@@ -137,27 +197,46 @@ onUnmounted(() => {
</script>
<template>
<div ref="rootEl" class="org-switch">
<div ref="rootEl" class="org-switch" :class="{ 'org-ws': isWorkspace, compact }">
<button
class="org-btn"
:class="{ compact, static: !canSwitch }"
:class="{
compact,
static: !menuEnabled,
'org-ws': isWorkspace,
open,
}"
type="button"
:title="currentName"
:aria-disabled="!canSwitch"
:aria-expanded="open"
:aria-haspopup="menuEnabled ? 'listbox' : undefined"
:aria-disabled="!menuEnabled"
@click.stop="toggle"
>
<UiIcon name="building" :size="18" />
<span>{{ currentName }}</span>
<template v-if="isWorkspace">
<span class="org-mark" aria-hidden="true">{{ currentInitial }}</span>
<span class="org-copy">
<strong>{{ currentName }}</strong>
<small>{{ currentSubtitle }}</small>
</span>
<i class="org-chev" :class="{ open }" aria-hidden="true" />
</template>
<template v-else>
<UiIcon name="building" :size="18" />
<span>{{ currentName }}</span>
</template>
</button>
<Teleport to="body">
<div
v-if="open && canSwitch"
v-if="open && menuEnabled"
ref="menuEl"
class="menu"
:class="{ 'org-ws': isWorkspace }"
:style="menuStyle"
role="listbox"
aria-label="محیط‌های کاری"
>
<p class="hint">ورود به محیط</p>
<p class="hint">{{ canSwitch ? 'تعویض محیط کاری' : 'محیط کاری' }}</p>
<button
v-for="org in orgs"
:key="org.id"
@@ -165,10 +244,21 @@ onUnmounted(() => {
class="org-item"
:class="{ on: org.id === auth.user?.organizationId }"
:disabled="loading"
role="option"
:aria-selected="org.id === auth.user?.organizationId"
@click="choose(org)"
>
<strong>{{ org.name }}</strong>
<span>{{ org.orgRoleName || USER_ROLE_LABELS[org.role] }}</span>
<span class="org-item-mark" aria-hidden="true">{{ org.name.trim().charAt(0) || 'م' }}</span>
<span class="org-item-copy">
<strong>{{ org.name }}</strong>
<span>{{ org.orgRoleName || USER_ROLE_LABELS[org.role] }}</span>
</span>
<UiIcon
v-if="org.id === auth.user?.organizationId"
class="org-check"
name="check"
:size="16"
/>
</button>
<button type="button" class="create" :disabled="loading" @click="openCreate">
محیط جدید
@@ -234,7 +324,7 @@ onUnmounted(() => {
margin-top: 0.05rem;
}
.org-btn span {
.org-btn > span {
min-width: 0;
white-space: normal;
overflow-wrap: anywhere;
@@ -253,7 +343,7 @@ onUnmounted(() => {
color: #94a3b8;
}
.org-btn.compact {
.org-btn.compact:not(.org-ws) {
display: grid;
place-items: center;
width: 100%;
@@ -262,18 +352,113 @@ onUnmounted(() => {
border-radius: var(--radius);
}
.org-btn.compact span {
.org-btn.compact:not(.org-ws) > span {
display: none;
}
.org-btn.compact:hover {
.org-btn.compact:not(.org-ws):hover {
background: #f8fafc;
}
.org-btn.compact.static:hover {
.org-btn.compact.static:not(.org-ws):hover {
background: transparent;
}
.org-btn.org-ws {
align-items: center;
gap: 0.7rem;
padding: 0.45rem 0.55rem;
border-radius: 16px;
color: #0f172a;
text-align: start;
}
.org-btn.org-ws:hover,
.org-btn.org-ws.open {
background: #f8fafc;
color: #0f172a;
}
.org-btn.org-ws.static:hover {
background: #f8fafc;
color: #0f172a;
}
.org-mark {
width: 36px;
height: 36px;
border-radius: 999px;
display: grid;
place-items: center;
flex-shrink: 0;
background: color-mix(in srgb, var(--accent-soft) 80%, white);
color: var(--accent-deep);
font-size: 0.92rem;
font-weight: 800;
}
.org-copy {
min-width: 0;
flex: 1;
display: grid;
gap: 0.08rem;
}
.org-copy strong {
font-size: 0.92rem;
font-weight: 800;
line-height: 1.25;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.org-copy small {
font-size: 0.72rem;
font-weight: 600;
color: #94a3b8;
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.org-chev {
width: 0.42rem;
height: 0.42rem;
border-right: 1.6px solid #94a3b8;
border-bottom: 1.6px solid #94a3b8;
/* RTL: اشاره به بیرون (چپ) */
transform: rotate(135deg);
transition: transform 0.15s ease;
flex-shrink: 0;
margin-inline-start: 0.15rem;
}
.org-chev.open {
transform: rotate(45deg);
}
.org-btn.compact.org-ws {
display: grid;
place-items: center;
width: 100%;
min-height: var(--control-h);
padding: 0;
border-radius: 14px;
}
.org-btn.compact.org-ws .org-copy,
.org-btn.compact.org-ws .org-chev {
display: none;
}
.org-btn.compact.org-ws .org-mark {
width: 32px;
height: 32px;
font-size: 0.82rem;
}
.menu {
position: fixed;
z-index: 90;
@@ -286,11 +471,21 @@ onUnmounted(() => {
gap: 0.2rem;
}
.menu.org-ws {
padding: 0.5rem;
border-radius: 16px;
border: 1px solid #e8eef3;
box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
gap: 4px;
}
.hint {
margin: 0;
padding: 0.25rem 0.45rem;
font-size: 0.72rem;
color: var(--muted);
padding: 0.35rem 0.65rem 0.45rem;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.02em;
color: #94a3b8;
}
.org-item,
@@ -305,29 +500,104 @@ onUnmounted(() => {
cursor: pointer;
}
.org-item strong {
font-size: 0.82rem;
.menu.org-ws .org-item {
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 0.7rem;
border-radius: 12px;
padding: 0.55rem 0.65rem;
color: #0f172a;
}
.org-item span {
font-size: 0.72rem;
color: var(--muted);
.org-item-mark {
width: 36px;
height: 36px;
border-radius: 999px;
display: grid;
place-items: center;
background: #eef2f7;
color: #475569;
font-size: 0.85rem;
font-weight: 800;
flex-shrink: 0;
}
.org-item-copy {
min-width: 0;
display: grid;
gap: 0.12rem;
}
.org-item strong {
font-size: 0.88rem;
font-weight: 700;
color: #0f172a;
line-height: 1.25;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.org-item span,
.org-item-copy span {
font-size: 0.74rem;
font-weight: 500;
color: #94a3b8;
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.org-check {
color: #0f172a;
flex-shrink: 0;
}
.org-item:hover,
.create:hover {
background: color-mix(in srgb, var(--accent-soft) 70%, white);
background: #f3f4f6;
}
.menu.org-ws .org-item:hover {
background: #f3f4f6;
}
.menu.org-ws .org-item:hover .org-item-mark {
background: #e2e8f0;
}
.org-item.on {
background: var(--accent-soft);
background: #f3f4f6;
}
.menu.org-ws .org-item.on {
background: #f3f4f6;
}
.menu.org-ws .org-item.on .org-item-mark {
background: color-mix(in srgb, var(--accent-soft) 85%, white);
color: var(--accent-deep);
}
.menu.org-ws .org-item.on strong {
font-weight: 800;
color: #0f172a;
}
.create {
margin-top: 0.15rem;
color: var(--accent);
padding: 0.7rem 0.65rem 0.55rem;
border-top: 1px solid #eef2f7;
border-radius: 0 0 12px 12px;
color: var(--accent-deep);
font-weight: 700;
font-size: 0.82rem;
font-size: 0.86rem;
}
.menu.org-ws .create:hover {
background: #f8fafc;
color: #0f766e;
}
.err {