-
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 13, 2020
1 parent
4c86b83
commit f673acf
Showing
44 changed files
with
278 additions
and
63 deletions.
There are no files selected for viewing
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
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.
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.
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.
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.
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.
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.
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.
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
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,76 @@ | ||
// .puzzleBox { | ||
// display: flex; | ||
// flex-direction: column; | ||
// align-items: center; | ||
// justify-content: center; | ||
// } | ||
|
||
// .puzzleBox .description { | ||
// width: 75vw; | ||
// margin: auto; | ||
// text-align: center; | ||
// } | ||
|
||
// .puzzle{ | ||
// display: flex; | ||
// flex-flow: row wrap; | ||
// } | ||
|
||
// .puzzle > * { | ||
// flex: 1 50%; | ||
// } | ||
|
||
.puzzle__solved-board{ | ||
position: relative; | ||
background-size: cover; | ||
} | ||
|
||
.puzzle__solved-board:before{ | ||
content: ''; | ||
background-color: rgba(255, 255, 255, 0.6); | ||
display: block; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
} | ||
|
||
.puzzle__solved-board, | ||
.puzzle__shuffled-board{ | ||
margin: 20px auto; | ||
width: 400px; | ||
list-style-type: none; | ||
padding: 0; | ||
font-size: 0; | ||
border: 1px solid #DDD; | ||
border-width: 1px 0 0 1px; | ||
} | ||
|
||
.puzzle li{ | ||
width: 99px; | ||
height: 99px; | ||
position: relative; | ||
text-align: left; | ||
display: inline-block; | ||
border: 1px solid #DDD; | ||
border-width: 0 1px 1px 0; | ||
} | ||
|
||
.puzzle li:empty:hover:before{ | ||
opacity: 1; | ||
} | ||
|
||
.puzzle li img{ | ||
width: 100px; | ||
height: 100px; | ||
position: absolute; | ||
cursor: grab; | ||
transition: transform 200ms ease, box-shadow 200ms ease; | ||
} | ||
|
||
.puzzle li img:hover{ | ||
z-index: 2; | ||
transform: scale(1.1); | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.8); | ||
} |
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 Puzzle from './puzzle'; | ||
|
||
describe(' Puzzle', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<Puzzle />); | ||
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,106 @@ | ||
import React, {useState} from 'react'; | ||
import { IMAGE_SUFFIX } from '@gerdesque/data'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import './puzzle.scss'; | ||
|
||
export const Puzzle = () => { | ||
const useStyles = makeStyles(() => ({ | ||
puzzle: { | ||
backgroundImage: `url(${"./assets/daheim_puzzle"+IMAGE_SUFFIX})`, | ||
boxShadow: '0 0 8px 8px #dcd5cc inset', | ||
}, | ||
})); | ||
const classes = useStyles(); | ||
|
||
const pieces = [...Array(16)].map((_, i) => ({ | ||
img: `daheim_puzzle_${("0" + (i + 1)).substr(-2)}`, | ||
order: i, | ||
board: "shuffled" | ||
})); | ||
|
||
const shufflePieces = (pieces) => { | ||
const shuffled = [...pieces]; | ||
|
||
for (let i = shuffled.length - 1; i > 0; i--) { | ||
const j = Math.floor(Math.random() * (i + 1)); | ||
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; | ||
} | ||
|
||
return shuffled; | ||
} | ||
const [shuffled, setShuffled] = useState(shufflePieces(pieces)); | ||
const [solved, setSolved] = useState([...Array(16)]); | ||
|
||
// const handleDrop = (e, targetName) => { | ||
// let target = this.state[targetName]; | ||
// const pieceOrder = e.dragData.piece.order; | ||
// if (target[pieceOrder]) return; | ||
|
||
// const pieceData = this.state.pieces.find(p => p.order === +pieceOrder); | ||
// const origin = this.state[pieceData.board]; | ||
|
||
// if (targetName === pieceData.board) target = origin; | ||
// origin[origin.indexOf(pieceData)] = undefined; | ||
// target[pieceOrder] = pieceData; | ||
// pieceData.board = targetName; | ||
|
||
// this.setState({ [pieceData.board]: origin, [targetName]: target }); | ||
// this.checkBoard(); | ||
// } | ||
|
||
const handleDrop = (e, index, targetName) => { | ||
e.preventDefault(); | ||
let target = targetName === 'shuffled' ? shuffled : solved; | ||
//if (target[index]) return; | ||
|
||
const pieceOrder = e.dataTransfer.getData('text'); | ||
const pieceData = pieces.find(p => p.order === +pieceOrder); | ||
const origin = pieceData.board === 'shuffled' ? shuffled : solved; | ||
|
||
if (targetName === pieceData.board) target = origin; | ||
//origin[origin.indexOf(pieceData)] = undefined; | ||
//target[pieceOrder] = pieceData; | ||
//pieceData.board = targetName; | ||
|
||
// this.setState({ [pieceData.board]: origin, [targetName]: target }); | ||
|
||
const newShuffled = [...shuffled]; | ||
newShuffled[newShuffled.indexOf(pieceData)] = undefined; | ||
|
||
solved[index] = pieceData; | ||
setShuffled(newShuffled); | ||
} | ||
|
||
const handleDragStart = (e, order) => { | ||
e.dataTransfer.setData('text/plain', order); | ||
} | ||
|
||
const renderPieceContainer = (piece, index, boardName) => { | ||
return ( | ||
<li key={index} | ||
onDragOver={(e) => e.preventDefault()} | ||
onDrop={(e) => handleDrop(e, index, boardName)}> | ||
{piece && <img | ||
draggable | ||
onDragStart={(e) => handleDragStart(e, piece.order)} | ||
alt="" | ||
src={`./assets/${piece.img}.webp`}/>} | ||
</li> | ||
); | ||
} | ||
|
||
return ( | ||
<div className='puzzleBox'> | ||
<div className='puzzle'> | ||
<ul className='puzzle__shuffled-board'> | ||
{shuffled.map((piece, i) => renderPieceContainer(piece, i, "shuffled"))} | ||
</ul> | ||
<ol className={`puzzle__solved-board ${classes.puzzle}`}> | ||
{solved.map((piece, i) => renderPieceContainer(piece, i, "solved"))} | ||
</ol> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Puzzle; |
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,36 @@ | ||
|
||
.icon-scroll, | ||
.icon-scroll:before { | ||
position: absolute; | ||
left: 50%; | ||
} | ||
.icon-scroll { | ||
width: 48px; | ||
height: 84px; | ||
margin-left: -20px; | ||
top: 85%; | ||
margin-top: -35px; | ||
border: 4px solid var(--color-title); | ||
border-radius: 25px; | ||
} | ||
.icon-scroll:before { | ||
content: ''; | ||
width: 10px; | ||
height: 10px; | ||
background: var(--color-title); | ||
margin-left: -4px; | ||
top: 8px; | ||
border-radius: 4px; | ||
animation-duration: 2s; | ||
animation-iteration-count: infinite; | ||
animation-name: scroll; | ||
} | ||
@keyframes scroll { | ||
0% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
transform: translateY(46px); | ||
} | ||
} |
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 Scrollicon from './scrollicon'; | ||
|
||
describe(' Scrollicon', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<Scrollicon />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.