mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-10 23:04:20 +00:00
lint suggestions
This commit is contained in:
parent
8430203092
commit
4b3da87f49
7 changed files with 222 additions and 17 deletions
104
desktop-app/app/components/AppNotification/AppNotification.js
Normal file
104
desktop-app/app/components/AppNotification/AppNotification.js
Normal file
|
@ -0,0 +1,104 @@
|
|||
import React, {useEffect, useState} from 'react';
|
||||
import cx from 'classnames';
|
||||
import {motion} from 'framer-motion';
|
||||
import {shell} from 'electron';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import settings from 'electron-settings';
|
||||
import {APP_NOTIFICATION} from '../../constants/settingKeys';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
function updateNotificationStatus(id, action) {
|
||||
const notifications = settings.get(APP_NOTIFICATION) || [];
|
||||
|
||||
const notificationStatusObject = {
|
||||
id,
|
||||
action,
|
||||
};
|
||||
notifications.push(notificationStatusObject);
|
||||
settings.set(APP_NOTIFICATION, notifications);
|
||||
}
|
||||
|
||||
function checkIfInteracted(id) {
|
||||
const notifications = settings.get(APP_NOTIFICATION);
|
||||
|
||||
let seenNotification;
|
||||
if (notifications) {
|
||||
seenNotification = notifications.find(
|
||||
notification => notification.id === id
|
||||
);
|
||||
}
|
||||
if (seenNotification) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const AppNotification = props => {
|
||||
const data = props.data;
|
||||
const [notificationInteracted, setNotificationInteracted] = useState(false);
|
||||
console.log(props);
|
||||
if (
|
||||
!data ||
|
||||
!Object.keys(data).length ||
|
||||
(!notificationInteracted && checkIfInteracted(data.id))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={styles.container}
|
||||
initial={{x: notificationInteracted ? 0 : 300, scale: 1}}
|
||||
animate={{x: notificationInteracted ? 300 : 0, scale: 1}}
|
||||
transition={{
|
||||
type: 'spring',
|
||||
stiffness: 260,
|
||||
damping: 20,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={styles.content}
|
||||
onClick={() => {
|
||||
shell.openExternal(data.link);
|
||||
updateNotificationStatus(data.id, 'ANSWERED');
|
||||
setNotificationInteracted(true);
|
||||
}}
|
||||
>
|
||||
{data.text}
|
||||
</div>
|
||||
<div className={styles.responseButtonsContainer}>
|
||||
<div className={styles.responseButtons}>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
aria-label="dismiss notfication"
|
||||
component="span"
|
||||
onClick={() => {
|
||||
shell.openExternal(data.link);
|
||||
updateNotificationStatus(data.id, 'ANSWER');
|
||||
setNotificationInteracted(true);
|
||||
}}
|
||||
>
|
||||
Yes
|
||||
</Button>
|
||||
</div>
|
||||
<div className={styles.dismiss}>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
aria-label="dismiss notfication"
|
||||
component="span"
|
||||
onClick={() => {
|
||||
updateNotificationStatus(data.id, 'DISMISS');
|
||||
setNotificationInteracted(true);
|
||||
}}
|
||||
>
|
||||
Dismiss
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppNotification;
|
27
desktop-app/app/components/AppNotification/styles.module.css
Normal file
27
desktop-app/app/components/AppNotification/styles.module.css
Normal file
|
@ -0,0 +1,27 @@
|
|||
.container {
|
||||
max-width: 250px;
|
||||
position: absolute;
|
||||
bottom: 25px;
|
||||
right: 50px;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
word-wrap: break-word;
|
||||
color: green;
|
||||
box-shadow: inset 0 0 3px #000;
|
||||
}
|
||||
|
||||
.content {
|
||||
color: green;
|
||||
padding: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.responseButtons {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.responseButtonsContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
|
@ -1,34 +1,43 @@
|
|||
import React, {useEffect, useState} from 'react';
|
||||
import cx from 'classnames';
|
||||
import {shell} from 'electron';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
import {shell} from 'electron';
|
||||
import AppNotification from '../AppNotification/AppNotification';
|
||||
|
||||
const Announcement = () => {
|
||||
const [data, setData] = useState(null);
|
||||
const [appMessagesData, setAppMessagesData] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const response = await (
|
||||
await fetch('https://responsively.app/assets/appMessages.json')
|
||||
).json();
|
||||
setData(response.statusBarMessage);
|
||||
setAppMessagesData(response);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
if (!data) {
|
||||
if (!appMessagesData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = appMessagesData.statusBarMessage;
|
||||
const notificationData = appMessagesData.notification;
|
||||
|
||||
return (
|
||||
<div className={styles.section}>
|
||||
<div
|
||||
className={cx(styles.text, styles.link)}
|
||||
onClick={() => shell.openExternal(data.link)}
|
||||
>
|
||||
<span className={cx('featureSuggestionLink', styles.linkText)}>
|
||||
{data.text}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
{data && (
|
||||
<div className={styles.section}>
|
||||
<div
|
||||
className={cx(styles.text, styles.link)}
|
||||
onClick={() => shell.openExternal(data.link)}
|
||||
>
|
||||
<span className={cx('featureSuggestionLink', styles.linkText)}>
|
||||
{data.text}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<AppNotification data={notificationData} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -827,7 +827,6 @@ class WebView extends Component {
|
|||
<IconFocus />
|
||||
</div>
|
||||
</Tooltip>
|
||||
{/* {expandOrCollapse} */}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
|
|
@ -4,3 +4,4 @@ export const USER_PREFERENCES = 'userPreferences';
|
|||
export const NETWORK_CONFIGURATION = 'networkConfiguration';
|
||||
export const BOOKMARKS = 'bookmarks';
|
||||
export const STATUS_BAR_VISIBILITY = 'statusBarVisibility';
|
||||
export const APP_NOTIFICATION = 'appNotification';
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
"electron-timber": "^0.5.1",
|
||||
"electron-updater": "^4.3.1",
|
||||
"flwww": "^2.0.10",
|
||||
"framer-motion": "^2.2.0",
|
||||
"history": "^4.7.2",
|
||||
"jimp": "^0.12.1",
|
||||
"lodash": "^4.17.19",
|
||||
|
|
|
@ -1160,7 +1160,7 @@
|
|||
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
|
||||
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
|
||||
|
||||
"@emotion/is-prop-valid@^0.8.1":
|
||||
"@emotion/is-prop-valid@^0.8.1", "@emotion/is-prop-valid@^0.8.2":
|
||||
version "0.8.8"
|
||||
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
|
||||
integrity sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==
|
||||
|
@ -1904,6 +1904,22 @@
|
|||
dependencies:
|
||||
"@types/node" ">= 8"
|
||||
|
||||
"@popmotion/easing@^1.0.1", "@popmotion/easing@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@popmotion/easing/-/easing-1.0.2.tgz#17d925c45b4bf44189e5a38038d149df42d8c0b4"
|
||||
integrity sha512-IkdW0TNmRnWTeWI7aGQIVDbKXPWHVEYdGgd5ZR4SH/Ty/61p63jCjrPxX1XrR7IGkl08bjhJROStD7j+RKgoIw==
|
||||
|
||||
"@popmotion/popcorn@^0.4.2":
|
||||
version "0.4.4"
|
||||
resolved "https://registry.yarnpkg.com/@popmotion/popcorn/-/popcorn-0.4.4.tgz#a5f906fccdff84526e3fcb892712d7d8a98d6adc"
|
||||
integrity sha512-jYO/8319fKoNLMlY4ZJPiPu8Ea8occYwRZhxpaNn/kZsK4QG2E7XFlXZMJBsTWDw7I1i0uaqyC4zn1nwEezLzg==
|
||||
dependencies:
|
||||
"@popmotion/easing" "^1.0.1"
|
||||
framesync "^4.0.1"
|
||||
hey-listen "^1.0.8"
|
||||
style-value-types "^3.1.7"
|
||||
tslib "^1.10.0"
|
||||
|
||||
"@samverschueren/stream-to-observable@^0.3.0":
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
|
||||
|
@ -7828,6 +7844,29 @@ fragment-cache@^0.2.1:
|
|||
dependencies:
|
||||
map-cache "^0.2.2"
|
||||
|
||||
framer-motion@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-2.2.0.tgz#4c8d5fb90f6040168f8259d07b7fd157af8ffec6"
|
||||
integrity sha512-9Y5e3dXrUC8+rpgQ0gQulK7ru6Ri5jpjINc6RAwabWoYuwbPfI+WwOuVCQcK4IOM1+KWT/zFtt4qHaZKj4wGIg==
|
||||
dependencies:
|
||||
"@popmotion/easing" "^1.0.2"
|
||||
"@popmotion/popcorn" "^0.4.2"
|
||||
framesync "^4.0.4"
|
||||
hey-listen "^1.0.8"
|
||||
popmotion "9.0.0-beta-8"
|
||||
style-value-types "^3.1.9"
|
||||
tslib "^1.10.0"
|
||||
optionalDependencies:
|
||||
"@emotion/is-prop-valid" "^0.8.2"
|
||||
|
||||
framesync@^4.0.1, framesync@^4.0.4:
|
||||
version "4.0.4"
|
||||
resolved "https://registry.yarnpkg.com/framesync/-/framesync-4.0.4.tgz#79c42c0118f26821c078570db0ff81fb863516a2"
|
||||
integrity sha512-mdP0WvVHe0/qA62KG2LFUAOiWLng5GLpscRlwzBxu2VXOp6B8hNs5C5XlFigsMgrfDrr2YbqTsgdWZTc4RXRMQ==
|
||||
dependencies:
|
||||
hey-listen "^1.0.8"
|
||||
tslib "^1.10.0"
|
||||
|
||||
fresh@0.5.2, fresh@^0.5.2:
|
||||
version "0.5.2"
|
||||
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
|
||||
|
@ -8447,6 +8486,11 @@ hex-rgb@^4.1.0:
|
|||
resolved "https://registry.yarnpkg.com/hex-rgb/-/hex-rgb-4.1.0.tgz#2d5d3a2943bd40e7dc9b0d5b98903d7d17035967"
|
||||
integrity sha512-n7xsIfyBkFChITGPh6FLtxNzAt2HxZLcQIY9hYH4gm2gmMQJHMguMH3E+jnmvUbSTF5QrmFnGab5Ippi+D7e/g==
|
||||
|
||||
hey-listen@^1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68"
|
||||
integrity sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==
|
||||
|
||||
highlight-es@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/highlight-es/-/highlight-es-1.0.3.tgz#12abc300a27e686f6f18010134e3a5c6d2fe6930"
|
||||
|
@ -12361,6 +12405,18 @@ pngjs@^3.0.0, pngjs@^3.3.1, pngjs@^3.3.3:
|
|||
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f"
|
||||
integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==
|
||||
|
||||
popmotion@9.0.0-beta-8:
|
||||
version "9.0.0-beta-8"
|
||||
resolved "https://registry.yarnpkg.com/popmotion/-/popmotion-9.0.0-beta-8.tgz#f5a709f11737734e84f2a6b73f9bcf25ee30c388"
|
||||
integrity sha512-6eQzqursPvnP7ePvdfPeY4wFHmS3OLzNP8rJRvmfFfEIfpFqrQgLsM50Gd9AOvGKJtYJOFknNG+dsnzCpgIdAA==
|
||||
dependencies:
|
||||
"@popmotion/easing" "^1.0.1"
|
||||
"@popmotion/popcorn" "^0.4.2"
|
||||
framesync "^4.0.4"
|
||||
hey-listen "^1.0.8"
|
||||
style-value-types "^3.1.6"
|
||||
tslib "^1.10.0"
|
||||
|
||||
popper.js@1.16.1-lts:
|
||||
version "1.16.1-lts"
|
||||
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1-lts.tgz#cf6847b807da3799d80ee3d6d2f90df8a3f50b05"
|
||||
|
@ -15086,6 +15142,14 @@ style-search@^0.1.0:
|
|||
resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902"
|
||||
integrity sha1-eVjHk+R+MuB9K1yv5cC/jhLneQI=
|
||||
|
||||
style-value-types@^3.1.6, style-value-types@^3.1.7, style-value-types@^3.1.9:
|
||||
version "3.1.9"
|
||||
resolved "https://registry.yarnpkg.com/style-value-types/-/style-value-types-3.1.9.tgz#faf7da660d3f284ed695cff61ea197d85b9122cc"
|
||||
integrity sha512-050uqgB7WdvtgacoQKm+4EgKzJExVq0sieKBQQtJiU3Muh6MYcCp4T3M8+dfl6VOF2LR0NNwXBP1QYEed8DfIw==
|
||||
dependencies:
|
||||
hey-listen "^1.0.8"
|
||||
tslib "^1.10.0"
|
||||
|
||||
styled-components@^4.3.0:
|
||||
version "4.4.1"
|
||||
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-4.4.1.tgz#e0631e889f01db67df4de576fedaca463f05c2f2"
|
||||
|
@ -15883,7 +15947,7 @@ tsconfig-paths@^3.9.0:
|
|||
minimist "^1.2.0"
|
||||
strip-bom "^3.0.0"
|
||||
|
||||
tslib@^1.0.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
|
||||
tslib@^1.0.0, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
|
||||
version "1.13.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
|
||||
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
|
||||
|
|
Loading…
Reference in a new issue