This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding feature to export data to excel
- Loading branch information
Helene Rigner
committed
Apr 15, 2019
1 parent
e4226f5
commit 5faad3d
Showing
11 changed files
with
187 additions
and
22 deletions.
There are no files selected for viewing
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
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,48 @@ | ||
.info-box { | ||
align-items: center; | ||
background-color: white; | ||
border: 1px solid #ccc; | ||
border-radius: 0.5rem; | ||
box-shadow: 2px 2px 10px #ccc; | ||
color: #404040; | ||
display: flex; | ||
font-size: 2em; | ||
height: 7em; | ||
justify-content: center; | ||
left: 0; | ||
margin-bottom: 2em; | ||
margin-left: auto; | ||
margin-right: auto; | ||
position: absolute; | ||
right: 0; | ||
width: 30em; | ||
z-index: 50; | ||
} | ||
|
||
.visible { | ||
animation: box-in 0.7s; | ||
bottom: 0; | ||
transition: bottom 0.6s ease-in-out; | ||
} | ||
|
||
.hidden { | ||
bottom: -15%; | ||
transition: bottom 0.8s ease-in-out; | ||
} | ||
|
||
.alert { | ||
fill: red; | ||
padding-left: 1.5em; | ||
padding-right: 1em; | ||
width: 1.5em; | ||
} | ||
|
||
@keyframes box-in { | ||
from { | ||
transform: translateY(100%); | ||
} | ||
|
||
to { | ||
transform: translateY(0); | ||
} | ||
} |
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,65 @@ | ||
import React, { useContext, useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import SVGInline from 'react-svg-inline'; | ||
|
||
import alert from '../assets/alert-triangle-outline.svg'; | ||
|
||
import './info-box.pcss'; | ||
|
||
const context = React.createContext(); | ||
|
||
const InfoBoxContainer = props => ( | ||
<div {...props} /> | ||
); | ||
|
||
const InfoBox = ({ children, visible }) => ( | ||
<div className={`info-box ${visible ? 'visible' : 'hidden'}`}> | ||
<SVGInline className="alert" svg={alert} /> | ||
{children} | ||
</div> | ||
); | ||
|
||
InfoBox.propTypes = { | ||
children: PropTypes.arrayOf(PropTypes.node).isRequired, | ||
visible: PropTypes.bool, | ||
}; | ||
|
||
InfoBox.defaultProps = { | ||
visible: true, | ||
}; | ||
|
||
export function InfoBoxProvider({ children }) { | ||
const [infoBox, setInfoBox] = useState(null); | ||
const [showTimer, setShowTimer] = useState(0); | ||
const [animateOutTimer, setAnimateOutTimer] = useState(0); | ||
|
||
useEffect(() => { clearTimeout(showTimer); clearTimeout(animateOutTimer); }, []); | ||
|
||
const show = (text) => { | ||
const id = Math.random().toString(36).substr(2, 9); | ||
setAnimateOutTimer(setTimeout(() => { setInfoBox({ content: text, id, visible: false }); }, 5000)); | ||
setShowTimer(setTimeout(() => { setInfoBox(null); }, 6000)); | ||
setInfoBox({ content: text, id, visible: true }); | ||
}; | ||
|
||
return ( | ||
<context.Provider value={{ show }}> | ||
{children} | ||
<InfoBoxContainer className="info-box-container"> | ||
{infoBox | ||
? ( | ||
<InfoBox key={infoBox.id} visible={infoBox.visible}> | ||
{infoBox.content} | ||
</InfoBox> | ||
) : null | ||
} | ||
</InfoBoxContainer> | ||
</context.Provider> | ||
); | ||
} | ||
|
||
InfoBoxProvider.propTypes = { | ||
children: PropTypes.arrayOf(PropTypes.node).isRequired, | ||
}; | ||
|
||
export const useInfoBox = () => useContext(context); |