Commit f8406596 authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

Merge remote-tracking branch 'origin/layout' into turid_sandbox

parents 7f033306 75ffbdef
......@@ -2,9 +2,11 @@
/* Sorted in alphabethic order with tags first, then classes. At the end are media-queries. */
body{
background-color: mediumslateblue;
background-color: #d2cfe4;
display: flex;
justify-content: center;
overflow-y: scroll;
font-family: Georgia, 'Times New Roman', Times, serif, serif;
}
button{
......@@ -13,10 +15,9 @@ button{
padding: 0.5vw 1vw;
margin: 0.1vw;
margin-left: 1vw;
font-size: 1.2vw;
font-size: 14px;
font-weight: bold;
background-color: #8fa0c9;
width: 80%;
}
button:hover{
......@@ -29,35 +30,23 @@ h4{
}
input[type=radio]{
width: 1vw;
height: 1vw;
width: 13px;
height: 13px;
}
q{
text-align: center;
}
/* Inspiration to footer from https://www.w3schools.com/howto/howto_css_fixed_footer.asp */
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #0f106d;
display: flex;
justify-content: center;
}
.box{
background: #61dafb;
margin: 1vw;
display: flex;
justify-content: center;
align-items: center;
padding: 2px;
}
.container{
background-color: #282c34;
display: flex;
justify-content: space-evenly;
flex-wrap: nowrap;
......@@ -89,9 +78,20 @@ q{
background-color: rgba(200,200,200,0.8);
}
/* Inspiration to footer from https://www.w3schools.com/howto/howto_css_fixed_footer.asp */
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #0f106d;
display: flex;
justify-content: center;
}
.header {
font-weight: bold;
font-size: 3.5vw;
font-size: 30px;
color: white;
position: fixed;
right: 0;
......@@ -99,18 +99,20 @@ q{
z-index: 999;
background-color: #0f106d;
text-align: center;
padding-top: 0.5vw;
padding-bottom: 0.5vw;
padding-top: 5px;
padding-bottom: 5px;
}
.image{
width: 45vw;
width: 44vw;
height: 35vw;
}
.main{
width: 80vw;
height: 100vh;
padding-bottom: 3vw;
padding-top: 3vw;
border: solid;
}
.navDots{
......@@ -139,7 +141,7 @@ q{
.screenBox{
display: flex;
flex-wrap: nowrap;
padding-top: 5.6vw;
padding-top: 55px;
}
.sidebar {
......@@ -147,15 +149,15 @@ q{
width: 14vw;
padding-left: 1vw;
padding-right: 1vw;
padding-top: 3vw;
}
.sidebarButtons{
width: 100%;
display: flex;
flex-direction: column;
}
.sidebarCollection{
font-size: 1.3vw;
font-size: 15px;
padding-bottom: 1vw;
}
......@@ -176,63 +178,171 @@ q{
.text{
width: 25vw;
height: 32vw;
flex-direction: column;
font-size: 1.5vw;
font-size: 16px;
border: #0f106d dotted;
}
/* Source of sizes: https://www.w3schools.com/css/css_rwd_mediaqueries.asp */
/* Source of first four sizes: https://www.w3schools.com/css/css_rwd_mediaqueries.asp */
/* Large devices (laptops/desktops, between 992px and 1200px) */
@media only screen and (max-width: 1200px) {
.container{
background-color: chartreuse;
.image{
width: 43vw;
}
}
/* Medium devices (landscape tablets, between 768px and 992px) */
@media only screen and (max-width: 992px) {
.image{
width: 42vw;
}
}
/* Small devices (portrait tablets and large phones, between 600px and 768px) */
@media only screen and (max-width: 768px) {
body{
overflow-y: unset;
}
button{
font-size: 1.4vw;
font-size: 13px;
width: 20vw;
margin-bottom: 1vw;
}
.container{
background-color: blueviolet;
input[type=radio]{
width: 11px;
height: 11px;
}
.dot{
width: 23px;
height: 23px;
margin: 5px;
}
.header{
font-size: 4.2vw;
font-size: 26px;
}
.sidebarCollection{
font-size: 1.8vw;
.image{
width: 80vw;
height: 40vh;
}
.main{
width: 92vw;
margin-top: 0;
padding-top: 0;
padding-bottom: 0;
border: none;
border-top: solid;
}
.navDots{
width: 100vw;
justify-content: space-evenly;
}
.prevBtn, .nextBtn{
width: auto;
padding: 2vw 1.5vw;
}
.radio{
width: 28vw;
padding-right: 2vw;
}
.screenBox{
padding: 0;
}
.sidebar{
display: flex;
padding-top: 50px;
}
.sidebarButtons{
flex-direction: row;
justify-content: center;
}
.slideButtonContainer{
height: 70vh;
}
.sound{
width: 80vw;
margin-bottom: 43px;
}
.text{
font-size: 2vw;
width: 80vw;
font-size: 15px;
}
}
/* Small devices (portrait tablets and large phones, between 600px and 768px) */
@media only screen and (max-width: 768px) {
/* Extra small devices (phones, between 410px and 600px) */
@media only screen and (max-width: 600px) {
button{
font-size: 1.9vw;
width: 20vw;
width: 25vw;
}
}
input[type=radio]{
width: 1.4vw;
height: 1.4vw;
/* Even smaller devices (phones, 410px and down) */
@media only screen and (max-width: 410px) {
button{
font-size: 12px;
}
.container{
background-color: blue;
.header{
font-size: 22px;
}
.radio{
width: 30vw;
padding: 0;
}
.sidebar{
padding-top: 42px;
}
.sidebarCollection{
font-size: 13px;
}
}
/* Medium devices (portrait tablets, between 600px and 900px in width and between 800px and 1300px in height) */
@media only screen and (orientation: portrait) and (min-width: 600px) and (min-height: 800px){
body{
overflow-y: unset;
}
button{
font-size: 19px;
width: 25vw;
margin-bottom: 1vw;
padding: 1vw;
}
input[type=radio]{
width: 20px;
height: 20px;
margin-bottom: 1vw;
margin-top: 1vw;
}
.dot{
width: 4vw;
height: 4vw;
margin: 1vw;
width: 35px;
height: 35px;
margin: 5px;
}
.header{
font-size: 42px;
}
.image{
......@@ -241,7 +351,12 @@ q{
}
.main{
width: 90vw;
width: 92vw;
margin-top: 0;
padding-top: 0;
padding-bottom: 0;
border: none;
border-top: solid;
}
.navDots{
......@@ -251,11 +366,11 @@ q{
.prevBtn, .nextBtn{
width: auto;
padding: 2vw 1.5vw;
padding: 3vw 2.5vw;
}
.radio{
width: 30vw;
width: 28vw;
padding-right: 2vw;
}
......@@ -265,16 +380,16 @@ q{
.sidebar{
display: flex;
padding-top: 8vw;
padding-top: 65px;
}
.sidebarButtons{
display: flex;
flex-direction: row;
justify-content: center;
}
.sidebarCollection{
font-size: 2.3vw;
font-size: 20px;
}
.slideButtonContainer{
......@@ -283,34 +398,39 @@ q{
.sound{
width: 80vw;
margin-bottom: 8vw;
margin-bottom: 50px;
}
.text{
width: 80vw;
height: 20vh;
min-height: 18vw;
font-size: 2.5vw;
font-size: 24px;
}
}
/* Extra small devices (phones, 599px and down) */
@media only screen and (max-width: 600px) {
/* Medium devices (portrait tablets, 900px and up in width and 1300px and up in height) */
@media only screen and (orientation: portrait) and (min-width: 900px) and (min-height: 1300px){
button{
font-size: 2.5vw;
width: 25vw;
font-size: 27px;
}
.dot{
width: 50px;
height: 50px;
}
.container{
background-color: aliceblue;
.header{
font-size: 55px;
}
.sidebar{
padding-top: 80px;
}
.sidebarCollection{
font-size: 3vw;
font-size: 28px;
}
.text{
font-size: 2.5vw;
height: 30vh;
font-size: 34px;
}
}
\ No newline at end of file
import React, {Component} from 'react';
import NavigationDots from './NavigationDots';
/*
Creates a footer with navigation-dots. Is used for small screens.
*/
class Footer extends Component {
render() {
return (
<div className="footer" id="footer"
ref={a => this._acc = a} >
<NavigationDots goToFirstSlide={this.props.goToFirstSlide}
goToSecondSlide={this.props.goToSecondSlide}
goToThirdSlide={this.props.goToThirdSlide}
goToFourthSlide={this.props.goToFourthSlide} />
</div>
)
}
render() {
return (
<div className="footer" id="footer">
<NavigationDots goToFirstSlide={this.props.goToFirstSlide}
goToSecondSlide={this.props.goToSecondSlide}
goToThirdSlide={this.props.goToThirdSlide}
goToFourthSlide={this.props.goToFourthSlide} />
</div>
)
}
}
export default Footer;
\ No newline at end of file
import React from 'react';
/*
Creates a div for the svg-images.
*/
class ImageBox extends React.Component{
constructor(props){
......@@ -8,9 +11,17 @@ class ImageBox extends React.Component{
this.getSVG = this.getSVG.bind(this);
this.getSVGnames = this.getSVGnames.bind(this);
/*
The boolean variable keeps track of whether or not the component is mounted.
Is used to prevents the attempt of injecting a svg-image in a div that does not exist any more,
which is a danger because fetch is asynchronous.
*/
this._isMounted = false;
}
/*
Finds the correct name for the svg-image to be displayed.
*/
getSVGnames(option){
var svgFiles = {'cat': ['chillax', 'fluff', 'lick', 'stare'],
'dragon': ['b&w', 'cartoon', 'flying', 'red'],
......@@ -19,8 +30,10 @@ class ImageBox extends React.Component{
return svgFiles[option];
};
/*
Fetches the svg-image to be displayed, and displays it in the div with id="svg-container" after emptying it first.
*/
getSVG() {
console.log(this.props);
let svg_name = this.getSVGnames(this.props.imageIndex)[this.props.currentIndex];
let con = document.getElementById("svg-container");
if (con !== null){
......
......@@ -5,11 +5,13 @@ import SoundBox from "./SoundBox";
import NextButton from './NextButton';
import PrevButton from './PrevButton';
/*
Creates a component with layout of svg-image, text and audio for larger screens.
*/
/*
Creates a component with layout of svg-image, text and audio for larger screens.
*/
class LargeScreenBox extends React.Component{
/*
Updates the content in SoundBox, ImageBox and TextBox.
*/
changeContentPB = () => {
this.refs.SoundBox.changeSoundContentSB();
this.refs.ImageBox.getSVG();
......
......@@ -34,6 +34,9 @@ class MiddlePart extends React.Component{
}
}
this.changeContent = this.changeContent.bind(this);
// Boolean variables to know when content should be changed,
// and when favorite collection should be displayed.
this._updateIndex = false;
this._fetchFav = false;
}
......@@ -50,7 +53,9 @@ class MiddlePart extends React.Component{
changeContent = () => {
let width = window.innerWidth;
if (width < 768) {
let height = window.innerHeight;
if (width < 768 || (width < height)) {
this.refs.SmallScreenBox.changeContentPB();
}
else{
......@@ -122,13 +127,17 @@ class MiddlePart extends React.Component{
*/
resize = () => this.forceUpdate();
/*
Adds eventlistener for when window on screen is resized.
*/
componentDidMount(){
/*
Adds eventlistener for when window on screen is resized.
*/
window.addEventListener("resize", this.resize);
}
/*
Updates displayed content only when a change is made.
*/
componentDidUpdate(){
if (this._updateIndex){
this.changeContent()
......@@ -140,20 +149,21 @@ class MiddlePart extends React.Component{
this._fetchFav = false;
}
/*
Removes eventlistener for when window on screen is resized.
*/
componentWillUnmount() {
/*
Removes eventlistener for when window on screen is resized.
*/
window.removeEventListener("resize", this.resize);
}
//--------------------------------------------------------------------------------------------------------------------------------------
render(){
let width = window.innerWidth;
let height = window.innerHeight;
/*
Either shows layout for smaller or larger screens based on width of window on screen.
*/
if (width < 768) {
if (width < 768 || (width < height)) {
return (
<div>
<Sidebar soundIndex={this.state.soundIndex}
......
import React from 'react';
class NavigationDots extends React.Component{
render(){
return (
<div className="navDots">
<button className = "dot" onClick={this.props.goToFirstSlide}></button>
<button className = "dot" onClick={this.props.goToSecondSlide}></button>
<button className = "dot" onClick={this.props.goToThirdSlide}></button>
<button className = "dot" onClick={this.props.goToFourthSlide}></button>
</div>
);
}
function NavigationDots(props){
return (
<div className="navDots">
<button className = "dot" onClick={props.goToFirstSlide}></button>
<button className = "dot" onClick={props.goToSecondSlide}></button>
<button className = "dot" onClick={props.goToThirdSlide}></button>
<button className = "dot" onClick={props.goToFourthSlide}></button>
</div>
);
}
export default NavigationDots;
......
......@@ -131,7 +131,6 @@ class Sidebar extends Component {
<button onClick={(e) => this.seeCombinationClickHandler(e)}>
See combination
</button>
<div id="count"></div>
<button onClick={(e) => this.saveFav(e)}>
Save as favorite
</button>
......
......@@ -5,12 +5,13 @@ import SoundBox from "./SoundBox";
import NextButton from './NextButton';
import