From 1eb9b712b75634579c733164dbea56517dceea27 Mon Sep 17 00:00:00 2001 From: Tilman Frick Date: Mon, 20 May 2019 09:58:13 +0200 Subject: [PATCH] feat: add cookie notice (#795) * feat: add cookie notice * fix: remove wrong text * fix: prevent flickering of cookie notice * fix: move display logic --- packages/site/package.json | 2 +- packages/site/src/cookie-notice.tsx | 26 ++++++++++++++++++++++++++ packages/site/src/site.tsx | 9 ++------- yarn.lock | 8 ++++---- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 packages/site/src/cookie-notice.tsx diff --git a/packages/site/package.json b/packages/site/package.json index 6221f2c3a..33ea5aa5a 100644 --- a/packages/site/package.json +++ b/packages/site/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "@emotion/styled": "^10.0.6", - "@meetalva/alva-design": "^1.4.4", + "@meetalva/alva-design": "^1.6.2", "@types/react": "16.4.11", "@types/react-helmet": "5.0.6", "react": "16.4.2", diff --git a/packages/site/src/cookie-notice.tsx b/packages/site/src/cookie-notice.tsx new file mode 100644 index 000000000..17a167288 --- /dev/null +++ b/packages/site/src/cookie-notice.tsx @@ -0,0 +1,26 @@ +import * as React from 'react'; +import * as D from '@meetalva/alva-design'; + +export class CookieNotice extends React.Component { + public state = { + display: + typeof document !== 'undefined' && document.cookie.indexOf('hidecookienotice=1') === -1 + }; + + public render() { + return ( + this.state.display === true && ( + { + document.cookie = 'hidecookienotice=1;path=/'; + this.setState({ display: false }); + }} + /> + ) + ); + } +} diff --git a/packages/site/src/site.tsx b/packages/site/src/site.tsx index d8df9ab0a..1db30b543 100644 --- a/packages/site/src/site.tsx +++ b/packages/site/src/site.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Helmet } from 'react-helmet'; import * as D from '@meetalva/alva-design'; import { Releases } from './releases'; +import { CookieNotice } from './cookie-notice'; export * from './render'; @@ -155,13 +156,6 @@ const Page: React.StatelessComponent = (): JSX.Element => { } /> - - = (): JSX.Element => { href="./doc/docs/privacypolicy?guides-enabled=true" /> + ); }; diff --git a/yarn.lock b/yarn.lock index 9fc720d20..a2c77c635 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1013,10 +1013,10 @@ mkdirp "^0.5.1" rimraf "^2.5.2" -"@meetalva/alva-design@^1.4.4": - version "1.4.4" - resolved "https://registry.yarnpkg.com/@meetalva/alva-design/-/alva-design-1.4.4.tgz#e48d307e5927453f790d8d651bb8bb8c6e3b7e06" - integrity sha512-rc22upg5LUMx8r1MW+tHUjh3kajiA4PhI/jFxG4K+30r8OmR6hlD8C9FunN2yldMO7oFhnLdHwJLhTM3ymV4RQ== +"@meetalva/alva-design@^1.6.2": + version "1.6.2" + resolved "https://registry.yarnpkg.com/@meetalva/alva-design/-/alva-design-1.6.2.tgz#c9890817b8cfa443e99bcb72994a7d6d50babd64" + integrity sha512-XnpY/WA/TYluWftDoKybhFPzWViRFQg83aYDEbU7uILLgrWYe1zPWVf+nJztrpr+1PYR5r6iisWpDoqhcIhm5g== dependencies: "@emotion/core" "^10.0.6" "@emotion/styled" "^10.0.6"