-
Notifications
You must be signed in to change notification settings - Fork 0
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 #83 from Plant-for-the-Planet-org/feature/cookieWi…
…dget Cookie Policy widget
- Loading branch information
Showing
9 changed files
with
208 additions
and
2 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,2 +1,3 @@ | ||
API_URL=https://app.plant-for-the-planet.org/app | ||
CDN_URL=https://cdn.plant-for-the-planet.org | ||
CDN_URL=https://cdn.plant-for-the-planet.org | ||
ENVIORNMENT=PROD |
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 @@ | ||
API_URL=https://app-staging.plant-for-the-planet.org/app | ||
CDN_URL=https://cdn.plant-for-the-planet.org | ||
APP_URL=https://www1.plant-for-the-planet.org | ||
ENVIORNMENT=development |
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 |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
"trees": "Trees", | ||
"the": "The", | ||
"forestGrows": "Forest Grows." | ||
} | ||
} |
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
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,103 @@ | ||
<svelte:options tag="tree-popup" immutable={true} /> | ||
|
||
<script> | ||
import { writable } from "../../utils/localstorage"; | ||
export let message; | ||
export let buttontext; | ||
export let theme = "light"; | ||
const now = new Date(); | ||
let cookiePolicy = localStorage.getItem("hidePlanetCookie"); | ||
if(cookiePolicy){ | ||
cookiePolicy = JSON.parse(cookiePolicy) | ||
if(now.getTime() > cookiePolicy.expiry){ | ||
localStorage.removeItem('hidePlanetCookie') | ||
cookiePolicy = null; | ||
} | ||
} | ||
export const hideCookieNotification = writable(cookiePolicy); | ||
function hideCookieNotice() { | ||
const expiryTime = now.getTime() + (__myapp.env.ENVIORNMENT === 'development' ? 15000 : 15778800000) //6 months in milliseconds | ||
const data ={ | ||
value: true, | ||
expiry: expiryTime, | ||
} | ||
hideCookieNotification.subscribe((value) => { | ||
localStorage.setItem("hidePlanetCookie", JSON.stringify(data)); | ||
}); | ||
cookiePolicy = true; | ||
} | ||
</script> | ||
|
||
{#if !cookiePolicy} | ||
<div | ||
class="cookie-policy" | ||
style="--bg-color: {theme === 'light' ? '#fff' : '#2f3336'}; | ||
--text-color: {theme === 'light' | ||
? '#000000' | ||
: '#fff'};" | ||
> | ||
<div class="policy-notice"> | ||
<div class="cookie-policy-link" /> | ||
{@html message} | ||
</div> | ||
<button | ||
id={"cookie-close-button"} | ||
class="primary-button" | ||
on:click={hideCookieNotice} | ||
> | ||
{buttontext} | ||
</button> | ||
</div> | ||
{/if} | ||
|
||
<style> | ||
.cookie-policy-link { | ||
font-weight: 700; | ||
color: #007a49; | ||
text-decoration: none; | ||
} | ||
.cookie-policy { | ||
position: fixed; | ||
background-color: var(--bg-color); | ||
color: var(--text-color); | ||
box-shadow: 0px 3px 6px -3px; | ||
bottom: 20px; | ||
left: 20px; | ||
width: 280px; | ||
border-radius: 4px; | ||
padding: 20px; | ||
z-index: 999999; | ||
font-family: "Raleway", sans-serif; | ||
} | ||
.policy-notice { | ||
text-align: center; | ||
} | ||
.primary-button { | ||
color: white; | ||
font-weight: bold; | ||
background-image: linear-gradient(97deg, #68b030 4%, #007a49 116%); | ||
height: 40px; | ||
padding: 0px; | ||
text-align: center; | ||
border: 0px; | ||
border-radius: 40px; | ||
min-width: 200px; | ||
width: 100%; | ||
margin-top: 24px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
transition-duration: 0.5s; | ||
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1); | ||
text-decoration: none; | ||
} | ||
.primary-button:hover { | ||
transform: translateY(-7px); | ||
cursor: pointer; | ||
} | ||
</style> |
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,3 @@ | ||
import App from "./App.svelte"; | ||
|
||
export default App; |
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,30 @@ | ||
import {writable as internal, get} from 'svelte/store' | ||
export function writable(key, initialValue) { | ||
// create an underlying store | ||
const store = internal(initialValue) | ||
const {subscribe, set} = store | ||
// get the last value from localStorage | ||
const json = localStorage.getItem(key) | ||
|
||
// use the value from localStorage if it exists | ||
if (json) { | ||
set(JSON.parse(json)) | ||
} | ||
|
||
// return an object with the same interface as svelte's writable() | ||
return { | ||
// capture set and write to localStorage | ||
set(value) { | ||
localStorage.setItem(key, JSON.stringify(value)) | ||
set(value) | ||
}, | ||
// capture updates and write to localStore | ||
update(cb) { | ||
const value = cb(get(store)) | ||
this.set(value) | ||
}, | ||
// punt subscriptions to underlying store | ||
subscribe | ||
} | ||
} | ||
|