diff --git a/components/Announcement.js b/components/Announcement.js index ae02bea..d98f737 100644 --- a/components/Announcement.js +++ b/components/Announcement.js @@ -1,93 +1,97 @@ import React from 'react' -const key = 'CARBON_CTA_1' +import { useAuth } from './AuthContext' -class Toast extends React.Component { - state = { - open: false - } +const key = 'CARBON_CTA_1' - close = () => { - this.setState({ open: false }) - window.localStorage.setItem(key, true) - } +function Toast() { + const [open, setState] = React.useState(false) - componentDidMount() { + React.useEffect(() => { window.localStorage.removeItem('CARBON_CTA') if (!window.localStorage.getItem(key)) { - this.setState({ open: true }) + setState(true) } + }, []) + + const user = useAuth() + + if (process.env.NODE_ENV !== 'production') { + return null } - render() { - if (process.env.NODE_ENV !== 'production') { - return null - } + if (!open) { + return null + } - if (!this.state.open) { - return null - } + if (user) { + return null + } - return ( -
-
-

Never lose a Carbon again - save your work automatically!

- Click "Sign up" to try it out! - -
- -
- ) - } + a { + text-decoration: underline; + } + + .close-toast { + padding-left: 0; + padding-right: 0; + background: transparent; + color: white; + border: none; + font-size: 100%; + margin-left: 32px; + text-decoration: none; + cursor: pointer; + } + + p { + margin: 0; + margin-right: 12px; + } + `} + + + ) } export default Toast diff --git a/components/Page.js b/components/Page.js index dbf884e..0344f20 100644 --- a/components/Page.js +++ b/components/Page.js @@ -11,9 +11,9 @@ class Page extends React.Component { return (
- -
+ +
{children}