changes
This commit is contained in:
@@ -262,7 +262,6 @@ $containers: ("3xs", "2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ─── Shared keywords (auto, px, full, min, max, fit) ───────────────────────
|
// ─── Shared keywords (auto, px, full, min, max, fit) ───────────────────────
|
||||||
// These are identical in value across w-, h-, and size-
|
|
||||||
$shared-keywords: (
|
$shared-keywords: (
|
||||||
"auto": auto,
|
"auto": auto,
|
||||||
"px": 1px,
|
"px": 1px,
|
||||||
@@ -281,7 +280,6 @@ $shared-keywords: (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ─── Viewport keywords ─────────────────────────────────────────────────────
|
// ─── Viewport keywords ─────────────────────────────────────────────────────
|
||||||
// dvw/dvh/lvw/lvh/svw/svh apply equally to w-, h-, and size-
|
|
||||||
$viewport-keywords: (
|
$viewport-keywords: (
|
||||||
"dvw": 100dvw,
|
"dvw": 100dvw,
|
||||||
"dvh": 100dvh,
|
"dvh": 100dvh,
|
||||||
@@ -305,3 +303,68 @@ $viewport-keywords: (
|
|||||||
.h-screen {
|
.h-screen {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Inset / positional offset classes ────────────────────────────────────
|
||||||
|
$inset-types: (
|
||||||
|
"inset": (
|
||||||
|
top,
|
||||||
|
right,
|
||||||
|
bottom,
|
||||||
|
left,
|
||||||
|
),
|
||||||
|
"inset-x": (
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
),
|
||||||
|
"inset-y": (
|
||||||
|
top,
|
||||||
|
bottom,
|
||||||
|
),
|
||||||
|
"top": (
|
||||||
|
top,
|
||||||
|
),
|
||||||
|
"right": (
|
||||||
|
right,
|
||||||
|
),
|
||||||
|
"bottom": (
|
||||||
|
bottom,
|
||||||
|
),
|
||||||
|
"left": (
|
||||||
|
left,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// ─── Numeric: 0 → 48, using the same --spacing scale ──────────────────────
|
||||||
|
@each $prefix, $props in $inset-types {
|
||||||
|
@for $i from 0 through 48 {
|
||||||
|
.#{$prefix}-#{$i} {
|
||||||
|
@include set-props($props, calc(var(--spacing) * #{$i}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Fractions ─────────────────────────────────────────────────────────────
|
||||||
|
@each $prefix, $props in $inset-types {
|
||||||
|
@each $name, $pair in $fractions {
|
||||||
|
$num: list.nth($pair, 1);
|
||||||
|
$den: list.nth($pair, 2);
|
||||||
|
.#{$prefix}-#{$name} {
|
||||||
|
@include set-props($props, calc(#{$num} / #{$den} * 100%));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Keywords ──────────────────────────────────────────────────────────────
|
||||||
|
$inset-keywords: (
|
||||||
|
"auto": auto,
|
||||||
|
"px": 1px,
|
||||||
|
"full": 100%,
|
||||||
|
);
|
||||||
|
|
||||||
|
@each $prefix, $props in $inset-types {
|
||||||
|
@each $name, $value in $inset-keywords {
|
||||||
|
.#{$prefix}-#{$name} {
|
||||||
|
@include set-props($props, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<Teleport
|
<Teleport
|
||||||
v-if="Object.values(props).some((x) => isNotNil(x))"
|
defer
|
||||||
to="#__nuxt > div"
|
to="#modals"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
:id="id"
|
||||||
class="modal is-active has-text-text-20"
|
class="modal is-active has-text-text-20"
|
||||||
@click="doClick"
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="modal-background"
|
class="modal-background"
|
||||||
:style="`opacity:${count === 0 ? 0.7 : 0.3} !important;`"
|
@click="closeModal"
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
class="modal-card"
|
class="modal-card"
|
||||||
:id="docid"
|
|
||||||
:style="{
|
:style="{
|
||||||
width: $store.viewport <= 1 ? 'calc(100% - 2rem)' : width || '60%',
|
width: $store.viewport <= 1 ? 'calc(100% - 2rem)' : width || '60%',
|
||||||
}"
|
}"
|
||||||
@@ -29,14 +28,12 @@
|
|||||||
<button
|
<button
|
||||||
class="delete is-medium"
|
class="delete is-medium"
|
||||||
aria-label="close"
|
aria-label="close"
|
||||||
@click="closeModal()"
|
@click="closeModal"
|
||||||
></button>
|
></button>
|
||||||
</header>
|
</header>
|
||||||
<section
|
<section
|
||||||
class="modal-card-body p-4"
|
class="modal-card-body p-4"
|
||||||
:style="{
|
:style="{ minHeight: height || '750px' }"
|
||||||
minHeight: height || '750px',
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="resolvedComponent"
|
:is="resolvedComponent"
|
||||||
@@ -53,10 +50,9 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, defineAsyncComponent, shallowRef, watchEffect } from "vue";
|
import { onMounted, defineAsyncComponent, shallowRef, watchEffect } from "vue";
|
||||||
import { isNotNil } from "es-toolkit";
|
|
||||||
|
|
||||||
const emit = defineEmits(["close", "remove", "select", "dataevent", "update"]);
|
const emit = defineEmits(["close", "remove", "select", "dataevent", "update"]);
|
||||||
const { $id, $store } = useNuxtApp();
|
const { $store } = useNuxtApp();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
component: String,
|
component: String,
|
||||||
@@ -67,7 +63,6 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const componentFiles = import.meta.glob("@/components/**/*.vue");
|
const componentFiles = import.meta.glob("@/components/**/*.vue");
|
||||||
|
|
||||||
const resolvedComponent = shallowRef(null);
|
const resolvedComponent = shallowRef(null);
|
||||||
|
|
||||||
function loadDynamicComponent() {
|
function loadDynamicComponent() {
|
||||||
@@ -77,7 +72,6 @@ function loadDynamicComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fullPath = `/components/${props.component}.vue`;
|
const fullPath = `/components/${props.component}.vue`;
|
||||||
|
|
||||||
const componentPath = Object.keys(componentFiles).find((path) => path.endsWith(fullPath));
|
const componentPath = Object.keys(componentFiles).find((path) => path.endsWith(fullPath));
|
||||||
|
|
||||||
if (componentPath) {
|
if (componentPath) {
|
||||||
@@ -93,13 +87,16 @@ watchEffect(() => {
|
|||||||
loadDynamicComponent();
|
loadDynamicComponent();
|
||||||
});
|
});
|
||||||
|
|
||||||
const docid = $id();
|
const id = useId();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const lock = false;
|
|
||||||
|
|
||||||
const closeModal = () => {
|
function closeModal() {
|
||||||
if (!lock) emit("close");
|
const modals = document.getElementById("modals");
|
||||||
};
|
const isTopMost = modals.lastElementChild?.id === id;
|
||||||
|
if (isTopMost) {
|
||||||
|
emit("close");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const modalEvent = function (ev) {
|
const modalEvent = function (ev) {
|
||||||
if (ev.name === "select") {
|
if (ev.name === "select") {
|
||||||
@@ -113,24 +110,13 @@ const modalEvent = function (ev) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const doClick = function (e) {
|
|
||||||
if (!e.srcElement.offsetParent) return;
|
|
||||||
const el = document.getElementById(docid);
|
|
||||||
if (el && !el.contains(e.target)) {
|
|
||||||
closeModal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const modalHasProps = Object.values(props).some((x) => isNotNil(x));
|
document.documentElement.classList.add("is-clipped");
|
||||||
if (modalHasProps) {
|
window.addEventListener("keydown", (e) => {
|
||||||
document.documentElement.classList.add("is-clipped");
|
if (e.key === "Escape") closeModal();
|
||||||
window.addEventListener("keydown", (e) => {
|
});
|
||||||
if (e.key === "Escape") closeModal();
|
const collection = document.getElementsByClassName("modal-background");
|
||||||
});
|
count = collection.length;
|
||||||
const collection = document.getElementsByClassName("modal-background");
|
|
||||||
count = collection.length;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -139,7 +125,39 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
footer {
|
.modal {
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-background {
|
||||||
|
position: fixed;
|
||||||
|
--bulma-modal-background-background-color: hsla(
|
||||||
|
var(--bulma-scheme-h),
|
||||||
|
var(--bulma-scheme-s),
|
||||||
|
var(--bulma-scheme-invert-l),
|
||||||
|
0.7
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card-body {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card:not(:has(.modal-card-head)) .modal-card-body {
|
||||||
|
border-start-start-radius: var(--bulma-radius-large);
|
||||||
|
border-start-end-radius: var(--bulma-radius-large);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card:has(.modal-card-foot:empty) .modal-card-body {
|
||||||
|
border-end-start-radius: var(--bulma-radius-large);
|
||||||
|
border-end-end-radius: var(--bulma-radius-large);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card-foot {
|
||||||
background-color: var(--bulma-modal-card-body-background-color);
|
background-color: var(--bulma-modal-card-body-background-color);
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|||||||
@@ -135,9 +135,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showmodal"
|
||||||
|
v-bind="showmodal"
|
||||||
@dataevent="dataevent"
|
@dataevent="dataevent"
|
||||||
@close="showmodal = undefined"
|
@close="showmodal = undefined"
|
||||||
v-bind="showmodal"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -155,6 +155,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showmodal"
|
||||||
v-bind="showmodal"
|
v-bind="showmodal"
|
||||||
@close="showmodal = undefined"
|
@close="showmodal = undefined"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ async function createProduct() {
|
|||||||
first: true,
|
first: true,
|
||||||
clearable: true,
|
clearable: true,
|
||||||
placeholder: 'Bộ nhớ ngoài',
|
placeholder: 'Bộ nhớ ngoài',
|
||||||
|
position: 'is-top-right',
|
||||||
addon: {
|
addon: {
|
||||||
component: 'imports/addons/AddExternalStorage',
|
component: 'imports/addons/AddExternalStorage',
|
||||||
width: '70%',
|
width: '70%',
|
||||||
@@ -304,6 +305,7 @@ async function createProduct() {
|
|||||||
first: true,
|
first: true,
|
||||||
clearable: true,
|
clearable: true,
|
||||||
placeholder: 'Chỉ số IP',
|
placeholder: 'Chỉ số IP',
|
||||||
|
position: 'is-top-right',
|
||||||
addon: {
|
addon: {
|
||||||
component: 'imports/addons/AddIPRating',
|
component: 'imports/addons/AddIPRating',
|
||||||
width: '70%',
|
width: '70%',
|
||||||
@@ -326,6 +328,7 @@ async function createProduct() {
|
|||||||
first: true,
|
first: true,
|
||||||
clearable: true,
|
clearable: true,
|
||||||
placeholder: 'Chất liệu',
|
placeholder: 'Chất liệu',
|
||||||
|
position: 'is-top-right',
|
||||||
addon: {
|
addon: {
|
||||||
component: 'imports/addons/AddDesign',
|
component: 'imports/addons/AddDesign',
|
||||||
width: '70%',
|
width: '70%',
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ async function deleteProduct() {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showConfirmModal"
|
||||||
v-bind="showConfirmModal"
|
v-bind="showConfirmModal"
|
||||||
@close="showConfirmModal = null"
|
@close="showConfirmModal = null"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ async function deleteVariant() {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showConfirmModal"
|
||||||
v-bind="showConfirmModal"
|
v-bind="showConfirmModal"
|
||||||
@close="showConfirmModal = null"
|
@close="showConfirmModal = null"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const showModal = ref(null);
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showModal"
|
||||||
v-bind="showModal"
|
v-bind="showModal"
|
||||||
@close="showModal = null"
|
@close="showModal = null"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
<Modal
|
||||||
|
v-if="showmodal"
|
||||||
v-bind="showmodal"
|
v-bind="showmodal"
|
||||||
@close="showmodal = undefined"
|
@close="showmodal = undefined"
|
||||||
@files="getFiles"
|
@files="getFiles"
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
const activeModals = ref([]);
|
|
||||||
|
|
||||||
export default function useModal() {
|
|
||||||
function open(component, options = {}) {
|
|
||||||
const id = Date.now() + Math.random();
|
|
||||||
const modal = {
|
|
||||||
id,
|
|
||||||
component,
|
|
||||||
title: options.title,
|
|
||||||
width: options.width,
|
|
||||||
height: options.height,
|
|
||||||
vbind: options.props || {},
|
|
||||||
onClose: options.onClose,
|
|
||||||
onEvent: options.onEvent,
|
|
||||||
...options,
|
|
||||||
};
|
|
||||||
activeModals.value.push(modal);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function close(id) {
|
|
||||||
const index = activeModals.value.findIndex((m) => m.id === id);
|
|
||||||
if (index !== -1) {
|
|
||||||
const modal = activeModals.value[index];
|
|
||||||
modal.onClose?.();
|
|
||||||
activeModals.value.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function send(id, eventName, data) {
|
|
||||||
const modal = activeModals.value.find((m) => m.id === id);
|
|
||||||
modal?.onEvent?.({ name: eventName, data });
|
|
||||||
}
|
|
||||||
return { modals: activeModals, open, close, send };
|
|
||||||
}
|
|
||||||
@@ -11,15 +11,16 @@
|
|||||||
@close="$store.snackbar = undefined"
|
@close="$store.snackbar = undefined"
|
||||||
/>
|
/>
|
||||||
</Transition>
|
</Transition>
|
||||||
<Modal
|
<div
|
||||||
v-bind="$store.showmodal"
|
id="modals"
|
||||||
@close="$store.showmodal = undefined"
|
class="absolute top-0"
|
||||||
/>
|
>
|
||||||
<!-- <Modal2
|
<Modal
|
||||||
v-for="modal in modals"
|
v-if="$store.showmodal"
|
||||||
:key="modal.id"
|
v-bind="$store.showmodal"
|
||||||
v-bind="modal"
|
@close="$store.showmodal = undefined"
|
||||||
/> -->
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user