drag drop

This commit is contained in:
Peter Hoppe
2023-01-12 15:43:44 +01:00
parent 25185d3758
commit 06849fe684
7 changed files with 43 additions and 12 deletions

View File

@ -12,6 +12,16 @@
justify-content: center; justify-content: center;
} }
.prevUplImg
{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
@media print @media print
{ {
.noprint .noprint

View File

@ -39,7 +39,7 @@ const Dog = () =>
<p>phone: {phone}</p> <p>phone: {phone}</p>
<p>pic: {picPath}</p> <p>pic: {picPath}</p>
<p>qr: {qrPath}</p> */} <p>qr: {qrPath}</p> */}
<Img pth={picPath} /> <Img pth={picPath} className=''/>
<DogNameTxt name={name} email={email} phone={phone} /> <DogNameTxt name={name} email={email} phone={phone} />
</div> </div>
: :

View File

@ -1,10 +1,10 @@
import React from 'react' import React from 'react'
export default function Img({pth}: {pth: string}) export default function Img({pth, className}: {pth: string, className: string | undefined})
{ {
return ( return (
<div> <div>
<img src={'./uploads' + pth} /> <img className={className} src={'./uploads' + pth} />
</div> </div>
) )
} }

View File

@ -75,6 +75,7 @@ function PreviewUpload({chgFile}:{chgFile: any}) {
onChange={handleChange} onChange={handleChange}
accept="image/jpg,.gif,.png,.svg,.webp audio/wav,.mp3" accept="image/jpg,.gif,.png,.svg,.webp audio/wav,.mp3"
/> />
<div className='prevUplImg'>
<img <img
src={file} src={file}
style={{ style={{
@ -84,6 +85,7 @@ function PreviewUpload({chgFile}:{chgFile: any}) {
maxHeight: '300px', maxHeight: '300px',
}} }}
/> />
</div>
{file && <p>Dimensions: {`${dimensionWidth} x ${dimensionHeight}`}</p>} {file && <p>Dimensions: {`${dimensionWidth} x ${dimensionHeight}`}</p>}
</div> </div>
); );

View File

@ -71,7 +71,7 @@ function Profil()
<div className='Profil'> <div className='Profil'>
<h2>Profil</h2> <h2>Profil</h2>
<div> <div>
{dog.data && <Img pth={dog.data.picture}/>} {dog.data && <Img pth={dog.data.picture} className=''/>}
<Link to={'/upload'}>Bild ändern</Link> <Link to={'/upload'}>Bild ändern</Link>
</div> </div>
<form onSubmit={submitForm}> <form onSubmit={submitForm}>

View File

@ -1,10 +1,17 @@
img img
{ {
width: 2.4cm; max-width: 300px;
max-height: 300px;
background: #ffffff; background: #ffffff;
} }
.qrCodeImg
{
max-width: 100%;
max-height: 100%;
}
.qrCodeBackFront .qrCodeBackFront
{ {
display: flex; display: flex;
@ -52,6 +59,11 @@ img
width: 2.4cm; width: 2.4cm;
} }
.beschreibung
{
font-size: x-small;
}
.vert .vert
{ {
flex-direction: row-reverse; flex-direction: row-reverse;
@ -112,7 +124,7 @@ img
.qr-input .qr-input
{ {
width: 50px; width: 55px;
} }
label label

View File

@ -107,6 +107,7 @@ export default function Qr()
//const handle drag sorting //const handle drag sorting
function handleSort() function handleSort()
{ {
// console.log('handleSort current:' + dragItem.current);
//duplicate items //duplicate items
let _itemList = [...itemList]; let _itemList = [...itemList];
@ -141,12 +142,16 @@ export default function Qr()
// 231 // 231
itemList.map((item, index) => // console.log('handleSort itemList:');
// console.log(_itemList);
_itemList.map((item, index) =>
{ {
digit = 10**(3-item.ordernum); digit = 10**(3-item.ordernum);
newItemOrder += (index+1) * digit; newItemOrder += (index+1) * digit;
}); });
setItemOrder(newItemOrder); setItemOrder(newItemOrder);
// console.log('handleSort newItemOrder:' + newItemOrder);
} }
function oneQrBlock() function oneQrBlock()
@ -155,7 +160,7 @@ export default function Qr()
<div className='qrCodeBackFront'> <div className='qrCodeBackFront'>
<div className='qrCode frame' style={{height : height + 'cm', width : width + 'cm'}}> <div className='qrCode frame' style={{height : height + 'cm', width : width + 'cm'}}>
<div className='qrCode__'>SCAN ME</div> <div className='qrCode__'>SCAN ME</div>
<Img pth={dog.data.qr_code}/> <Img pth={dog.data.qr_code} className='qrCodeImg'/>
</div> </div>
<div className='qrCode vert frame' style={{ height : height + 'cm', width : width + 'cm', fontSize: fontSize + '%' }}> <div className='qrCode vert frame' style={{ height : height + 'cm', width : width + 'cm', fontSize: fontSize + '%' }}>
{((visibleItem & 0b100) > 0) && <div className={`vertFont order${getItemOrderNumber(100)}`}>{dog.data.name}</div>} {((visibleItem & 0b100) > 0) && <div className={`vertFont order${getItemOrderNumber(100)}`}>{dog.data.name}</div>}
@ -301,17 +306,19 @@ export default function Qr()
</div> </div>
<div> <div>
<div>Reihenfolge</div> <div>Reihenfolge</div>
<div className='beschreibung'>Ändern durch Drag'n Drop</div>
<div className="list-container"> <div className="list-container">
{itemList.map((item, index) => ( {itemList.map((item, index) => (
<div <div
key={index} key={index}
className="list-item" className="list-item"
draggable draggable
onDragStart={(e) => (dragItem.current = index)} onDragStart={(e) => {dragItem.current = index; /* console.log('onDragStart index: ' + index); */}}
onDragEnter={(e) => (dragOverItem.current = index)} onDragEnter={(e) => {dragOverItem.current = index; /* console.log('onDragEnter index: ' + index); */}}
onDragEnd={handleSort} onDragEnd={handleSort}
onDragOver={(e) => e.preventDefault()}> onDragOver={(e) => {e.preventDefault(); /* console.log('onDragEnter index: ' + index); */}}
<h6>{item.name}</h6> >
<li>{item.name}</li>
</div> </div>
))} ))}
</div> </div>