-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from jsightapi/rc/5.1
Release 5.1
- Loading branch information
Showing
30 changed files
with
1,607 additions
and
1,234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
REACT_APP_API_URL=http://localhost:8080 | ||
REACT_APP_CLOUD_URL=https://cloud.jsight.io | ||
REACT_APP_GTM_ID= | ||
REACT_APP_CUSTOM_MESSAGE_URL=https://jsightapi.github.io/online-editor-custom-messages.json |
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import React from 'react'; | ||
import {Link} from 'react-router-dom'; | ||
import logo from 'assets/images/Logo.svg'; | ||
|
||
export const HeaderLogo = () => ( | ||
<div className="logo"> | ||
<Link to="/"> | ||
<a href="https://jsight.io" target="_blank" rel="noreferrer noopener"> | ||
<img src={logo} alt="JSight" /> | ||
</Link> | ||
</a> | ||
</div> | ||
); |
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
29 changes: 29 additions & 0 deletions
29
src/components/Modals/CustomMessage/CustomMessage.styles.scss
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,29 @@ | ||
@import 'src/styles/variables'; | ||
|
||
.custom-message-modal { | ||
.custom-message { | ||
.content { | ||
padding: 1.7rem 0; | ||
} | ||
|
||
.footer { | ||
padding-top: 1.7rem; | ||
display: flex; | ||
justify-content: flex-end; | ||
|
||
button { | ||
padding: 1rem 4.6rem; | ||
border-radius: 4px; | ||
font-size: 1.6rem; | ||
line-height: 2.4rem; | ||
font-weight: 600; | ||
margin-left: 20px; | ||
transition: 0.3s background; | ||
|
||
&:hover { | ||
background: #f8f8fa; | ||
} | ||
} | ||
} | ||
} | ||
} |
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,89 @@ | ||
import {FC, useEffect, useState} from 'react'; | ||
import Modal from 'react-modal'; | ||
import {Button} from 'components/Button'; | ||
|
||
import './CustomMessage.styles.scss'; | ||
|
||
interface CustmomMessageProps { | ||
customMessageUrl: string; | ||
} | ||
|
||
interface Message { | ||
id: string; | ||
regex: string; | ||
content: string; | ||
width?: number; | ||
} | ||
|
||
export const CustomMessage: FC<CustmomMessageProps> = ({customMessageUrl}) => { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const [allMessages, setAllMessages] = useState([] as Message[]); | ||
const [message, setMessage] = useState({} as Message); | ||
|
||
useEffect(() => { | ||
const getCustomMessages = async () => { | ||
try { | ||
const response = await fetch(customMessageUrl); | ||
const allMessages = await response.json(); | ||
setAllMessages(allMessages); | ||
} catch (err) { | ||
throw err; | ||
} | ||
}; | ||
|
||
getCustomMessages(); | ||
}, [customMessageUrl]); | ||
|
||
useEffect(() => { | ||
const url = window.location.href; | ||
const message = allMessages.find(({regex}) => { | ||
const regexp = new RegExp(regex); | ||
return regexp.test(url); | ||
}); | ||
|
||
message && setMessage(message); | ||
}, [allMessages]); | ||
|
||
useEffect(() => { | ||
const isShowModal = !!message.id && !Boolean(localStorage.getItem(message.id)); | ||
|
||
setIsModalOpen(isShowModal); | ||
}, [message]); | ||
|
||
const closeModal = () => setIsModalOpen(false); | ||
|
||
const onCloseForever = () => { | ||
localStorage.setItem(message.id, 'true'); | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
isOpen={isModalOpen} | ||
shouldCloseOnOverlayClick={true} | ||
shouldCloseOnEsc={true} | ||
className="r-modal custom-message-modal" | ||
overlayClassName="r-modal-overlay" | ||
style={{ | ||
content: { | ||
width: message?.width ? `${message.width}px` : 'auto', | ||
minWidth: message?.width ? 'unset' : '680px', | ||
maxWidth: message?.width ? 'unset' : '90vw', | ||
padding: '25px 32px 42px', | ||
}, | ||
}} | ||
> | ||
<div className="custom-message"> | ||
<div className="content" dangerouslySetInnerHTML={{__html: message.content}} /> | ||
<div className="footer"> | ||
<Button className="button close-forever" onClick={onCloseForever}> | ||
Close Forever | ||
</Button> | ||
<Button className="button close-show-later" onClick={closeModal}> | ||
Show Later | ||
</Button> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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
Oops, something went wrong.