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 style

Maksim Mrug2b694e8413b9
diff --git a/app/App.tsx b/app/App.tsx
index f8aa8810c..82d4ea561 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -68,35 +68,6 @@ 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='assets/logo_blue.png' alt='Swetrix' />
- </div>
- </div>
- )
-}
-
const App = () => {
const dispatch = useAppDispatch()
const { pathname } = useLocation()
diff --git a/app/hoc/renderOnClient.tsx b/app/hoc/renderOnClient.tsx
new file mode 100644
index 000000000..1b8bdbbaa
--- /dev/null
+++ b/app/hoc/renderOnClient.tsx
@@ -0,0 +1,32 @@
+import React from 'react'
+
+let isHydrating = true
+
+const RenderOnClient = ({ 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='assets/logo_blue.png' alt='Swetrix' />
+ </div>
+ </div>
+ )
+}
+
+export default RenderOnClient
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index 101a3f007..7dfdf680f 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -34,7 +34,7 @@ import _size from 'lodash/size'
import _truncate from 'lodash/truncate'
import _isString from 'lodash/isString'
import PropTypes from 'prop-types'
-import * as SwetrixSDK from '@swetrix/sdk'
+// import * as SwetrixSDK from '@swetrix/sdk'
import { withProjectProtected } from 'hoc/projectProtected'
@@ -78,7 +78,6 @@ import RefRow from './components/RefRow'
import NoEvents from './components/NoEvents'
import Filters from './components/Filters'
import ProjectAlertsView from '../Alerts/View'
-import './styles.css'
const CUSTOM_EV_DROPDOWN_MAX_VISIBLE_LENGTH = 32
@@ -255,17 +254,19 @@ const ViewProject = ({
// first we check if we have activeTab in url
// if we have activeTab in url, we return it
// if we do not have activeTab in url, we return activeTab from localStorage or default tab trafic
+ return projectTab || PROJECT_TABS.traffic
+ })
+
+ useEffect(() => {
// @ts-ignore
const url = new URL(window.location)
const { searchParams } = url
const tab = searchParams.get('tab') as string
if (PROJECT_TABS[tab]) {
- return tab || 'traffic'
+ setActiveTab(tab)
}
-
- return projectTab || PROJECT_TABS.traffic
- })
+ }, [])
// pgActiveFragment is a active fragment for pagination
const [pgActiveFragment, setPgActiveFragment] = useState<number>(0)
@@ -1171,60 +1172,60 @@ const ViewProject = ({
}, [isLoading, activeChartMetrics, chartData, chartDataPerf, activeChartMetricsPerf, dataChartCompare]) // eslint-disable-line
// Initialising Swetrix SDK instance. Using for marketplace and extensions
- useEffect(() => {
- let sdk: any | null = null
-
- const filteredExtensions = _filter(extensions, (ext) => _isString(ext.fileURL))
-
- if (!_isEmpty(filteredExtensions)) {
- const processedExtensions = _map(filteredExtensions, (ext) => {
- const { id: extId, fileURL } = ext
- return {
- id: extId,
- cdnURL: `${CDN_URL}file/${fileURL}`,
- }
- })
-
- // @ts-ignore
- sdk = new SwetrixSDK(processedExtensions, {
- debug: isDevelopment,
- }, {
- onAddExportDataRow: (label: any, onClick: (e: any) => void) => {
- setCustomExportTypes((prev) => [
- ...prev,
- {
- label,
- onClick,
- },
- ])
- },
- onRemoveExportDataRow: (label: any) => {
- setCustomExportTypes((prev) => _filter(prev, (row) => row.label !== label))
- },
- onAddPanelTab: (extensionID: string, panelID: string, tabContent: any, onOpen: (a: any) => void) => {
- setCustomPanelTabs((prev) => [
- ...prev,
- {
- extensionID,
- panelID,
- tabContent,
- onOpen,
- },
- ])
- },
- onRemovePanelTab: (extensionID: string, panelID: string) => {
- setCustomPanelTabs((prev) => _filter(prev, (row) => row.extensionID !== extensionID && row.panelID !== panelID))
- },
- })
- setSdkInstance(sdk)
- }
-
- return () => {
- if (sdk) {
- sdk._destroy()
- }
- }
- }, [extensions])
+ // useEffect(() => {
+ // let sdk: any | null = null
+
+ // const filteredExtensions = _filter(extensions, (ext) => _isString(ext.fileURL))
+
+ // if (!_isEmpty(filteredExtensions)) {
+ // const processedExtensions = _map(filteredExtensions, (ext) => {
+ // const { id: extId, fileURL } = ext
+ // return {
+ // id: extId,
+ // cdnURL: `${CDN_URL}file/${fileURL}`,
+ // }
+ // })
+
+ // // @ts-ignore
+ // sdk = new SwetrixSDK(processedExtensions, {
+ // debug: isDevelopment,
+ // }, {
+ // onAddExportDataRow: (label: any, onClick: (e: any) => void) => {
+ // setCustomExportTypes((prev) => [
+ // ...prev,
+ // {
+ // label,
+ // onClick,
+ // },
+ // ])
+ // },
+ // onRemoveExportDataRow: (label: any) => {
+ // setCustomExportTypes((prev) => _filter(prev, (row) => row.label !== label))
+ // },
+ // onAddPanelTab: (extensionID: string, panelID: string, tabContent: any, onOpen: (a: any) => void) => {
+ // setCustomPanelTabs((prev) => [
+ // ...prev,
+ // {
+ // extensionID,
+ // panelID,
+ // tabContent,
+ // onOpen,
+ // },
+ // ])
+ // },
+ // onRemovePanelTab: (extensionID: string, panelID: string) => {
+ // setCustomPanelTabs((prev) => _filter(prev, (row) => row.extensionID !== extensionID && row.panelID !== panelID))
+ // },
+ // })
+ // setSdkInstance(sdk)
+ // }
+
+ // return () => {
+ // if (sdk) {
+ // sdk._destroy()
+ // }
+ // }
+ // }, [extensions])
// Supplying 'timeupdate' event to the SDK after loading. Using for marketplace and extensions
useEffect(() => {
diff --git a/app/pages/Project/View/styles.css b/app/pages/Project/View/styles.css
deleted file mode 100644
index 4033bbaf4..000000000
--- a/app/pages/Project/View/styles.css
+++ /dev/null
@@ -1,15 +0,0 @@
-html.dark .bb-legend-item text {
- fill: #f9fafb;
-}
-
-html.dark .bb-axis {
- fill: #f9fafb;
-}
-
-@media (max-width: 640px) {
- .custom-space-x-style > :not([hidden]) ~ :not([hidden]) {
- --tw-space-x-reverse: 0 !important;
- margin-right: calc(0.5rem * var(--tw-space-x-reverse)) !important;
- margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse))) !important;
- }
-}
diff --git a/app/root.tsx b/app/root.tsx
index f3658775f..39aad1714 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -15,6 +15,7 @@ import _map from 'lodash/map'
// @ts-ignore
import { transitions, positions, Provider as AlertProvider } from '@blaumaus/react-alert'
import BillboardCss from 'billboard.js/dist/billboard.min.css'
+// import { getCookie } from 'utils/cookie'
import AlertTemplate from 'ui/Alert'
import { trackViews } from 'utils/analytics'
@@ -25,6 +26,13 @@ import { detectLanguage } from 'i18n'
import mainCss from 'styles/index.css'
import tailwindCss from 'styles/tailwind.css'
+import FlatpickerCss from 'styles/Flatpicker.css'
+import FlatpickerLibaryCss from 'flatpickr/dist/themes/dark.css'
+
+// if (getCookie('colour-theme') === 'light') {
+// // @ts-ignore
+// FlatpickerLibaryCss = import('flatpickr/dist/themes/light.css')
+// }
trackViews()
@@ -48,6 +56,8 @@ export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: tailwindCss },
{ rel: 'stylesheet', href: mainCss },
{ rel: 'stylesheet', href: BillboardCss },
+ { rel: 'stylesheet', href: FlatpickerCss },
+ { rel: 'stylesheet', href: FlatpickerLibaryCss },
{ rel: 'preconnect', href: FONTS_PROVIDER },
{ rel: 'stylesheet', href: FONTS_URL },
]
diff --git a/app/routes/projects.$id.tsx b/app/routes/projects.$id.tsx
index fe00cc8e1..b4d7ead31 100644
--- a/app/routes/projects.$id.tsx
+++ b/app/routes/projects.$id.tsx
@@ -1,5 +1,6 @@
import ViewProject from 'pages/Project/View'
-import type { V2_MetaFunction } from '@remix-run/node'
+import type { V2_MetaFunction, LinksFunction } from '@remix-run/node'
+import ProjectViewStyle from 'styles/ProjectViewStyle.css'
export const meta: V2_MetaFunction = () => {
return [
@@ -10,6 +11,10 @@ export const meta: V2_MetaFunction = () => {
]
}
+export const links: LinksFunction = () => [
+ { rel: 'stylesheet', href: ProjectViewStyle },
+]
+
export default function Index() {
return <ViewProject />
}
diff --git a/app/ui/ButtonChristmas.css b/app/styles/ButtonChristmas.css
similarity index 100%
rename from app/ui/ButtonChristmas.css
rename to app/styles/ButtonChristmas.css
diff --git a/app/ui/Button.tsx b/app/ui/Button.tsx
index 6c1f3c469..3fa864ff1 100644
--- a/app/ui/Button.tsx
+++ b/app/ui/Button.tsx
@@ -5,7 +5,6 @@ import PropTypes from 'prop-types'
// import { useSelector } from 'react-redux'
// import { THEME_TYPE } from 'redux/constants'
import Spin from './icons/Spin'
-import './ButtonChristmas.css'
// Define the prop types for the component
interface IButton {
diff --git a/app/ui/Flatpicker.css b/app/ui/Flatpicker.css
deleted file mode 100644
index 9ab1625d1..000000000
--- a/app/ui/Flatpicker.css
+++ /dev/null
@@ -1,60 +0,0 @@
-.flatpicker-custom .flatpickr-calendar.static {
- position: absolute !important;
-}
-
-.flatpicker-custom .flatpickr-calendar.static.open {
- left: -310px;
- top: 30px;
-}
-
-.flatpicker-custom .flatpickr-day.selected,
-.flatpicker-custom .flatpickr-day.startRange,
-.flatpicker-custom .flatpickr-day.endRange,
-.flatpicker-custom .flatpickr-day.selected.inRange,
-.flatpicker-custom .flatpickr-day.startRange.inRange,
-.flatpicker-custom .flatpickr-day.endRange.inRange,
-.flatpicker-custom .flatpickr-day.selected:focus,
-.flatpicker-custom .flatpickr-day.startRange:focus,
-.flatpicker-custom .flatpickr-day.endRange:focus,
-.flatpicker-custom .flatpickr-day.selected:hover,
-.flatpicker-custom .flatpickr-day.startRange:hover,
-.flatpicker-custom .flatpickr-day.endRange:hover,
-.flatpicker-custom .flatpickr-day.selected.prevMonthDay,
-.flatpicker-custom .flatpickr-day.startRange.prevMonthDay,
-.flatpicker-custom .flatpickr-day.endRange.prevMonthDay,
-.flatpicker-custom .flatpickr-day.selected.nextMonthDay,
-.flatpicker-custom .flatpickr-day.startRange.nextMonthDay,
-.flatpicker-custom .flatpickr-day.endRange.nextMonthDay {
- background: #1d4ed8;
- -webkit-box-shadow: none;
- box-shadow: none;
- color: #fff;
- border-color: #1d4ed8;
-}
-
-/* if you need other color on dark theme */
-
-.dark .flatpicker-custom .flatpickr-day.selected,
-.dark .flatpicker-custom .flatpickr-day.startRange,
-.dark .flatpicker-custom .flatpickr-day.endRange,
-.dark .flatpicker-custom .flatpickr-day.selected.inRange,
-.dark .flatpicker-custom .flatpickr-day.startRange.inRange,
-.dark .flatpicker-custom .flatpickr-day.endRange.inRange,
-.dark .flatpicker-custom .flatpickr-day.selected:focus,
-.dark .flatpicker-custom .flatpickr-day.startRange:focus,
-.dark .flatpicker-custom .flatpickr-day.endRange:focus,
-.dark .flatpicker-custom .flatpickr-day.selected:hover,
-.dark .flatpicker-custom .flatpickr-day.startRange:hover,
-.dark .flatpicker-custom .flatpickr-day.endRange:hover,
-.dark .flatpicker-custom .flatpickr-day.selected.prevMonthDay,
-.dark .flatpicker-custom .flatpickr-day.startRange.prevMonthDay,
-.dark .flatpicker-custom .flatpickr-day.endRange.prevMonthDay,
-.dark .flatpicker-custom .flatpickr-day.selected.nextMonthDay,
-.dark .flatpicker-custom .flatpickr-day.startRange.nextMonthDay,
-.dark .flatpicker-custom .flatpickr-day.endRange.nextMonthDay {
- background: #4f46e5;
- -webkit-box-shadow: none;
- box-shadow: none;
- color: #fff;
- border-color: #4f46e5;
-}
\ No newline at end of file
diff --git a/app/ui/Flatpicker.tsx b/app/ui/Flatpicker.tsx
index b928a6c51..f4a26fb02 100644
--- a/app/ui/Flatpicker.tsx
+++ b/app/ui/Flatpicker.tsx
@@ -5,17 +5,7 @@ import _size from 'lodash/size'
import _split from 'lodash/split'
import PropTypes from 'prop-types'
-import { getCookie } from 'utils/cookie'
import { MAX_MONTHS_IN_PAST } from 'redux/constants'
-import './Flatpicker.css'
-
-if (getCookie('colour-theme') === 'light') {
- // @ts-ignore
- import('flatpickr/dist/themes/light.css')
-} else {
- // @ts-ignore
- import('flatpickr/dist/themes/dark.css')
-}
interface FlatPickerProps {
onChange?: (dates: Date[]) => void,