forked from noxious/client
character selection work
This commit is contained in:
parent
2db7fc9905
commit
1febe56a50
11
src/assets/scss/_variables.scss
Normal file
11
src/assets/scss/_variables.scss
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Colors
|
||||||
|
$white: #fff;
|
||||||
|
$black: #000;
|
||||||
|
$purple: #4741e6;
|
||||||
|
$lilac: #7B76FF;
|
||||||
|
$light-blue: #00c2ff;
|
||||||
|
$red: #ff0000;
|
||||||
|
$gray: #7f7f7f;
|
||||||
|
$gray-2: #696969;
|
||||||
|
$dark-gray: #454545;
|
||||||
|
$light-gray: #b1b2b5;
|
@ -1,3 +1,5 @@
|
|||||||
|
@import '@/assets/scss/main';
|
||||||
|
|
||||||
#bg-img {
|
#bg-img {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -33,14 +35,14 @@
|
|||||||
.form-field {
|
.form-field {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
background-color: rgba($white, 0.5);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
min-width: 25rem;
|
min-width: 25rem;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
color: #000;
|
color: $black;
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
background-color: rgba($white, 0.5);
|
||||||
padding: 0.25rem 0.25rem;
|
padding: 0.25rem 0.25rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
border-top-left-radius: 3px;
|
border-top-left-radius: 3px;
|
||||||
@ -71,17 +73,17 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
font-size: 0.65rem;
|
font-size: 0.65rem;
|
||||||
background-color: rgba(71, 65, 230, 0.75);
|
background-color: rgba($purple, 0.75);
|
||||||
border: rgba(255, 255, 255, 0.35) 1px solid;
|
border: rgba($white, 0.35) 1px solid;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
color: white;
|
color: $white;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: rgba(123, 118, 255, 0.75);
|
background-color: rgba($lilac, 0.75);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,13 +95,13 @@
|
|||||||
margin-top: 7rem;
|
margin-top: 7rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
color: #FFF;
|
color: $white;
|
||||||
text-shadow: -1px -1px 0 gray, 1px -1px 0 gray, -1px 1px 0 gray, 1px 1px 0 gray;
|
text-shadow: -1px -1px 0 $gray, 1px -1px 0 $gray, -1px 1px 0 $gray, 1px 1px 0 $gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
p, a, li, label {
|
p, a, li, label {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
color: #FFF;
|
color: $white;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
@ -1,3 +1,6 @@
|
|||||||
|
@import "@/assets/scss/_variables";
|
||||||
|
|
||||||
|
// Fonts
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: GentiumPlus;
|
font-family: GentiumPlus;
|
||||||
src: url('@/assets/fonts/Gentium_plus.ttf');
|
src: url('@/assets/fonts/Gentium_plus.ttf');
|
||||||
@ -6,7 +9,7 @@
|
|||||||
body {
|
body {
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
background: black;
|
background: $black;
|
||||||
|
|
||||||
// Disable selection, might wanna comment when debugging
|
// Disable selection, might wanna comment when debugging
|
||||||
-webkit-user-select: none; /* Safari */
|
-webkit-user-select: none; /* Safari */
|
@ -10,6 +10,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@import '@/assets/scss/main';
|
||||||
|
|
||||||
.chat-wrapper {
|
.chat-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
@ -24,8 +26,8 @@
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
padding: 0 1.5rem;
|
padding: 0 1.5rem;
|
||||||
background-color: rgba(255, 255, 255, 0.85);
|
background-color: rgba($white, 0.85);
|
||||||
border: 2px solid #fff;
|
border: 2px solid $white;
|
||||||
color: black;
|
color: black;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@import '@/assets/scss/main';
|
||||||
|
|
||||||
.hud-wrapper {
|
.hud-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
.profile {
|
.profile {
|
||||||
@ -22,9 +24,9 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
width: 4rem;
|
width: 4rem;
|
||||||
height: 4rem;
|
height: 4rem;
|
||||||
background-color: rgba(255, 255, 255, 0.8);
|
background-color: rgba($white, 0.8);
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
border: 2px solid #fff;
|
border: 2px solid $white;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
img {
|
img {
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
@ -46,7 +48,7 @@
|
|||||||
// background-color: rgba(127, 127, 127, 0.7);
|
// background-color: rgba(127, 127, 127, 0.7);
|
||||||
clip-path: ellipse(3rem 3rem at 0% 0%) invert;
|
clip-path: ellipse(3rem 3rem at 0% 0%) invert;
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
border: 2px solid #fff;
|
border: 2px solid $white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -34,71 +34,73 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.menu-wrapper {
|
@import '@/assets/scss/main';
|
||||||
.menu {
|
|
||||||
list-style: none;
|
|
||||||
display: flex;
|
|
||||||
gap: 1.25rem;
|
|
||||||
|
|
||||||
.menu-item {
|
.menu-wrapper {
|
||||||
position: relative;
|
.menu {
|
||||||
p {
|
list-style: none;
|
||||||
position: absolute;
|
display: flex;
|
||||||
bottom: 3.125rem;
|
gap: 1.25rem;
|
||||||
width: 4rem;
|
|
||||||
text-align: center;
|
|
||||||
background-color: #B1B2B5;
|
|
||||||
border: 2px solid #fff;
|
|
||||||
border-radius: 1.5rem;
|
|
||||||
height: 1.5rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.5rem;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
display: none;
|
|
||||||
|
|
||||||
&::after {
|
.menu-item {
|
||||||
content: '';
|
position: relative;
|
||||||
position: absolute;
|
p {
|
||||||
top: 100%;
|
position: absolute;
|
||||||
background-color: #fff;
|
bottom: 3.125rem;
|
||||||
height: 0.5rem;
|
width: 4rem;
|
||||||
width: 0.875rem;
|
text-align: center;
|
||||||
clip-path: polygon(100% 0, 0 0, 50% 100%);
|
background-color: #B1B2B5;
|
||||||
left: calc(50% - 0.4375rem);
|
border: 2px solid $white;
|
||||||
}
|
border-radius: 1.5rem;
|
||||||
}
|
height: 1.5rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
line-height: 1.5rem;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
display: none;
|
||||||
|
|
||||||
a {
|
&::after {
|
||||||
padding: 0.5rem;
|
content: '';
|
||||||
background-color: rgba(127, 127, 127, 0.7);
|
position: absolute;
|
||||||
border: 2px solid #fff;
|
top: 100%;
|
||||||
border-radius: 100%;
|
background-color: $white;
|
||||||
display: block;
|
height: 0.5rem;
|
||||||
width: 1.875rem;
|
width: 0.875rem;
|
||||||
height: 1.875rem;
|
clip-path: polygon(100% 0, 0 0, 50% 100%);
|
||||||
|
left: calc(50% - 0.4375rem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
a {
|
||||||
width: inherit;
|
padding: 0.5rem;
|
||||||
height: inherit;
|
background-color: rgba(127, 127, 127, 0.7);
|
||||||
}
|
border: 2px solid $white;
|
||||||
}
|
border-radius: 100%;
|
||||||
|
display: block;
|
||||||
|
width: 1.875rem;
|
||||||
|
height: 1.875rem;
|
||||||
|
|
||||||
&:hover {
|
img {
|
||||||
p {
|
width: inherit;
|
||||||
display: block;
|
height: inherit;
|
||||||
}
|
}
|
||||||
a {
|
}
|
||||||
background-image: url('/assets/galaxy.png');
|
|
||||||
background-position: center;
|
&:hover {
|
||||||
background-size: cover;
|
p {
|
||||||
img {
|
display: block;
|
||||||
-webkit-filter: drop-shadow(0px 3px 6px #000);
|
}
|
||||||
filter: drop-shadow(0px 3px 6px #000);
|
a {
|
||||||
}
|
background-image: url('/assets/galaxy.png');
|
||||||
}
|
background-position: center;
|
||||||
}
|
background-size: cover;
|
||||||
}
|
img {
|
||||||
}
|
-webkit-filter: drop-shadow(0px 3px 6px $black);
|
||||||
}
|
filter: drop-shadow(0px 3px 6px $black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="character-select-screen">
|
||||||
<div class="characters-wrapper">
|
<div class="ui-wrapper">
|
||||||
<div class="list">
|
<div class="characters-wrapper">
|
||||||
<div v-for="character in characters" :key="character.id" class="character">
|
<div v-for="character in characters" :key="character.id" class="character">
|
||||||
<input type="radio" :id="character.id" name="character" :value="character.id" v-model="selected_character" />
|
<input type="radio" :id="character.id" name="character" :value="character.id" v-model="selected_character" />
|
||||||
<label :for="character.id">
|
<label :for="character.id">
|
||||||
@ -13,94 +13,136 @@
|
|||||||
|
|
||||||
<div class="buttons-wrapper">
|
<div class="buttons-wrapper">
|
||||||
<button @click="select_character()">Play</button>
|
<button @click="select_character()">Play</button>
|
||||||
<button @click="openCreator">Create New</button>
|
<button @click="isModalOpen = true">Create New</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<Create :isOpen="isCharacterCreatorOpened" @modal-close="closeCreator" @submit="submitHandler" name="character-create" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Modal :isModalOpen="isModalOpen">
|
||||||
|
<form method="post" @submit.prevent="create">
|
||||||
|
<h1>Create your character</h1>
|
||||||
|
<div>
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input v-model="name" name="name" id="name">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button @click="create">Create</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<button @click="isModalOpen = false">Cancel</button>
|
||||||
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSocketStore } from '@/stores/socket'
|
import { useSocketStore } from '@/stores/socket'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import Create from '@/components/screens/partials/characters/Create.vue'
|
|
||||||
import type { Character } from '../../../env'
|
import type { Character } from '../../../env'
|
||||||
|
import Modal from '@/components/utilities/Modal.vue'
|
||||||
|
|
||||||
const socket = useSocketStore();
|
const socket = useSocketStore();
|
||||||
const characters = ref([]);
|
|
||||||
socket.getConnection.emit('character:list');
|
|
||||||
|
|
||||||
|
// Fetch characters
|
||||||
|
socket.getConnection.emit('character:list');
|
||||||
socket.getConnection.on('character:list', (data: any) => {
|
socket.getConnection.on('character:list', (data: any) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
characters.value = data;
|
characters.value = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Select character logics
|
||||||
|
const characters = ref([]);
|
||||||
const selected_character = ref(null);
|
const selected_character = ref(null);
|
||||||
function select_character() {
|
function select_character() {
|
||||||
console.log(selected_character.value);
|
console.log(selected_character.value);
|
||||||
if (selected_character.value) {
|
if (selected_character.value) {
|
||||||
socket.getConnection.emit('character:connect', {character_id: selected_character.value});
|
socket.getConnection.emit('character:connect', {character_id: selected_character.value});
|
||||||
socket.getConnection.on('character:connect', (data: Character) => {
|
socket.getConnection.on('character:connect', (data: Character) => socket.setCharacter(data));
|
||||||
socket.setCharacter(data);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCharacterCreatorOpened = ref(false);
|
// Create character logics
|
||||||
|
const isModalOpen = ref(false);
|
||||||
const openCreator = () => {
|
let name: any = ref('');
|
||||||
isCharacterCreatorOpened.value = true;
|
function create() {
|
||||||
};
|
socket.getConnection.emit('character:create', { name: name.value });
|
||||||
const closeCreator = () => {
|
name.value = '';
|
||||||
isCharacterCreatorOpened.value = false;
|
isModalOpen.value = false;
|
||||||
};
|
|
||||||
|
|
||||||
const submitHandler = ()=>{
|
|
||||||
//here you do whatever
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.characters-wrapper {
|
@import '@/assets/scss/main';
|
||||||
// vertical and vertical center
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list {
|
.character-select-screen {
|
||||||
display: flex;
|
background-image: url("/assets/bglogin.png");
|
||||||
flex-wrap: wrap;
|
.ui-wrapper {
|
||||||
justify-content: center;
|
// vertical and vertical center
|
||||||
|
height: 100vh;
|
||||||
// make all the divs same width
|
|
||||||
div {
|
|
||||||
width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide the radio buttons
|
|
||||||
input[type="radio"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
// img under the label
|
|
||||||
label {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 10px;
|
gap: 6.25rem;
|
||||||
}
|
padding: 0 5rem;
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
|
||||||
// for selected radio, give bg color
|
}
|
||||||
input[type="radio"]:checked + label {
|
|
||||||
background: #ff0000;
|
.characters-wrapper {
|
||||||
padding: 5px;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 5rem;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.character {
|
||||||
|
min-width: 150px;
|
||||||
|
min-height: 250px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background-color: rgba($white, 0.8);
|
||||||
|
border-radius: 20px;
|
||||||
|
position: relative;
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
background-color: rgba($purple, 0.6);
|
||||||
|
border-top-left-radius: 20px;
|
||||||
|
border-top-right-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide the radio buttons
|
||||||
|
input[type="radio"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
// img under the label
|
||||||
|
label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for selected radio, give bg color
|
||||||
|
input[type="radio"]:checked + label {
|
||||||
|
background: rgba($purple, 0.6);
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons-wrapper {
|
||||||
|
display: flex;
|
||||||
|
gap: 30px;
|
||||||
|
button {
|
||||||
|
padding: 5px 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
@ -78,5 +78,5 @@ async function registerFunc() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/assets/login";
|
@import "@/assets/scss/login";
|
||||||
</style>
|
</style>
|
@ -1,42 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="create-container" v-if="isOpen">
|
|
||||||
<form method="post" @submit.prevent="create">
|
|
||||||
<h1>Create your character</h1>
|
|
||||||
<div>
|
|
||||||
<label for="name">Name</label>
|
|
||||||
<input v-model="name" type="text" name="name" id="name">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button @click.stop="create">Create</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<button @click.stop="emit('modal-close')">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useSocketStore } from '@/stores/socket'
|
|
||||||
import { ref, defineEmits, defineProps } from 'vue'
|
|
||||||
import {onClickOutside} from '@vueuse/core'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
isOpen: Boolean
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(["modal-close"]);
|
|
||||||
|
|
||||||
const target = ref(null)
|
|
||||||
onClickOutside(target, () => emit('modal-close'));
|
|
||||||
|
|
||||||
const socket = useSocketStore();
|
|
||||||
|
|
||||||
// const emit = defineEmits(['character:create']);
|
|
||||||
let name: any = ref('');
|
|
||||||
|
|
||||||
function create() {
|
|
||||||
socket.getConnection.emit('character:create', { name: name.value });
|
|
||||||
// emit('character:create');
|
|
||||||
name.value = '';
|
|
||||||
props.isOpen = false;
|
|
||||||
}
|
|
||||||
</script>
|
|
99
src/components/utilities/Modal.vue
Normal file
99
src/components/utilities/Modal.vue
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<template>
|
||||||
|
<Teleport to="body" v-if="isModalOpen">
|
||||||
|
<div class="modal-container" :style="{ top: y + 'px', left: x + 'px' }">
|
||||||
|
<div class="modal-header" @mousedown="startDrag">
|
||||||
|
<h3>Modal</h3>
|
||||||
|
<button @click="close">X</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { defineEmits, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
|
const properties = defineProps({
|
||||||
|
isModalOpen: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const isModalOpen = ref(properties.isModalOpen);
|
||||||
|
const emit = defineEmits(["modal:close", "character:create"]);
|
||||||
|
|
||||||
|
function close () {
|
||||||
|
emit('modal:close');
|
||||||
|
}
|
||||||
|
|
||||||
|
// make modal draggable
|
||||||
|
let startX = 0;
|
||||||
|
let startY = 0;
|
||||||
|
let initialX = 0;
|
||||||
|
let initialY = 0;
|
||||||
|
const x = ref(0);
|
||||||
|
const y = ref(0);
|
||||||
|
const isDragging = ref(false);
|
||||||
|
|
||||||
|
const startDrag = (event: MouseEvent) => {
|
||||||
|
isDragging.value = true;
|
||||||
|
startX = event.clientX;
|
||||||
|
startY = event.clientY;
|
||||||
|
initialX = x.value;
|
||||||
|
initialY = y.value;
|
||||||
|
event.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
|
const drag = (event: MouseEvent) => {
|
||||||
|
if (!isDragging.value) return;
|
||||||
|
const dx = event.clientX - startX;
|
||||||
|
const dy = event.clientY - startY;
|
||||||
|
x.value = initialX + dx;
|
||||||
|
y.value = initialY + dy;
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopDrag = () => {
|
||||||
|
isDragging.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
addEventListener('mousemove', drag);
|
||||||
|
addEventListener('mouseup', stopDrag);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
removeEventListener('mousemove', drag);
|
||||||
|
removeEventListener('mouseup', stopDrag);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '@/assets/scss/main';
|
||||||
|
|
||||||
|
.modal-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 30%;
|
||||||
|
height: 40%;
|
||||||
|
border-radius: 30px;
|
||||||
|
background-color: #cfcfcf;
|
||||||
|
z-index: 999;
|
||||||
|
|
||||||
|
// make draggable
|
||||||
|
.modal-header {
|
||||||
|
cursor: move;
|
||||||
|
background-color: #333;
|
||||||
|
color: white;
|
||||||
|
padding: 3px 15px;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,4 +1,4 @@
|
|||||||
import './assets/main.scss'
|
import './assets/scss/main.scss'
|
||||||
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user