Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix loader, add hoc for render on client

Maksim Mrug07d144f3d2fe
diff --git a/app/App.tsx b/app/App.tsx
index 719ddb005..6e33d552a 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -29,6 +29,7 @@ import { errorsActions } from 'redux/reducers/errors'
import { alertsActions } from 'redux/reducers/alerts'
import { StateType, useAppDispatch } from 'redux/store'
import UIActions from 'redux/reducers/ui'
+import swetrixLogo from 'assets/logo_blue.png'
import { getRefreshToken } from 'utils/refreshToken'
import { authMe } from './api'
@@ -58,6 +59,8 @@ const Fallback = ({ isMinimalFooter }: FallbackProps): JSX.Element => {
}
}, [])
+ console.log('showLoader', showLoader)
+
return (
<div className={cx('bg-gray-50 dark:bg-slate-900', { 'min-h-page': !isMinimalFooter, 'min-h-min-footer': isMinimalFooter })}>
{showLoader && (
@@ -67,6 +70,35 @@ const Fallback = ({ isMinimalFooter }: FallbackProps): JSX.Element => {
)
}
+let isHydrating = true
+
+const HocThrowErrorWhenWindowIsUndefined = ({ children }: { children: React.ReactNode }) => {
+ const [isHydrated, setIsHydrated] = React.useState(
+ !isHydrating,
+ )
+
+ React.useEffect(() => {
+ isHydrating = false
+ setIsHydrated(true)
+ }, [])
+
+ if (isHydrated) {
+ return children
+ }
+
+ return (
+ <div className='loader' id='loader'>
+ <div className='loader-head'>
+ <div className='first' />
+ <div className='second' />
+ </div>
+ <div className='logo-frame'>
+ <img className='logo-frame-img' width='361' height='80' src={swetrixLogo} alt='' />
+ </div>
+ </div>
+ )
+}
+
const App = () => {
const dispatch = useAppDispatch()
const location = useLocation()
@@ -166,14 +198,14 @@ const App = () => {
const isMinimalFooter = _some(minimalFooterPages, (page) => _includes(location.pathname, page))
return (
- <>
+ <HocThrowErrorWhenWindowIsUndefined>
{(!accessToken || !loading) && (
// eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
<Header
authenticated={authenticated}
theme={theme}
- // themeType={themeType}
+ // themeType={themeType}
user={user}
/>
{/* {location.pathname === routes.main && (
@@ -194,7 +226,7 @@ const App = () => {
</Suspense>
)}
<div className='hidden' />
- </>
+ </HocThrowErrorWhenWindowIsUndefined>
)
}
diff --git a/public/assets/CoreFeaturesLight.png b/app/assets/CoreFeaturesLight.png
similarity index 100%
rename from public/assets/CoreFeaturesLight.png
rename to app/assets/CoreFeaturesLight.png
diff --git a/public/assets/CoreFeaturesLight.webp b/app/assets/CoreFeaturesLight.webp
similarity index 100%
rename from public/assets/CoreFeaturesLight.webp
rename to app/assets/CoreFeaturesLight.webp
diff --git a/public/assets/Elipse.png b/app/assets/Elipse.png
similarity index 100%
rename from public/assets/Elipse.png
rename to app/assets/Elipse.png
diff --git a/public/assets/andrii-120px.png b/app/assets/andrii-120px.png
similarity index 100%
rename from public/assets/andrii-120px.png
rename to app/assets/andrii-120px.png
diff --git a/public/assets/andrii.jpg b/app/assets/andrii.jpg
similarity index 100%
rename from public/assets/andrii.jpg
rename to app/assets/andrii.jpg
diff --git a/public/assets/chrome.svg b/app/assets/chrome.svg
similarity index 100%
rename from public/assets/chrome.svg
rename to app/assets/chrome.svg
diff --git a/public/assets/firefox.svg b/app/assets/firefox.svg
similarity index 100%
rename from public/assets/firefox.svg
rename to app/assets/firefox.svg
diff --git a/public/assets/gdpr.svg b/app/assets/gdpr.svg
similarity index 100%
rename from public/assets/gdpr.svg
rename to app/assets/gdpr.svg
diff --git a/public/assets/ivan.jpg b/app/assets/ivan.jpg
similarity index 100%
rename from public/assets/ivan.jpg
rename to app/assets/ivan.jpg
diff --git a/public/assets/linkedin.svg b/app/assets/linkedin.svg
similarity index 100%
rename from public/assets/linkedin.svg
rename to app/assets/linkedin.svg
diff --git a/public/assets/logo_blue.png b/app/assets/logo_blue.png
similarity index 100%
rename from public/assets/logo_blue.png
rename to app/assets/logo_blue.png
diff --git a/public/assets/logo_blue.svg b/app/assets/logo_blue.svg
similarity index 100%
rename from public/assets/logo_blue.svg
rename to app/assets/logo_blue.svg
diff --git a/public/assets/logo_white.png b/app/assets/logo_white.png
similarity index 100%
rename from public/assets/logo_white.png
rename to app/assets/logo_white.png
diff --git a/public/assets/logo_white.svg b/app/assets/logo_white.svg
similarity index 100%
rename from public/assets/logo_white.svg
rename to app/assets/logo_white.svg
diff --git a/public/assets/logo_white_christmas.png b/app/assets/logo_white_christmas.png
similarity index 100%
rename from public/assets/logo_white_christmas.png
rename to app/assets/logo_white_christmas.png
diff --git a/public/assets/maxim.jpg b/app/assets/maxim.jpg
similarity index 100%
rename from public/assets/maxim.jpg
rename to app/assets/maxim.jpg
diff --git a/public/assets/mc.png b/app/assets/mc.png
similarity index 100%
rename from public/assets/mc.png
rename to app/assets/mc.png
diff --git a/public/assets/og_image.png b/app/assets/og_image.png
similarity index 100%
rename from public/assets/og_image.png
rename to app/assets/og_image.png
diff --git a/public/assets/opensource_dark.png b/app/assets/opensource_dark.png
similarity index 100%
rename from public/assets/opensource_dark.png
rename to app/assets/opensource_dark.png
diff --git a/public/assets/opensource_dark.webp b/app/assets/opensource_dark.webp
similarity index 100%
rename from public/assets/opensource_dark.webp
rename to app/assets/opensource_dark.webp
diff --git a/public/assets/opensource_light.png b/app/assets/opensource_light.png
similarity index 100%
rename from public/assets/opensource_light.png
rename to app/assets/opensource_light.png
diff --git a/public/assets/opensource_light.webp b/app/assets/opensource_light.webp
similarity index 100%
rename from public/assets/opensource_light.webp
rename to app/assets/opensource_light.webp
diff --git a/public/assets/pci.png b/app/assets/pci.png
similarity index 100%
rename from public/assets/pci.png
rename to app/assets/pci.png
diff --git a/public/assets/screenshot_dark.png b/app/assets/screenshot_dark.png
similarity index 100%
rename from public/assets/screenshot_dark.png
rename to app/assets/screenshot_dark.png
diff --git a/public/assets/screenshot_dark.webp b/app/assets/screenshot_dark.webp
similarity index 100%
rename from public/assets/screenshot_dark.webp
rename to app/assets/screenshot_dark.webp
diff --git a/public/assets/screenshot_light.png b/app/assets/screenshot_light.png
similarity index 100%
rename from public/assets/screenshot_light.png
rename to app/assets/screenshot_light.png
diff --git a/public/assets/screenshot_light.webp b/app/assets/screenshot_light.webp
similarity index 100%
rename from public/assets/screenshot_light.webp
rename to app/assets/screenshot_light.webp
diff --git a/public/assets/section-signup-dark.png b/app/assets/section-signup-dark.png
similarity index 100%
rename from public/assets/section-signup-dark.png
rename to app/assets/section-signup-dark.png
diff --git a/public/assets/section-signup-dark.webp b/app/assets/section-signup-dark.webp
similarity index 100%
rename from public/assets/section-signup-dark.webp
rename to app/assets/section-signup-dark.webp
diff --git a/public/assets/section-signup-light.png b/app/assets/section-signup-light.png
similarity index 100%
rename from public/assets/section-signup-light.png
rename to app/assets/section-signup-light.png
diff --git a/public/assets/section-signup-light.webp b/app/assets/section-signup-light.webp
similarity index 100%
rename from public/assets/section-signup-light.webp
rename to app/assets/section-signup-light.webp
diff --git a/public/assets/swe2.png b/app/assets/swe2.png
similarity index 100%
rename from public/assets/swe2.png
rename to app/assets/swe2.png
diff --git a/public/assets/swe3.png b/app/assets/swe3.png
similarity index 100%
rename from public/assets/swe3.png
rename to app/assets/swe3.png
diff --git a/public/assets/swe4.png b/app/assets/swe4.png
similarity index 100%
rename from public/assets/swe4.png
rename to app/assets/swe4.png
diff --git a/public/assets/teardown.svg b/app/assets/teardown.svg
similarity index 100%
rename from public/assets/teardown.svg
rename to app/assets/teardown.svg
diff --git a/public/assets/visa.png b/app/assets/visa.png
similarity index 100%
rename from public/assets/visa.png
rename to app/assets/visa.png
diff --git a/public/assets/yehor.jpg b/app/assets/yehor.jpg
similarity index 100%
rename from public/assets/yehor.jpg
rename to app/assets/yehor.jpg
diff --git a/public/assets/yevhenii.jpg b/app/assets/yevhenii.jpg
similarity index 100%
rename from public/assets/yevhenii.jpg
rename to app/assets/yevhenii.jpg
diff --git a/app/root.tsx b/app/root.tsx
index ff400e828..09ef5b810 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -17,6 +17,7 @@ import { getRefreshToken } from 'utils/refreshToken'
import AppWrapper from 'App'
+import mainCss from 'styles/index.css'
import tailwindCss from './css/tailwind.css'
trackViews()
@@ -36,6 +37,7 @@ if (process.env.NODE_ENV !== 'production') {
export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: tailwindCss },
+ { rel: 'stylesheet', href: mainCss },
]
const removeObsoleteAuthTokens = () => {
diff --git a/app/styles/index.css b/app/styles/index.css
new file mode 100644
index 000000000..94c8e95d6
--- /dev/null
+++ b/app/styles/index.css
@@ -0,0 +1,373 @@
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ -webkit-font-smoothing: antialiased
+}
+
+.loader.available {
+ opacity: 0
+}
+
+.loader {
+ background-color: #f9fafb;
+ width: 100%;
+ height: 100%;
+ position: fixed;
+ opacity: 1;
+ pointer-events: none;
+ -webkit-transition: opacity cubic-bezier(.4, 0, .2, 1) 436ms;
+ -moz-transition: opacity cubic-bezier(.4, 0, .2, 1) 436ms;
+ transition: opacity cubic-bezier(.4, 0, .2, 1) 436ms;
+ z-index: 9999
+}
+
+.logo-frame {
+ display: -webkit-flex;
+ display: -moz-flex;
+ display: flex;
+ -webkit-flex-direction: column;
+ -moz-flex-direction: column;
+ flex-direction: column;
+ -webkit-justify-content: center;
+ -moz-justify-content: center;
+ justify-content: center;
+ -webkit-animation: fadein 436ms;
+ -moz-animation: fadein 436ms;
+ animation: fadein 436ms;
+ height: 98%
+}
+
+.logo-frame-img {
+ font-size: 30px;
+ padding-left: 10px;
+ padding-right: 10px;
+ -webkit-align-self: center;
+ -moz-align-self: center;
+ align-self: center
+}
+
+.loader-head {
+ background-color: #c6dafc;
+ height: 4px;
+ overflow: hidden;
+ position: relative
+}
+
+.loader .first,
+.loader .second {
+ background-color: #4f46e5;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ top: 0;
+ position: absolute;
+ -webkit-transform-origin: left center;
+ -moz-transform-origin: left center;
+ transform-origin: left center;
+ -webkit-transform: scaleX(0);
+ -moz-transform: scaleX(0);
+ transform: scaleX(0)
+}
+
+.loader .first {
+ -webkit-animation: first 2s linear infinite;
+ -moz-animation: first 2s linear infinite;
+ animation: first 2s linear infinite
+}
+
+.loader .second {
+ -webkit-animation: second 2s linear infinite;
+ -moz-animation: second 2s linear infinite;
+ animation: second 2s linear infinite
+}
+
+@-webkit-keyframes fadein {
+ from {
+ opacity: 0
+ }
+
+ to {
+ opacity: 1
+ }
+}
+
+@-moz-keyframes fadein {
+ from {
+ opacity: 0
+ }
+
+ to {
+ opacity: 1
+ }
+}
+
+@keyframes fadein {
+ from {
+ opacity: 0
+ }
+
+ to {
+ opacity: 1
+ }
+}
+
+@keyframes first {
+ 0% {
+ transform: translate(0) scaleX(0)
+ }
+
+ 25% {
+ transform: translate(0) scaleX(.5)
+ }
+
+ 50% {
+ transform: translate(25%) scaleX(.75)
+ }
+
+ 75% {
+ transform: translate(100%) scaleX(0)
+ }
+
+ 100% {
+ transform: translate(100%) scaleX(0)
+ }
+}
+
+@keyframes second {
+ 0% {
+ transform: translate(0) scaleX(0)
+ }
+
+ 60% {
+ transform: translate(0) scaleX(0)
+ }
+
+ 80% {
+ transform: translate(0) scaleX(.6)
+ }
+
+ 100% {
+ transform: translate(100%) scaleX(.1)
+ }
+}
+
+html {
+ font-family: 'Inter', 'Cantarell', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ scroll-behavior: smooth;
+}
+
+
+.santa-claus {
+ position: absolute;
+ top: 0;
+ right: 0;
+ z-index: 20;
+ /* rotateZ(195deg) */
+ transform: rotateZ(195deg) translateY(140px) translateX(15px);
+ /* move to top 100px after render */
+}
+
+.sc-head {
+ width: 80px;
+ height: 80px;
+ border-radius: 40%;
+ background: #f7caaf;
+ position: relative;
+}
+
+.sc-head .eyes {
+ position: absolute;
+ left: 2px;
+ top: 20px;
+ display: table;
+ margin: 0 auto;
+}
+
+.sc-head .eyes::before,
+.sc-head .eyes::after {
+ content: "";
+ width: 8px;
+ height: 8px;
+ background: #000;
+ border-radius: 50%;
+ display: inline-block;
+ margin: 0 15px;
+}
+
+.sc-head .nose {
+ width: 20px;
+ height: 13px;
+ border-radius: 50%;
+ background: #d48c7e;
+ top: 32px;
+ position: relative;
+}
+
+.sc-head .beard {
+ position: absolute;
+ bottom: -45px;
+ left: -10px;
+ background: #fff;
+ width: calc(100% + 20px);
+ height: 80px;
+ border-radius: 20% 20% 60% 60%;
+}
+
+.sc-head .beard::before {
+ content: "";
+ width: 20px;
+ height: 20px;
+ background: #000;
+ border-radius: 0 0 50% 50%;
+ margin-top: 6px;
+}
+
+.sc-head .ears {
+ width: calc(100% + 17px);
+ position: absolute;
+ top: 25px;
+ left: -8px;
+}
+
+.sc-head .ears .ear {
+ width: 10px;
+ height: 20px;
+ background: #d48c7e;
+ border-radius: 50% 0 0 50%;
+}
+
+.sc-head .ears .ear.left {
+ float: left;
+}
+
+.sc-head .ears .ear.right {
+ float: right;
+ transform: rotateZ(180deg);
+}
+
+.sc-hat {
+ position: absolute;
+ top: -37px;
+ left: -6px;
+ width: calc(100% + 10px);
+ height: 55px;
+ background: #de3939;
+ border-radius: 60px 80px 0 0;
+}
+
+.sc-hat::before {
+ content: "";
+ width: inherit;
+ height: 20px;
+ background: #fff;
+ display: block;
+ border-radius: 6px;
+ position: absolute;
+ bottom: -5px;
+ left: -4px;
+}
+
+.sc-hat .hat-tip {
+ width: 0;
+ height: 0;
+ border-left: 20px solid transparent;
+ border-right: 20px solid transparent;
+ border-bottom: 69px solid #de3939;
+ position: absolute;
+ top: -37px;
+ animation: 2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
+ left: 8px;
+}
+
+.sc-hat .hat-tip::before {
+ content: "";
+ width: 20px;
+ height: 20px;
+ background: #fff;
+ border-radius: 50%;
+ display: block;
+ position: absolute;
+ left: -13px;
+ top: -10px;
+}
+
+.sc-body {
+ position: absolute;
+ left: -70px;
+ width: 200px;
+ height: 200px;
+ background: #de3939;
+ border-radius: 30%;
+}
+
+
+/* Temporary solution: this WILL override all the other colour - background colour transitions */
+/* Do not use animations for people with vestibular motion disorders */
+* {
+ transition-property: background-color, color, border-color, fill, stroke;
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+ transition-duration: 200ms;
+}
+
+@media (prefers-reduced-motion) {
+ * {
+ transition: none !important;
+ }
+}
+
+body {
+ margin: 0;
+}
+
+code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
+}
+
+.label {
+ text-overflow: clip;
+ white-space: nowrap;
+ overflow-x: auto;
+ scrollbar-width: thin;
+}
+
+.disabled {
+ opacity: 0.8;
+ cursor: not-allowed;
+}
+
+.hoverable {
+ transition: opacity 300ms;
+}
+
+.hoverable:hover {
+ opacity: 0.75;
+}
+
+/* adaptive panels buttons next and prev */
+.w-card-toggle-sm {
+ width: calc(100% - 2rem) !important;
+}
+
+/* custom scrollbar */
+::-webkit-scrollbar {
+ width: 5px;
+ height: 5px;
+}
+
+::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+::-webkit-scrollbar-thumb {
+ background-color: #9ca3af;
+ border-radius: 10px;
+ cursor: pointer;
+}
+
+::-webkit-scrollbar-thumb:hover {
+ background-color: #6b7280;
+}
\ No newline at end of file