Skip to content

Commit

Permalink
🔧 improve cookie config
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Jun 28, 2023
1 parent 9267941 commit 776f15e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Improve visual

### Added
- Restrict cookie to current domain

## [1.0.3] - 2023-06-28
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion dist/assets/leckerli.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/assets/leckerli.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Banner = () => {
const { banner, acceptAll, rejectAll, setModal } = useSettings();

return (
<div className="fixed bottom-0 left-0 max-w-md px-5 py-4 m-2 z-[9998] bg-background space-y-4 font-primary text-foreground rounded-md">
<div className="fixed bottom-0 left-0 max-w-md px-5 py-4 m-2 shadow-md shadow-black/25 z-[9998] bg-background space-y-4 font-primary text-foreground rounded-md">
<h3 className="m-0 text-lg font-semibold font-primary md:text-xl">
{banner.title}
</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Settings = () => {
useSettings();

return (
<div className="fixed w-full max-w-md max-h-full px-5 py-4 m-2 text-black z-[9999] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-background text-foreground font-primary rounded-md">
<div className="fixed bottom-0 left-0 w-full max-w-lg max-h-full px-5 py-4 m-2 text-black shadow-md shadow-black/25 z-[9999] bg-background text-foreground font-primary rounded-md">
<div className="space-y-6">
<h3 className="w-10/12 m-0 text-xl font-semibold font-primary md:text-2xl">
{banner.customise}
Expand Down
12 changes: 9 additions & 3 deletions src/hooks/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const useSettings = create<SettingsStore>((set, getState) => ({
// Write cookie if not exist and setup eventListeners
init: () => {
if (isNil(initialCookie) && getState().choiceMade) {
cookies.set(getState().name, JSON.stringify(getState().cookie));
cookies.set(getState().name, JSON.stringify(getState().cookie), {
domain: window.location.host,
});
}

// Emit initial event and data or null if the choice has not been made
Expand Down Expand Up @@ -103,7 +105,9 @@ const useSettings = create<SettingsStore>((set, getState) => ({
return acc;
}, state.baseData);

cookies.set(state.name, JSON.stringify(newCookie));
cookies.set(state.name, JSON.stringify(newCookie), {
domain: window.location.host,
});

// Emit event and data
document.dispatchEvent(
Expand All @@ -129,7 +133,9 @@ const useSettings = create<SettingsStore>((set, getState) => ({
return acc;
}, state.baseData);

cookies.set(state.name, JSON.stringify(newCookie));
cookies.set(state.name, JSON.stringify(newCookie), {
domain: window.location.host,
});

// Emit event and data
document.dispatchEvent(
Expand Down

0 comments on commit 776f15e

Please sign in to comment.