-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Faucet Responsive + Fix Flicker (#1782)
Co-authored-by: Pavan Soratur <[email protected]>
- Loading branch information
1 parent
4ea6a42
commit b21aa3e
Showing
6 changed files
with
163 additions
and
76 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
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,33 @@ | ||
import { SIDEBAR_OPEN_KEY } from '@webb-tools/webb-ui-components/constants'; | ||
import { getCookie, setCookie } from 'cookies-next'; | ||
|
||
/** | ||
* Set the sidebar state in the cookie on client side | ||
*/ | ||
export const setSideBarCookieOnToggle = () => { | ||
const sideBarStateFromCookie = getCookie(SIDEBAR_OPEN_KEY); | ||
|
||
if (sideBarStateFromCookie === 'true') { | ||
setCookie(SIDEBAR_OPEN_KEY, 'false'); | ||
} else { | ||
setCookie(SIDEBAR_OPEN_KEY, 'true'); | ||
} | ||
}; | ||
|
||
/** | ||
* Getting the sidebar state from the on server side to prevent hydration error | ||
* NOTE: this function only works on getServerSideProps according to cookies-next doc | ||
* @param options options required to get the cookie from the server | ||
* @returns the state of the sidebar that is stored in the cookie | ||
*/ | ||
export function getSideBarStateFromCookie( | ||
options: Parameters<typeof getCookie>[1] | ||
) { | ||
const sideBarStateFromCookie = getCookie(SIDEBAR_OPEN_KEY, options); | ||
|
||
return sideBarStateFromCookie === undefined | ||
? undefined | ||
: sideBarStateFromCookie === 'true' | ||
? true | ||
: false; | ||
} |
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 |
---|---|---|
|
@@ -9348,6 +9348,11 @@ | |
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/cookie@^0.4.1": | ||
version "0.4.1" | ||
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" | ||
integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== | ||
|
||
"@types/cross-spawn@^6.0.2": | ||
version "6.0.3" | ||
resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.3.tgz#c743cb2608f55860ee9776d8c99135d6032c763c" | ||
|
@@ -9706,6 +9711,11 @@ | |
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.54.tgz#4a63bdcea5b714f546aa27406a1c60621236a132" | ||
integrity sha512-oTmGy68gxZZ21FhTJVVvZBYpQHEBZxHKTsGshobMqm9qWpbqdZsA5jvsuPZcHu0KwpmLrOHWPdEfg7XDpNT9UA== | ||
|
||
"@types/node@^16.10.2": | ||
version "16.18.59" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.59.tgz#4cdbd631be6d9be266a96fb17b5d0d7ad6bbe26c" | ||
integrity sha512-PJ1w2cNeKUEdey4LiPra0ZuxZFOGvetswE8qHRriV/sUkL5Al4tTmPV9D2+Y/TPIxTHHgxTfRjZVKWhPw/ORhQ== | ||
|
||
"@types/node@^18.17.5": | ||
version "18.18.0" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.0.tgz#bd19d5133a6e5e2d0152ec079ac27c120e7f1763" | ||
|
@@ -14067,6 +14077,20 @@ [email protected], cookie@^0.5.0: | |
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" | ||
integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== | ||
|
||
cookie@^0.4.0: | ||
version "0.4.2" | ||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" | ||
integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== | ||
|
||
cookies-next@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/cookies-next/-/cookies-next-4.0.0.tgz#36d5c0d5899cf729a2580fd065071bdfa13783ca" | ||
integrity sha512-3TyzeltFCGgdOlVOVTPClSq+YV9ZCdOyA3aHRZv9f5aSgg7EyI4NSvXFOCgzT/xIxeHR4Rz8/z5Tdo9oPqaVpA== | ||
dependencies: | ||
"@types/cookie" "^0.4.1" | ||
"@types/node" "^16.10.2" | ||
cookie "^0.4.0" | ||
|
||
copy-anything@^2.0.1: | ||
version "2.0.6" | ||
resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.6.tgz#092454ea9584a7b7ad5573062b2a87f5900fc480" | ||
|