Dyanically set iframe height
This commit is contained in:
@@ -13,6 +13,8 @@ html {
|
|||||||
|
|
||||||
#moco-bx-root {
|
#moco-bx-root {
|
||||||
min-width: 516px;
|
min-width: 516px;
|
||||||
|
min-height: 300px;
|
||||||
|
transition: height 2s ease-out;
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@@ -99,11 +101,16 @@ html {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
|
|
||||||
h1 {
|
h2 {
|
||||||
margin-bottom: 0;
|
font-weight: normal;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin-top: 0.6rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timer {
|
.timer {
|
||||||
@@ -134,7 +141,6 @@ html {
|
|||||||
img {
|
img {
|
||||||
margin-top: 1.5rem;
|
margin-top: 1.5rem;
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
width: 44%;
|
|
||||||
|
|
||||||
&.moco-bx-logo {
|
&.moco-bx-logo {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
|
|||||||
@@ -110,6 +110,9 @@ class App extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.addEventListener("keydown", this.handleKeyDown)
|
window.addEventListener("keydown", this.handleKeyDown)
|
||||||
|
console.log(window.document.body.scrollHeight)
|
||||||
|
console.log(window.document.body)
|
||||||
|
parent.postMessage(window.document.body.scrollHeight, "*")
|
||||||
chrome.runtime.onMessage.addListener(this.handleSetFormErrors)
|
chrome.runtime.onMessage.addListener(this.handleSetFormErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,8 @@ export default function TimerView({ timedActivity, onStopTimer }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="moco-bx-timer-view">
|
<div className="moco-bx-timer-view">
|
||||||
<h1>
|
<h2>{timedActivity.assignment_name}</h2>
|
||||||
{timedActivity.assignment_name}
|
<h2>{timedActivity.task_name}</h2>
|
||||||
<br />
|
|
||||||
{timedActivity.task_name}
|
|
||||||
</h1>
|
|
||||||
<p className="text-secondary">{timedActivity.customer_name}</p>
|
<p className="text-secondary">{timedActivity.customer_name}</p>
|
||||||
<Timer
|
<Timer
|
||||||
className="timer text-red"
|
className="timer text-red"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const InvalidConfigurationError = () => (
|
|||||||
<img
|
<img
|
||||||
src={chrome.extension.getURL(settingsUrl)}
|
src={chrome.extension.getURL(settingsUrl)}
|
||||||
alt="Browser extension configuration settings"
|
alt="Browser extension configuration settings"
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer", width: "185px", height: "195px" }}
|
||||||
onClick={() => chrome.runtime.sendMessage({ type: "openOptions" })}
|
onClick={() => chrome.runtime.sendMessage({ type: "openOptions" })}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import logo from "images/moco-159x159.png"
|
|||||||
|
|
||||||
const UnknownError = ({ message = "Unbekannter Fehler" }) => (
|
const UnknownError = ({ message = "Unbekannter Fehler" }) => (
|
||||||
<div className="moco-bx-error-container">
|
<div className="moco-bx-error-container">
|
||||||
<img className="moco-bx-logo" src={logo} alt="MOCO logo" />
|
<img
|
||||||
|
className="moco-bx-logo"
|
||||||
|
src={logo}
|
||||||
|
style={{ width: "48px", height: "48px" }}
|
||||||
|
alt="MOCO logo"
|
||||||
|
/>
|
||||||
<h1>Ups, es ist ein Fehler passiert!</h1>
|
<h1>Ups, es ist ein Fehler passiert!</h1>
|
||||||
<p>Bitte überprüfe deine Internetverbindung.</p>
|
<p>Bitte überprüfe deine Internetverbindung.</p>
|
||||||
<p>Fehlermeldung:</p>
|
<p>Fehlermeldung:</p>
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import firefoxAddons from "images/firefox_addons.png"
|
|||||||
|
|
||||||
const UpgradeRequiredError = () => (
|
const UpgradeRequiredError = () => (
|
||||||
<div className="moco-bx-error-container">
|
<div className="moco-bx-error-container">
|
||||||
<img className="moco-bx-logo" src={logo} alt="MOCO logo" />
|
<img
|
||||||
|
className="moco-bx-logo"
|
||||||
|
src={logo}
|
||||||
|
style={{ width: "48px", height: "48px" }}
|
||||||
|
alt="MOCO logo"
|
||||||
|
/>
|
||||||
<h1>Bitte aktualisieren</h1>
|
<h1>Bitte aktualisieren</h1>
|
||||||
<p>Die installierte MOCO Browser-Erweiterung ist veraltet — bitte aktualisieren.</p>
|
<p>Die installierte MOCO Browser-Erweiterung ist veraltet — bitte aktualisieren.</p>
|
||||||
{isChrome() ? (
|
{isChrome() ? (
|
||||||
@@ -18,7 +23,12 @@ const UpgradeRequiredError = () => (
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<p>Unter folgender URL:</p>
|
<p>Unter folgender URL:</p>
|
||||||
<img className="firefox-addons" src={firefoxAddons} alt="about:addons" />
|
<img
|
||||||
|
className="firefox-addons"
|
||||||
|
src={firefoxAddons}
|
||||||
|
style={{ width: "292px", height: "40px" }}
|
||||||
|
alt="about:addons"
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,41 +1,24 @@
|
|||||||
import React, { Component } from "react"
|
import React, { useEffect, useRef } from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import queryString from "query-string"
|
import queryString from "query-string"
|
||||||
import { ERROR_UNKNOWN, ERROR_UNAUTHORIZED, ERROR_UPGRADE_REQUIRED, serializeProps } from "utils"
|
import { serializeProps } from "utils"
|
||||||
import { isChrome } from "utils/browser"
|
|
||||||
|
|
||||||
function getStyles(errorType) {
|
function Popup(props) {
|
||||||
return {
|
const iFrameRef = useRef()
|
||||||
width: "516px",
|
|
||||||
height:
|
|
||||||
errorType === ERROR_UNAUTHORIZED
|
|
||||||
? "590px"
|
|
||||||
: errorType === ERROR_UPGRADE_REQUIRED
|
|
||||||
? isChrome()
|
|
||||||
? "429px"
|
|
||||||
: "472px"
|
|
||||||
: errorType === ERROR_UNKNOWN
|
|
||||||
? "408px"
|
|
||||||
: isChrome()
|
|
||||||
? "558px"
|
|
||||||
: "574px",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Popup extends Component {
|
const handleRequestClose = event => {
|
||||||
static propTypes = {
|
|
||||||
service: PropTypes.object,
|
|
||||||
errorType: PropTypes.string,
|
|
||||||
onRequestClose: PropTypes.func.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
handleRequestClose = event => {
|
|
||||||
if (event.target.classList.contains("moco-bx-popup")) {
|
if (event.target.classList.contains("moco-bx-popup")) {
|
||||||
this.props.onRequestClose()
|
props.onRequestClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
const handleMessage = event => {
|
||||||
|
if (iFrameRef.current) {
|
||||||
|
iFrameRef.current.style.height = `${event.data}px`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
// Document might lose focus when clicking the browser action.
|
// Document might lose focus when clicking the browser action.
|
||||||
// Document might be out of focus when hitting the shortcut key.
|
// Document might be out of focus when hitting the shortcut key.
|
||||||
// This puts the focus back to the document and ensures that:
|
// This puts the focus back to the document and ensures that:
|
||||||
@@ -43,39 +26,45 @@ class Popup extends Component {
|
|||||||
// - the ESC key closes the popup without closing anything else
|
// - the ESC key closes the popup without closing anything else
|
||||||
window.focus()
|
window.focus()
|
||||||
document.activeElement?.blur()
|
document.activeElement?.blur()
|
||||||
}
|
window.addEventListener("message", handleMessage)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("message", handleMessage)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
render() {
|
const serializedProps = serializeProps([
|
||||||
const serializedProps = serializeProps([
|
"loading",
|
||||||
"loading",
|
"service",
|
||||||
"service",
|
"subdomain",
|
||||||
"subdomain",
|
"projects",
|
||||||
"projects",
|
"activities",
|
||||||
"activities",
|
"schedules",
|
||||||
"schedules",
|
"timedActivity",
|
||||||
"timedActivity",
|
"lastProjectId",
|
||||||
"lastProjectId",
|
"lastTaskId",
|
||||||
"lastTaskId",
|
"fromDate",
|
||||||
"fromDate",
|
"toDate",
|
||||||
"toDate",
|
"errorType",
|
||||||
"errorType",
|
"errorMessage",
|
||||||
"errorMessage",
|
])(props)
|
||||||
])(this.props)
|
|
||||||
|
|
||||||
const styles = getStyles(this.props.errorType)
|
return (
|
||||||
|
<div className="moco-bx-popup" onClick={handleRequestClose}>
|
||||||
return (
|
<div className="moco-bx-popup-content" style={{ width: "516px", minHeight: "300px" }}>
|
||||||
<div className="moco-bx-popup" onClick={this.handleRequestClose}>
|
<iframe
|
||||||
<div className="moco-bx-popup-content" style={styles}>
|
ref={iFrameRef}
|
||||||
<iframe
|
src={chrome.extension.getURL(`popup.html?${queryString.stringify(serializedProps)}`)}
|
||||||
src={chrome.extension.getURL(`popup.html?${queryString.stringify(serializedProps)}`)}
|
width="516px"
|
||||||
width={styles.width}
|
/>
|
||||||
height={styles.height}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
</div>
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Popup.propTypes = {
|
||||||
|
service: PropTypes.object,
|
||||||
|
errorType: PropTypes.string,
|
||||||
|
onRequestClose: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Popup
|
export default Popup
|
||||||
|
|||||||
Reference in New Issue
Block a user