-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate machine into multiple components
- Loading branch information
Showing
9 changed files
with
164 additions
and
122 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
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,75 @@ | ||
/* eslint-disable react/no-unused-prop-types */ | ||
import React, { Component } from 'react'; | ||
import { number } from 'prop-types'; | ||
|
||
import styles from './Spinner.module.css'; | ||
|
||
import bottom from './bottom.svg'; | ||
import top from './top.svg'; | ||
|
||
const mod = (a) => { | ||
const jsResult = a % 360; | ||
|
||
if (jsResult < 0) { | ||
return jsResult + 360; | ||
} | ||
|
||
return jsResult; | ||
}; | ||
|
||
const nearestAngle = (prevAngle, angle) => { | ||
const firstPossibility = prevAngle + mod(angle - prevAngle); | ||
const secondPossibility = prevAngle - mod(prevAngle - angle); | ||
|
||
if (Math.abs(prevAngle - firstPossibility) < Math.abs(prevAngle - secondPossibility)) { | ||
return firstPossibility; | ||
} | ||
|
||
return secondPossibility; | ||
}; | ||
|
||
class Spinner extends Component { | ||
static propTypes = { | ||
bottomAngle: number.isRequired, | ||
topAngle: number.isRequired, | ||
}; | ||
|
||
state = { | ||
topAngle: 0, | ||
bottomAngle: 0, | ||
} | ||
|
||
static getDerivedStateFromProps( | ||
{ bottomAngle, topAngle }, | ||
{ bottomAngle: prevBottomAngle, topAngle: prevTopAngle }, | ||
) { | ||
return { | ||
bottomAngle: nearestAngle(prevBottomAngle, bottomAngle), | ||
topAngle: nearestAngle(prevTopAngle, topAngle), | ||
}; | ||
} | ||
|
||
render() { | ||
const { bottomAngle, topAngle } = this.state; | ||
|
||
return ( | ||
<div className={`col-12 col-lg-6 text-center ${styles.wrapper}`}> | ||
<img | ||
src={bottom} | ||
className={styles.image} | ||
alt="baseboard" | ||
style={{ transform: `rotate(${bottomAngle}deg)` }} | ||
/> | ||
|
||
<img | ||
src={top} | ||
className={styles.image} | ||
alt="spinner" | ||
style={{ transform: `rotate(${topAngle}deg)` }} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Spinner; |
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,32 @@ | ||
.wrapper { | ||
position: relative; | ||
} | ||
|
||
.image { | ||
left: 0; | ||
margin-left: auto; | ||
margin-right: auto; | ||
position: absolute; | ||
right: 0; | ||
height: 50vh; | ||
transition: transform 0.8s ease-in-out; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.image { | ||
height: 65vh; | ||
} | ||
} | ||
|
||
@media (min-width: 992px) { | ||
.image { | ||
height: unset; | ||
max-width: 100%; | ||
} | ||
} | ||
|
||
@media (min-width: 1200px) { | ||
.image { | ||
max-width: 85%; | ||
} | ||
} |
File renamed without changes
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,3 @@ | ||
import Spinner from './Spinner'; | ||
|
||
export default Spinner; |
File renamed without changes
Oops, something went wrong.