-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerd Müller
committed
Jun 21, 2020
1 parent
39c0288
commit 5bd7d17
Showing
12 changed files
with
242 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.daily { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
.description { | ||
flex: 1 100%; | ||
text-align: center; | ||
margin: 10px 0; | ||
} | ||
|
||
.items { | ||
display: flex; | ||
flex-flow: row wrap; | ||
justify-content: space-around; | ||
|
||
.ddcontainer:hover { | ||
transition: background-color 0.5s ease; | ||
font-weight: bold; | ||
} | ||
|
||
&:focus { | ||
outline: none; | ||
} | ||
|
||
.item p { | ||
letter-spacing:0.1em; | ||
cursor: grab; | ||
} | ||
} | ||
|
||
.component_box { | ||
background-size: contain; | ||
height: 30vh; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
img { | ||
height: auto; | ||
text-align: center; | ||
width: 60%; | ||
margin: 0 auto 0; | ||
justify-content: center; | ||
display: flex; | ||
max-height: 66vh; | ||
} | ||
|
||
.show { | ||
margin-bottom: 5%; | ||
} | ||
} | ||
|
||
@media (min-width: 600px) { | ||
.daily .component_box { | ||
height: 45vh; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import Daily from './daily'; | ||
|
||
describe(' Daily', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<Daily />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import React, { useState } from "react"; | ||
import { DragDropContainer, DropTarget } from 'react-drag-drop-container'; | ||
import shortid from 'shortid'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
import Image from "../image/image"; | ||
|
||
import './daily.scss'; | ||
|
||
/* eslint-disable-next-line */ | ||
export interface DailyProps {} | ||
|
||
const dailyItems = ["Waschen und Baden", "Frühstück", "Wanderungen machen", "Sprechstunde des Lagerarztes", | ||
"Lagerruhe - Post- und Zeitungsausgabe", "Tagung des Lagerparlaments", "Gemeinsame Veranstaltungen", "Zeltruhe"]; | ||
const schedule = ["6 Uhr", "8 Uhr", "8 ½ – 12 Uhr ", "8 ½ – 9 ½", "12 ½ – 14 ½ ", | ||
"18 – 19 Uhr", "19 ½ – 21 Uhr", "21 Uhr"] | ||
const description = "Um die einzelnen Tagespunkte in die richtige Reihenfolge zu bringen, ziehe sie einfach auf das Plakat. Klicke auf 'Tagesplan anzeigen!', um dir den originalen Tagesablauf anzusehen." | ||
|
||
export const Daily = (props: DailyProps) => { | ||
|
||
const [result, setResult] = useState(false); | ||
|
||
const handleClick = () => { | ||
setResult(true); | ||
//props.onCheckDaily(); | ||
}; | ||
|
||
const getItems = () => { | ||
if (result) return; | ||
return ( | ||
<div className="items"> | ||
{dailyItems.map((item, index) => | ||
<div key={index} className="item"> | ||
<DragDropContainer targetKey="box" dragData={{label: item}}> | ||
<p>{item}</p> | ||
</DragDropContainer> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
const showStatus = () => { | ||
if (result) { | ||
return <Image value='daily_result' /> | ||
} | ||
return ( | ||
<> | ||
<Box targetKey="box"/> | ||
<button type='button' className='link-button show' onClick={() => handleClick()}>Tagesplan anzeigen!</button> | ||
</> | ||
) | ||
} | ||
|
||
return ( | ||
<div className="daily"> | ||
<div className="description">{description}</div> | ||
{getItems()} | ||
{showStatus()} | ||
</div> | ||
) | ||
} | ||
|
||
const Box = (props) => { | ||
const useStyles = makeStyles(() => ({ | ||
box: { | ||
background: 'url(./assets/daily.webp) no-repeat center center' | ||
}, | ||
})); | ||
const classes = useStyles(); | ||
|
||
const [boxItems, setBoxItems] = useState([]); | ||
|
||
const handleDrop = (e) => { | ||
const items = boxItems.slice(); | ||
items.push({label: e.dragData.label, uid: shortid.generate()}); | ||
setBoxItems(items) | ||
e.containerElem.style.visibility="hidden"; | ||
}; | ||
|
||
const swap = (fromIndex, toIndex, dragData) => { | ||
const items = boxItems.slice(); | ||
const item = {label: dragData.label, uid: shortid.generate()}; | ||
items.splice(toIndex, 0, item); | ||
setBoxItems(items) | ||
}; | ||
|
||
const kill = (uid) => { | ||
const items = boxItems.slice(); | ||
const index = items.findIndex((item) => { | ||
return item.uid === uid | ||
}); | ||
if (index !== -1) { | ||
items.splice(index, 1); | ||
} | ||
setBoxItems(items) | ||
}; | ||
|
||
return ( | ||
<DropTarget | ||
onHit={handleDrop} | ||
targetKey={props.targetKey} | ||
dropData={{name: props.name}}> | ||
<DropTarget | ||
onHit={handleDrop} | ||
targetKey="boxItem" | ||
dropData={{name: props.name}}> | ||
<div className={`component_box ${classes.box}`}> | ||
{boxItems.map((item, index) => { | ||
return ( | ||
<BoxItem key={item.uid} uid={item.uid} kill={kill} index={index} swap={swap}> | ||
{item.label} | ||
</BoxItem> | ||
) | ||
})} | ||
</div> | ||
</DropTarget> | ||
</DropTarget> | ||
); | ||
} | ||
|
||
const BoxItem = (props) => { | ||
|
||
const handleDrop = (e) => { | ||
e.stopPropagation(); | ||
props.swap(e.dragData.index, props.index, e.dragData); | ||
e.containerElem.style.visibility="hidden"; | ||
}; | ||
|
||
const deleteMe = () => { | ||
props.kill(props.uid); | ||
}; | ||
|
||
return ( | ||
<div className="box_item_component"> | ||
<DragDropContainer | ||
targetKey="boxItem" | ||
dragData={{label: props.children, index: props.index}} | ||
onDrop={deleteMe} | ||
disappearDraggedElement={true} | ||
dragHandleClassName="grabber"> | ||
<DropTarget | ||
onHit={handleDrop} | ||
targetKey="boxItem"> | ||
<div className="outer"> | ||
<div className="item"> | ||
<span className="grabber">∷</span> | ||
{schedule[props.index]} | ||
<span> </span> | ||
{props.children} | ||
</div> | ||
</div> | ||
</DropTarget> | ||
</DragDropContainer> | ||
</div> | ||
); | ||
} | ||
|
||
export default Daily; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters