📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Generic Text component
Blue Mouse3bb2c216fba4
diff --git a/web/app/modals/NewFunnel.tsx b/web/app/modals/NewFunnel.tsxindex 541b0a200..e230dfeef 100644--- a/web/app/modals/NewFunnel.tsx+++ b/web/app/modals/NewFunnel.tsx@@ -10,6 +10,7 @@ import { useCurrentProject } from '~/providers/CurrentProjectProvider'import Input from '~/ui/Input'import Modal from '~/ui/Modal'import Select from '~/ui/Select'+import { Text } from '~/ui/Text'interface NewFunnelProps {onClose: () => void@@ -88,7 +89,9 @@ const NewFunnel = ({ onClose, onSubmit, isOpened, funnel, loading }: NewFunnelPronChange={(e) => setName(e.target.value)}disabled={!allowedToManage}/>- <p className='mt-5 text-sm font-medium text-gray-700 dark:text-gray-200'>{t('modals.funnels.steps')}</p>+ <Text as='p' size='sm' weight='medium' colour='secondary' className='mt-5'>+ {t('modals.funnels.steps')}+ </Text>{_map(steps, (step, index) => (<div key={index} className='mt-1 flex items-center space-x-2'><Selectdiff --git a/web/app/pages/Dashboard/Dashboard.tsx b/web/app/pages/Dashboard/Dashboard.tsxindex 9cf4244c1..9b11cfdaa 100644--- a/web/app/pages/Dashboard/Dashboard.tsx+++ b/web/app/pages/Dashboard/Dashboard.tsx@@ -21,6 +21,7 @@ import { FeatureFlag } from '~/lib/models/User'import { useAuth } from '~/providers/AuthProvider'import Modal from '~/ui/Modal'import Pagination from '~/ui/Pagination'+import { Text } from '~/ui/Text'import { setCookie } from '~/utils/cookie'import routes from '~/utils/routes'@@ -330,7 +331,7 @@ const Dashboard = () => {<div className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8'><div className={cx('flex flex-wrap justify-between gap-2', showTabs ? 'mb-2' : 'mb-4')}><div className='flex items-end justify-between'>- <h2 className='mt-2 flex items-baseline gap-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>+ <Text as='h2' size='3xl' weight='bold' className='mt-2 flex items-baseline gap-2'><span>{t('titles.dashboard')}</span>{isSearchActive ? (<button@@ -365,7 +366,7 @@ const Dashboard = () => {/></button>)}- </h2>+ </Text>{isSearchActive ? (<div className='hidden w-full max-w-md items-center px-2 pb-1 sm:ml-2 sm:flex'><label htmlFor='project-search' className='sr-only'>diff --git a/web/app/pages/Dashboard/NoProjects.tsx b/web/app/pages/Dashboard/NoProjects.tsxindex 7e60b2b7d..7ecf40950 100644--- a/web/app/pages/Dashboard/NoProjects.tsx+++ b/web/app/pages/Dashboard/NoProjects.tsx@@ -4,6 +4,7 @@ import React from 'react'import { useTranslation } from 'react-i18next'import { Link } from 'react-router'+import { Text } from '~/ui/Text'import routes from '~/utils/routes'import { DASHBOARD_TABS } from './Tabs'@@ -20,20 +21,26 @@ export const NoProjects = ({ onClick, activeTab, search }: NoProjectsProps) => {if (activeTab !== 'default' || search) {return (<div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-6xl text-gray-900 dark:text-gray-50'>- <h3 className='mb-8 text-center text-xl leading-snug'>{t('dashboard.noProjectsForCriteria')}</h3>+ <div className='mx-auto w-full max-w-6xl'>+ <Text as='h3' size='xl' className='mb-8 text-center leading-snug'>+ {t('dashboard.noProjectsForCriteria')}+ </Text></div></div>)}return (- <div className='mx-auto w-full max-w-2xl py-16 text-center text-gray-900 dark:text-gray-50'>+ <div className='mx-auto w-full max-w-2xl py-16 text-center'><div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-800'><FolderInputIcon className='size-7 text-gray-700 dark:text-gray-200' strokeWidth={1.5} /></div>- <h3 className='text-xl font-medium tracking-tight'>{t('dashboard.noProjects')}</h3>- <p className='mx-auto mt-2 max-w-md text-sm text-gray-800 dark:text-gray-200'>{t('dashboard.createProject')}</p>+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>+ {t('dashboard.noProjects')}+ </Text>+ <Text as='p' size='sm' colour='secondary' className='mx-auto mt-2 max-w-md'>+ {t('dashboard.createProject')}+ </Text><div className='mt-6'><Linkto={routes.new_project}diff --git a/web/app/pages/Dashboard/ProjectCard.tsx b/web/app/pages/Dashboard/ProjectCard.tsxindex cc305223f..0e459a6ee 100644--- a/web/app/pages/Dashboard/ProjectCard.tsx+++ b/web/app/pages/Dashboard/ProjectCard.tsx@@ -20,6 +20,7 @@ import { useAuth } from '~/providers/AuthProvider'import { Badge, BadgeProps } from '~/ui/Badge'import Spin from '~/ui/icons/Spin'import Modal from '~/ui/Modal'+import { Text } from '~/ui/Text'import { nFormatter, calculateRelativePercentage } from '~/utils/generic'import routes from '~/utils/routes'@@ -47,14 +48,18 @@ const MiniCard = ({ labelTKey, total, percChange }: MiniCardProps) => {return (<div>- <p className='text-sm text-gray-500 dark:text-gray-300'>{t(labelTKey)}</p>+ <Text as='p' size='sm' colour='muted'>+ {t(labelTKey)}+ </Text><div className='flex font-bold'>{total === null ? (<Spin className='mt-2 !ml-0' />) : (<>- <p className='text-xl text-gray-700 dark:text-gray-100'>{_isNumber(total) ? nFormatter(total) : total}</p>+ <Text as='p' weight='bold' size='xl' colour='secondary'>+ {_isNumber(total) ? nFormatter(total) : total}+ </Text>{_isNumber(percChange) ? (<pclassName={cx('flex items-start text-xs', {@@ -221,7 +226,9 @@ export const ProjectCard = ({><div className={cx('flex flex-col', viewMode === 'list' ? 'flex-1' : 'px-4 py-4')}><div className={cx('flex items-center', viewMode === 'grid' ? 'justify-between' : 'justify-start gap-1')}>- <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>+ <Text as='p' size='lg' weight='semibold' truncate>+ {name}+ </Text>{project.isAccessConfirmed && role !== 'viewer' ? (<Linkdiff --git a/web/app/pages/NotFound/index.tsx b/web/app/pages/NotFound/index.tsxindex f8eeff96b..9a1730e01 100644--- a/web/app/pages/NotFound/index.tsx+++ b/web/app/pages/NotFound/index.tsx@@ -2,6 +2,7 @@ import { useTranslation } from 'react-i18next'import { Link } from 'react-router'import { isSelfhosted } from '~/lib/constants'+import { Text } from '~/ui/Text'import routes from '~/utils/routes'const CONTACT_US_URL = `https://swetrix.com${routes.contact}`@@ -13,15 +14,17 @@ const NotFound = () => {<div className='min-h-min-footer bg-gray-50 px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8 dark:bg-slate-900'><div className='mx-auto max-w-max'><main className='sm:flex'>- <p className='text-4xl font-bold text-indigo-600 sm:text-5xl dark:text-indigo-500'>404</p>+ <Text as='p' size='4xl' weight='bold' className='text-indigo-600 sm:text-5xl dark:text-indigo-500'>+ 404+ </Text><div className='sm:ml-6'><div className='sm:border-l sm:border-gray-200 sm:pl-6'>- <h1 className='text-4xl font-extrabold text-gray-900 sm:text-5xl dark:text-gray-50'>+ <Text as='h1' size='4xl' weight='bold' className='sm:text-5xl'>{t('notFoundPage.title')}- </h1>- <p className='mt-1 text-base whitespace-pre-line text-gray-500 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='muted' className='mt-1 whitespace-pre-line'>{t('notFoundPage.description')}- </p>+ </Text></div><div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'><Linkdiff --git a/web/app/pages/Organisations/NoOrganisations.tsx b/web/app/pages/Organisations/NoOrganisations.tsxindex 13c645eb8..767146db5 100644--- a/web/app/pages/Organisations/NoOrganisations.tsx+++ b/web/app/pages/Organisations/NoOrganisations.tsx@@ -1,6 +1,8 @@import { BuildingOffice2Icon } from '@heroicons/react/24/outline'import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+interface NoOrganisationsProps {onClick: () => void}@@ -9,14 +11,16 @@ export const NoOrganisations = ({ onClick }: NoOrganisationsProps) => {const { t } = useTranslation('common')return (- <div className='mx-auto w-full max-w-2xl py-16 text-center text-gray-900 dark:text-gray-50'>+ <div className='mx-auto w-full max-w-2xl py-16 text-center'><div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-800'><BuildingOffice2Icon className='size-7 text-gray-700 dark:text-gray-200' strokeWidth={1.5} /></div>- <h3 className='text-xl font-medium tracking-tight'>{t('organisations.noOrganisations')}</h3>- <p className='mx-auto mt-2 max-w-md text-sm text-gray-800 dark:text-gray-200'>+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>+ {t('organisations.noOrganisations')}+ </Text>+ <Text as='p' size='sm' colour='secondary' className='mx-auto mt-2 max-w-md'>{t('organisations.createOrganisation')}- </p>+ </Text><buttontype='button'onClick={onClick}diff --git a/web/app/pages/Organisations/OrganisationCard.tsx b/web/app/pages/Organisations/OrganisationCard.tsxindex 3ad5c1695..b0ce21ca4 100644--- a/web/app/pages/Organisations/OrganisationCard.tsx+++ b/web/app/pages/Organisations/OrganisationCard.tsx@@ -14,6 +14,7 @@ import { DetailedOrganisation } from '~/lib/models/Organisation'import { useAuth } from '~/providers/AuthProvider'import { Badge, BadgeProps } from '~/ui/Badge'import Modal from '~/ui/Modal'+import { Text } from '~/ui/Text'import routes from '~/utils/routes'interface OrganisationCardProps {@@ -126,7 +127,9 @@ export const OrganisationCard = ({ organisation, reloadOrganisations }: Organisa><div className='px-4 py-4'><div className='flex items-center justify-between'>- <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>+ <Text as='p' size='lg' weight='semibold' truncate>+ {name}+ </Text>{membership?.role === 'viewer' ? null : (// dummy button, since the whole card is clickablediff --git a/web/app/pages/Organisations/Organisations.tsx b/web/app/pages/Organisations/Organisations.tsxindex 779ffdf61..7955ede50 100644--- a/web/app/pages/Organisations/Organisations.tsx+++ b/web/app/pages/Organisations/Organisations.tsx@@ -21,6 +21,7 @@ import Input from '~/ui/Input'import Loader from '~/ui/Loader'import Modal from '~/ui/Modal'import Pagination from '~/ui/Pagination'+import { Text } from '~/ui/Text'import routes from '~/utils/routes'import { AddOrganisation } from './AddOrganisation'@@ -180,7 +181,7 @@ const Organisations = () => {<div className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8'><div className='mb-6 flex flex-wrap justify-between gap-2'><div className='flex items-end justify-between'>- <h2 className='mt-2 flex items-baseline gap-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>+ <Text as='h2' size='3xl' weight='bold' className='mt-2 flex items-baseline gap-2'><span>{t('titles.organisations')}</span>{isSearchActive ? (<button@@ -215,7 +216,7 @@ const Organisations = () => {/></button>)}- </h2>+ </Text>{isSearchActive ? (<div className='hidden w-full max-w-md items-center px-2 pb-1 sm:ml-2 sm:flex'><label htmlFor='organisation-search' className='sr-only'>@@ -340,9 +341,9 @@ const Organisations = () => {onChange={(e) => setNewOrganisationName(e.target.value)}/>{newOrganisationError ? (- <p className='mt-2 text-sm font-medium text-red-500'>+ <Text as='p' size='sm' weight='medium' colour='error' className='mt-2'>{t('apiNotifications.errorOccured', { error: newOrganisationError })}- </p>+ </Text>) : null}</div>}diff --git a/web/app/pages/Project/New/index.tsx b/web/app/pages/Project/New/index.tsxindex 4a6811456..ad561c41b 100644--- a/web/app/pages/Project/New/index.tsx+++ b/web/app/pages/Project/New/index.tsx@@ -15,6 +15,7 @@ import Button from '~/ui/Button'import Input from '~/ui/Input'import Loader from '~/ui/Loader'import Select from '~/ui/Select'+import { Text } from '~/ui/Text'import { trackCustom } from '~/utils/analytics'import routes from '~/utils/routes'@@ -141,7 +142,9 @@ const NewProject = () => {return (<div className='flex min-h-min-footer flex-col bg-gray-50 dark:bg-slate-900'><form className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8' onSubmit={handleSubmit}>- <h2 className='mt-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>{t('project.settings.create')}</h2>+ <Text as='h2' size='3xl' weight='bold' className='mt-2'>+ {t('project.settings.create')}+ </Text><Inputname='name'label={t('project.settings.name')}@@ -177,7 +180,9 @@ const NewProject = () => {</div>) : null}- <p className='mt-1 mb-4 text-sm text-gray-500 italic dark:text-gray-300'>{t('project.settings.createHint')}</p>+ <Text as='p' size='sm' colour='muted' className='mt-1 mb-4 italic'>+ {t('project.settings.createHint')}+ </Text><div><Buttondiff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsxindex f95a9b340..f84eb4672 100644--- a/web/app/pages/Project/View/Panels.tsx+++ b/web/app/pages/Project/View/Panels.tsx@@ -32,6 +32,7 @@ import Dropdown from '~/ui/Dropdown'import Sort from '~/ui/icons/Sort'import Spin from '~/ui/icons/Spin'import Modal from '~/ui/Modal'+import { Text } from '~/ui/Text'import { trackError } from '~/utils/analytics'import { nFormatter, getLocaleDisplayName } from '~/utils/generic'import countries from '~/utils/isoCountries'@@ -90,14 +91,18 @@ class ExtensionErrorBoundary extends React.Component<render() {if (this.state.hasError) {return (- <div className='text-sm text-red-500'>- <p>Something went wrong. Please try again later.</p>+ <div>+ <Text as='p' size='sm' colour='error'>+ Something went wrong. Please try again later.+ </Text><br />- <p>+ <Text as='p' size='sm' colour='error'><span>Extension ID: </span><span>{this.props?.extensionID || 'unknown'}</span>- </p>- <p>If the problem persists, please contact support.</p>+ </Text>+ <Text as='p' size='sm' colour='error'>+ If the problem persists, please contact support.+ </Text></div>)}@@ -171,10 +176,10 @@ const PanelContainer = ({)}><div className='mb-2 flex items-center justify-between gap-4'>- <h3 className='flex items-center text-lg leading-6 font-semibold whitespace-nowrap text-gray-900 dark:text-gray-50'>+ <Text as='h3' size='lg' weight='semibold' className='flex items-center leading-6 whitespace-nowrap'>{icon ? <span className='mr-1'>{icon}</span> : null}{name}- </h3>+ </Text><div className='scrollbar-thin flex items-center gap-2.5 overflow-x-auto'>{panelTabs && onTabChange ? (<>@@ -432,7 +437,11 @@ const KVTableContainer = ({ data, uniques, displayKeyAsHeader, onClick }: KVTabl}, [data, uniques])if (_isEmpty(data)) {- return <p className='mb-2 text-gray-600 dark:text-gray-200'>{t('project.noData')}</p>+ return (+ <Text as='p' size='base' colour='secondary' className='mb-2'>+ {t('project.noData')}+ </Text>+ )}return _map(processed, (value, key) => {@@ -743,21 +752,25 @@ const Metadata = ({const renderTabContent = () => {if (_isEmpty(eventsData)) {- return <p className='mt-1 text-base text-gray-700 dark:text-gray-300'>{t('project.noParamData')}</p>+ return (+ <Text as='p' size='base' colour='secondary' className='mt-1'>+ {t('project.noParamData')}+ </Text>+ )}return (<><div className='mb-1 flex items-center justify-between px-1 py-1'>- <span className='w-4/6 text-sm font-medium text-gray-600 dark:text-gray-400'>+ <Text size='sm' weight='medium' colour='muted' className='w-4/6'>{activeTabId === 'props' ? t('project.property') : t('project.event')}- </span>- <span className='w-1/6 text-right text-sm font-medium text-gray-600 dark:text-gray-400'>+ </Text>+ <Text size='sm' weight='medium' colour='muted' className='w-1/6 text-right'>{t('project.quantity')}- </span>- <span className='w-1/6 text-right text-sm font-medium text-gray-600 dark:text-gray-400'>+ </Text>+ <Text size='sm' weight='medium' colour='muted' className='w-1/6 text-right'>{t('project.conversion')}- </span>+ </Text></div><div className='space-y-0.5'>@@ -789,7 +802,9 @@ const Metadata = ({/><div className='relative z-10 flex w-4/6 min-w-0 items-center'>- <span className='flex items-center truncate text-sm text-gray-900 dark:text-gray-100'>{ev}</span>+ <Text size='sm' truncate>+ {ev}+ </Text><FilterIconclassName='ml-2 hidden h-4 w-4 shrink-0 text-gray-500 group-hover:block dark:text-gray-300'strokeWidth={1.5}@@ -797,10 +812,14 @@ const Metadata = ({<div className='ml-2 h-4 w-4 group-hover:hidden' /></div><div className='relative z-10 w-1/6 text-right'>- <span className='text-sm font-medium text-gray-900 dark:text-gray-50'>{eventsData[ev]}</span>+ <Text size='sm' weight='medium'>+ {eventsData[ev]}+ </Text></div><div className='relative z-10 w-1/6 text-right'>- <span className='text-sm font-medium text-gray-900 dark:text-gray-50'>{perc}%</span>+ <Text size='sm' weight='medium'>+ {perc}%+ </Text></div></div>)diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsxindex 88c3e5075..2b7de7aba 100644--- a/web/app/pages/Project/View/ViewProject.tsx+++ b/web/app/pages/Project/View/ViewProject.tsx@@ -149,6 +149,7 @@ import Flag from '~/ui/Flag'import Loader from '~/ui/Loader'import LoadingBar from '~/ui/LoadingBar'import Select from '~/ui/Select'+import { Text } from '~/ui/Text'import { trackCustom } from '~/utils/analytics'import { periodToCompareDate } from '~/utils/compareConvertDate'import {@@ -3445,10 +3446,10 @@ const ViewProjectContent = () => {<><div className='relative top-0 z-20 mb-2 flex flex-col items-center justify-between bg-gray-50/50 backdrop-blur-md lg:sticky lg:flex-row dark:bg-slate-900/50'><div className='flex flex-wrap items-center justify-center gap-2'>- <h2 className='text-xl font-bold break-words break-all text-gray-900 dark:text-gray-50'>+ <Text as='h2' size='xl' weight='bold' className='break-words break-all'>{/* If tab is funnels - then display a funnel name, otherwise a project name */}{activeTab === PROJECT_TABS.funnels ? activeFunnel?.name : project.name}- </h2>+ </Text>{activeTab !== PROJECT_TABS.funnels ? <LiveVisitorsDropdown /> : null}</div><div className='mx-auto mt-3 flex w-full max-w-[420px] flex-wrap items-center justify-center gap-x-2 gap-y-1 sm:mx-0 sm:w-auto sm:max-w-none sm:flex-nowrap sm:justify-between lg:mt-0'>@@ -3512,7 +3513,7 @@ const ViewProjectContent = () => {}if (item.id === 'no-views') {- return <span className='text-gray-600 dark:text-gray-200'>{item.name}</span>+ return <Text colour='secondary'>{item.name}</Text>}return (diff --git a/web/app/pages/Project/View/components/CurrentTime.tsx b/web/app/pages/Project/View/components/CurrentTime.tsxindex de046df9e..0cf593c09 100644--- a/web/app/pages/Project/View/components/CurrentTime.tsx+++ b/web/app/pages/Project/View/components/CurrentTime.tsx@@ -7,6 +7,7 @@ import { useSearchParams } from 'react-router'import { DEFAULT_TIMEZONE } from '~/lib/constants'import { useAuth } from '~/providers/AuthProvider'+import { Text } from '~/ui/Text'import Tooltip from '~/ui/Tooltip'import { useViewProjectContext } from '../ViewProject'@@ -27,16 +28,16 @@ const CurrentTime = () => {<Tooltiptext={<div className='flex flex-col'>- <span className='font-semibold'>{t('project.timezoneX', { timezone })}</span>+ <Text weight='semibold'>{t('project.timezoneX', { timezone })}</Text>{isEmbedded ? null : (- <span className='text-xs text-gray-300 dark:text-gray-400'>+ <Text size='xs' colour='muted'>{isAuthenticated ? t('project.changeInSettings') : t('project.signInToChange')}- </span>+ </Text>)}</div>}tooltipNode={- <span className='text-sm text-gray-700 dark:text-gray-50'>+ <Text size='sm' colour='secondary'><Transi18nKey='project.currentTimeX'values={{@@ -58,7 +59,7 @@ const CurrentTime = () => {),}}/>- </span>+ </Text>}/></div>diff --git a/web/app/pages/Project/View/components/Errors.tsx b/web/app/pages/Project/View/components/Errors.tsxindex cc5b33cc5..94a7122f6 100644--- a/web/app/pages/Project/View/components/Errors.tsx+++ b/web/app/pages/Project/View/components/Errors.tsx@@ -9,6 +9,7 @@ import { ClientOnly } from 'remix-utils/client-only'import { SwetrixError } from '~/lib/models/Project'import { Badge } from '~/ui/Badge'import Loader from '~/ui/Loader'+import { Text } from '~/ui/Text'import { getRelativeDateIfPossible } from '~/utils/date'interface ErrorsProps {@@ -70,17 +71,23 @@ const ErrorItem = ({ error }: ErrorItemProps) => {<li className='relative mb-3 flex cursor-pointer justify-between gap-x-6 overflow-hidden rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 transition-colors hover:bg-gray-200/70 sm:px-6 dark:border-slate-800/25 dark:bg-slate-800/70 dark:hover:bg-slate-700/60'><div className='flex min-w-0 gap-x-4'><div className='min-w-0 flex-auto'>- <p className='flex items-center gap-x-2 leading-6 font-semibold text-gray-900 dark:text-gray-50'>- <span className='pb-0.5 text-sm font-bold'>{error.name}</span>+ <p className='flex items-center gap-x-2 leading-6 font-semibold'>+ <Text size='sm' weight='bold' className='pb-0.5'>+ {error.name}+ </Text>{error.filename ? (<><Separator className='self-center' />- <span className='mx-1 text-xs font-normal break-all text-gray-500'>{error.filename}</span>+ <Text size='xs' weight='normal' colour='muted' className='mx-1 break-all'>+ {error.filename}+ </Text></>) : null}</p>{error.message ? (- <p className='mt-1 flex text-sm leading-5 text-gray-500 dark:text-gray-300'>{error.message}</p>+ <Text as='p' size='sm' colour='muted' className='mt-1 flex leading-5'>+ {error.message}+ </Text>) : null}<p className='mt-1 flex items-center gap-x-2 text-sm leading-5 text-gray-500 dark:text-gray-300'><Badge className='mr-2 sm:hidden' label={status.label} colour={status.colour} />@@ -96,11 +103,11 @@ const ErrorItem = ({ error }: ErrorItemProps) => {</div><div className='flex shrink-0 items-center gap-x-4'><div className='hidden sm:flex sm:flex-col sm:items-end'>- <p className='text-sm leading-6 text-gray-900 dark:text-gray-50'>+ <Text as='p' size='sm' className='leading-6'>{t('dashboard.xOccurrences', {x: error.count,})}- </p>+ </Text><Badge label={status.label} colour={status.colour} /></div><ChevronRightIcon className='h-5 w-5 flex-none text-gray-400' aria-hidden='true' />diff --git a/web/app/pages/Project/View/components/FunnelsList.tsx b/web/app/pages/Project/View/components/FunnelsList.tsxindex 6e1ec575d..42eb5c091 100644--- a/web/app/pages/Project/View/components/FunnelsList.tsx+++ b/web/app/pages/Project/View/components/FunnelsList.tsx@@ -7,6 +7,7 @@ import { Link, useSearchParams } from 'react-router'import { Funnel } from '~/lib/models/Project'import { useAuth } from '~/providers/AuthProvider'+import { Text } from '~/ui/Text'interface FunnelsListProps {funnels?: any[]@@ -47,7 +48,9 @@ const FunnelCard = ({ funnel, openFunnelSettings, deleteFunnel, loading, allowed><div className='px-4 py-4'><div className='flex items-center justify-between'>- <p className='truncate text-base font-semibold text-slate-900 dark:text-gray-50'>{funnel.name}</p>+ <Text as='p' size='base' weight='semibold' truncate>+ {funnel.name}+ </Text><div className='flex items-center gap-1'><buttontype='button'@@ -104,9 +107,9 @@ const AddFunnel = ({ openFunnelSettings }: AddFunnelProps) => {className='mx-auto h-12 w-12 text-gray-400 transition-colors group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400'strokeWidth={1}/>- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>+ <Text as='span' size='sm' weight='semibold' className='mt-2 block group-hover:dark:text-gray-400'>{t('dashboard.newFunnel')}- </span>+ </Text></div></li>)diff --git a/web/app/pages/Project/View/components/MetricCards.tsx b/web/app/pages/Project/View/components/MetricCards.tsxindex 9c91ef232..64b41d6b2 100644--- a/web/app/pages/Project/View/components/MetricCards.tsx+++ b/web/app/pages/Project/View/components/MetricCards.tsx@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next'import { OverallObject, OverallPerformanceObject } from '~/lib/models/Project'import { Badge } from '~/ui/Badge'import OutsideClickHandler from '~/ui/OutsideClickHandler'+import { Text } from '~/ui/Text'import { nFormatter, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'interface MetricCardProps {@@ -72,19 +73,21 @@ export const MetricCard: React.FC<MetricCardProps> = ({classes,}) => (<div className={cx('flex flex-col', classes?.container)}>- <div className={cx('text-4xl font-bold whitespace-nowrap text-slate-900 dark:text-gray-50', classes?.value)}>+ <Text size='4xl' weight='bold' className={cx('whitespace-nowrap', classes?.value)}>{valueMapper ? valueMapper(value, 'main') : value}- </div>+ </Text><divclassName={cx(- 'flex items-center text-sm font-bold whitespace-nowrap',+ 'flex items-center whitespace-nowrap',{'space-x-2': _isNumber(change),},classes?.label,)}>- <span className='text-slate-900 dark:text-gray-50'>{label}</span>+ <Text size='sm' weight='bold'>+ {label}+ </Text><ChangeBadge change={change} type={type} goodChangeDirection={goodChangeDirection} valueMapper={valueMapper} /></div></div>@@ -115,26 +118,25 @@ export const MetricCardSelect = ({ values, valueMapper, selectLabel, classes }:return (<div className={cx('flex flex-col', classes?.container)}>- <div className={cx('text-4xl font-bold whitespace-nowrap text-slate-900 dark:text-gray-50', classes?.value)}>+ <Text size='4xl' weight='bold' className={cx('whitespace-nowrap', classes?.value)}>{valueMapper ? valueMapper(values[selected], selected) : values[selected].value}- </div>- <div className='relative flex items-center text-sm font-bold whitespace-nowrap'>+ </Text>+ <div className='relative flex items-center whitespace-nowrap'><OutsideClickHandler onOutsideClick={() => setShow(false)}>- <span- className={cx('cursor-pointer text-slate-900 dark:text-gray-50', classes?.label)}- onClick={() => setShow(!show)}- >- {values[selected].label}{' '}- <ChevronDownIcon- className={cx(- 'inline h-4 w-4 transform transition-transform duration-200',- show ? 'rotate-180' : 'rotate-0',- )}- />+ <span className={cx('cursor-pointer', classes?.label)} onClick={() => setShow(!show)}>+ <Text size='sm' weight='bold'>+ {values[selected].label}{' '}+ <ChevronDownIcon+ className={cx(+ 'inline h-4 w-4 transform transition-transform duration-200',+ show ? 'rotate-180' : 'rotate-0',+ )}+ />+ </Text></span><divclassName={cx(- 'absolute top-4 z-10 mt-2 min-w-[250px] origin-top transform cursor-auto overflow-hidden rounded-md border border-black/10 bg-white break-words whitespace-normal text-gray-900 shadow-lg transition-all duration-200 ease-out dark:border-slate-700/50 dark:bg-slate-900',+ 'absolute top-4 z-10 mt-2 min-w-[250px] origin-top transform cursor-auto overflow-hidden rounded-md border border-black/10 bg-white whitespace-normal shadow-lg transition-all duration-200 ease-out dark:border-slate-700/50 dark:bg-slate-900',show? 'pointer-events-auto translate-y-0 scale-100 opacity-100': 'pointer-events-none -translate-y-1 scale-95 opacity-0',@@ -142,7 +144,9 @@ export const MetricCardSelect = ({ values, valueMapper, selectLabel, classes }:><div className='flex w-full flex-col'><div className='flex items-center justify-between border-b border-black/10 bg-white p-2 dark:border-slate-700/50 dark:bg-slate-900'>- <p className='text-sm font-semibold text-gray-900 dark:text-gray-50'>{selectLabel}</p>+ <Text as='p' size='sm' weight='semibold'>+ {selectLabel}+ </Text><buttonclassName='-m-1 rounded-md p-1 hover:bg-gray-200 dark:hover:bg-slate-700'type='button'@@ -157,9 +161,11 @@ export const MetricCardSelect = ({ values, valueMapper, selectLabel, classes }:type='button'key={label}onClick={() => _onSelect(index)}- className='w-full rounded-md p-2 text-left text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700'+ className='w-full rounded-md p-2 text-left hover:bg-gray-200 dark:hover:bg-slate-700'>- {label}+ <Text size='sm' colour='secondary'>+ {label}+ </Text></button>))}</div>diff --git a/web/app/pages/Project/View/components/NoErrorDetails.tsx b/web/app/pages/Project/View/components/NoErrorDetails.tsxindex c80071a6f..e383d2eac 100644--- a/web/app/pages/Project/View/components/NoErrorDetails.tsx+++ b/web/app/pages/Project/View/components/NoErrorDetails.tsx@@ -1,6 +1,8 @@import { BugIcon } from 'lucide-react'import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+const NoErrorDetails = () => {const { t } = useTranslation('common')@@ -11,12 +13,12 @@ const NoErrorDetails = () => {<BugIcon className='mb-2 -ml-1.5 h-12 w-12 sm:m-0 sm:h-20 sm:w-20' /><div className='sm:ml-6'><div className='sm:border-l sm:border-gray-200 sm:pl-6'>- <h1 className='text-4xl font-extrabold text-gray-900 sm:text-5xl dark:text-gray-50'>+ <Text as='h1' size='4xl' weight='bold' className='sm:text-5xl'>{t('project.noErrorDetails')}- </h1>- <p className='mt-1 max-w-prose text-base whitespace-pre-line text-gray-700 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='secondary' className='mt-1 max-w-prose whitespace-pre-line'>{t('project.noErrorDesc')}- </p>+ </Text></div></div></main>diff --git a/web/app/pages/Project/View/components/NoEvents.tsx b/web/app/pages/Project/View/components/NoEvents.tsxindex 33ced945a..df7653fa2 100644--- a/web/app/pages/Project/View/components/NoEvents.tsx+++ b/web/app/pages/Project/View/components/NoEvents.tsx@@ -2,6 +2,8 @@ import _isEmpty from 'lodash/isEmpty'import { memo } from 'react'import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+import { Filter } from '../interfaces/traffic'import { typeNameMapping } from '../ViewProject.helpers'@@ -18,9 +20,13 @@ const NoEvents = ({ filters }: NoEventsProps) => {if (_isEmpty(filters)) {return (<div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>- <h2 className='my-3 text-center text-4xl leading-tight font-semibold'>{t('project.noEvTitle')}</h2>- <h3 className='mb-8 text-center text-2xl leading-snug'>{t('project.noEvContent')}</h3>+ <div className='mx-auto w-full max-w-7xl'>+ <Text as='h2' size='4xl' weight='semibold' className='my-3 text-center leading-tight'>+ {t('project.noEvTitle')}+ </Text>+ <Text as='h3' size='2xl' className='mb-8 text-center leading-snug'>+ {t('project.noEvContent')}+ </Text></div></div>)@@ -32,9 +38,13 @@ const NoEvents = ({ filters }: NoEventsProps) => {<Filters tnMapping={tnMapping} /></div><div className='mt-5 flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>- <h2 className='my-3 text-center text-4xl leading-tight font-semibold'>{t('project.noEvTitle')}</h2>- <h3 className='mb-8 text-center text-2xl leading-snug'>{t('project.noEventsFiltersDesc')}</h3>+ <div className='mx-auto w-full max-w-7xl'>+ <Text as='h2' size='4xl' weight='semibold' className='my-3 text-center leading-tight'>+ {t('project.noEvTitle')}+ </Text>+ <Text as='h3' size='2xl' className='mb-8 text-center leading-snug'>+ {t('project.noEventsFiltersDesc')}+ </Text></div></div></>diff --git a/web/app/pages/Project/View/components/NoSessionDetails.tsx b/web/app/pages/Project/View/components/NoSessionDetails.tsxindex 9c6938dae..d3832f240 100644--- a/web/app/pages/Project/View/components/NoSessionDetails.tsx+++ b/web/app/pages/Project/View/components/NoSessionDetails.tsx@@ -1,6 +1,8 @@import { FaceFrownIcon } from '@heroicons/react/24/outline'import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+const NoSessionDetails = () => {const { t } = useTranslation('common')@@ -11,12 +13,12 @@ const NoSessionDetails = () => {<FaceFrownIcon type='giant' className='mb-2 -ml-1.5 h-12 w-12 sm:m-0 sm:h-20 sm:w-20' /><div className='sm:ml-6'><div className='sm:border-l sm:border-gray-200 sm:pl-6'>- <h1 className='text-4xl font-extrabold text-gray-900 sm:text-5xl dark:text-gray-50'>+ <Text as='h1' size='4xl' weight='bold' className='sm:text-5xl'>{t('project.noSessionDetails')}- </h1>- <p className='mt-1 max-w-prose text-base whitespace-pre-line text-gray-700 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='secondary' className='mt-1 max-w-prose whitespace-pre-line'>{t('project.noSessionDesc')}- </p>+ </Text></div></div></main>diff --git a/web/app/pages/Project/View/components/ProjectSidebar.tsx b/web/app/pages/Project/View/components/ProjectSidebar.tsxindex 2cef9d715..3754adbf0 100644--- a/web/app/pages/Project/View/components/ProjectSidebar.tsx+++ b/web/app/pages/Project/View/components/ProjectSidebar.tsx@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next'import { Link, LinkProps } from 'react-router'import { PROJECT_TABS } from '~/lib/constants'+import { Text } from '~/ui/Text'import Tooltip from '~/ui/Tooltip'import routes from '~/utils/routes'@@ -233,7 +234,9 @@ const ProjectSidebar: React.FC<ProjectSidebarProps> = ({<Tooltiptext={projectName}tooltipNode={- <p className='max-w-full truncate text-sm font-medium text-gray-900 dark:text-gray-50'>{projectName}</p>+ <Text as='p' size='sm' weight='medium' truncate className='max-w-full'>+ {projectName}+ </Text>}/></div>diff --git a/web/app/pages/Project/View/components/WaitingForAnEvent.tsx b/web/app/pages/Project/View/components/WaitingForAnEvent.tsxindex 847329f10..a28332a53 100644--- a/web/app/pages/Project/View/components/WaitingForAnEvent.tsx+++ b/web/app/pages/Project/View/components/WaitingForAnEvent.tsx@@ -4,6 +4,7 @@ import { Link } from 'react-router'import TrackingSnippet from '~/modals/TrackingSnippet'import PulsatingCircle from '~/ui/icons/PulsatingCircle'+import { Text } from '~/ui/Text'import routes from '~/utils/routes'const TROUBLESHOOTING_URL = 'https://docs.swetrix.com/troubleshooting'@@ -13,12 +14,14 @@ const WaitingForAnEvent = () => {const [isModalOpened, setIsModalOpened] = useState(false)return (- <div className='mx-auto w-full max-w-2xl py-16 text-center text-gray-900 dark:text-gray-50'>+ <div className='mx-auto w-full max-w-2xl py-16 text-center'><div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-800'><PulsatingCircle type='giant' /></div>- <h3 className='text-xl font-medium tracking-tight'>{t('project.waiting.title')}</h3>- <p className='mx-auto mt-2 max-w-md text-sm whitespace-pre-line text-gray-800 dark:text-gray-200'>+ <Text as='h3' size='xl' weight='medium' className='tracking-tight'>+ {t('project.waiting.title')}+ </Text>+ <Text as='p' size='sm' colour='secondary' className='mx-auto mt-2 max-w-md whitespace-pre-line'><Transt={t}i18nKey='project.waiting.desc'@@ -44,7 +47,7 @@ const WaitingForAnEvent = () => {),}}/>- </p>+ </Text><TrackingSnippet isOpened={isModalOpened} onClose={() => setIsModalOpened(false)} /></div>)diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsxindex 107b88caf..d4830f980 100644--- a/web/app/pages/UserSettings/UserSettings.tsx+++ b/web/app/pages/UserSettings/UserSettings.tsx@@ -38,6 +38,7 @@ import Modal from '~/ui/Modal'import Select from '~/ui/Select'import Textarea from '~/ui/Textarea'import TimezonePicker from '~/ui/TimezonePicker'+import { Text } from '~/ui/Text'import { trackCustom } from '~/utils/analytics'import { getCookie, setCookie } from '~/utils/cookie'import routes from '~/utils/routes'@@ -381,9 +382,9 @@ const UserSettings = () => {const SharedProjects = () => (<><hr className='mt-5 border-gray-200 dark:border-gray-600' />- <h3 className='mt-2 flex items-center text-lg font-bold text-gray-900 dark:text-gray-50'>+ <Text as='h3' size='lg' weight='bold' className='mt-2 flex items-center'>{t('profileSettings.shared')}- </h3>+ </Text><div>{!_isEmpty(user?.sharedProjects) ? (<div className='mt-3 overflow-hidden rounded-lg border border-gray-200 dark:border-slate-700'>@@ -428,7 +429,9 @@ const UserSettings = () => {return (<div className='flex min-h-min-footer flex-col bg-gray-50 dark:bg-slate-900'><form className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8' onSubmit={handleSubmit}>- <h2 className='mt-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>{t('titles.profileSettings')}</h2>+ <Text as='h2' size='3xl' weight='bold' className='mt-2'>+ {t('titles.profileSettings')}+ </Text><hr className='mt-5 border-gray-200 dark:border-gray-600' /><div className='mt-6 flex flex-col gap-6 md:flex-row'><div className='md:hidden'>diff --git a/web/app/pages/UserSettings/components/NoOrganisations.tsx b/web/app/pages/UserSettings/components/NoOrganisations.tsxindex 0a12edcdb..726b4f29e 100644--- a/web/app/pages/UserSettings/components/NoOrganisations.tsx+++ b/web/app/pages/UserSettings/components/NoOrganisations.tsx@@ -1,12 +1,16 @@import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+const NoOrganisations = () => {const { t } = useTranslation('common')return (<div className='flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>- <h2 className='mb-4 text-center text-2xl leading-snug'>{t('profileSettings.noOrganisations')}</h2>+ <div className='mx-auto w-full max-w-7xl'>+ <Text as='h2' size='2xl' className='mb-4 text-center leading-snug'>+ {t('profileSettings.noOrganisations')}+ </Text></div></div>)diff --git a/web/app/pages/UserSettings/components/NoSharedProjects.tsx b/web/app/pages/UserSettings/components/NoSharedProjects.tsxindex b86bba0f7..296e7ccd3 100644--- a/web/app/pages/UserSettings/components/NoSharedProjects.tsx+++ b/web/app/pages/UserSettings/components/NoSharedProjects.tsx@@ -1,12 +1,16 @@import { useTranslation } from 'react-i18next'+import { Text } from '~/ui/Text'+const NoSharedProjects = () => {const { t } = useTranslation('common')return (<div className='flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>- <h2 className='mb-4 text-center text-2xl leading-snug'>{t('profileSettings.noSharedProjects')}</h2>+ <div className='mx-auto w-full max-w-7xl'>+ <Text as='h2' size='2xl' className='mb-4 text-center leading-snug'>+ {t('profileSettings.noSharedProjects')}+ </Text></div></div>)diff --git a/web/app/ui/Text.tsx b/web/app/ui/Text.tsxnew file mode 100644index 000000000..31826a575--- /dev/null+++ b/web/app/ui/Text.tsx@@ -0,0 +1,66 @@+import React from 'react'++import { cn } from '~/utils/generic'++type TextElement = 'span' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label' | 'div'+type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl'+type TextWeight = 'light' | 'normal' | 'medium' | 'semibold' | 'bold'+type TextColour = 'primary' | 'secondary' | 'muted' | 'success' | 'warning' | 'error' | 'inherit'++export interface TextProps {+ children: React.ReactNode+ as?: TextElement+ size?: TextSize+ weight?: TextWeight+ colour?: TextColour+ truncate?: boolean+ className?: string+ [key: string]: unknown+}++const sizeClasses: Record<TextSize, string> = {+ xs: 'text-xs',+ sm: 'text-sm',+ base: 'text-base',+ lg: 'text-lg',+ xl: 'text-xl',+ '2xl': 'text-2xl',+ '3xl': 'text-3xl',+ '4xl': 'text-4xl',+}++const weightClasses: Record<TextWeight, string> = {+ light: 'font-light',+ normal: 'font-normal',+ medium: 'font-medium',+ semibold: 'font-semibold',+ bold: 'font-bold',+}++const colourClasses: Record<TextColour, string> = {+ primary: 'text-gray-900 dark:text-gray-50',+ secondary: 'text-gray-700 dark:text-gray-200',+ muted: 'text-gray-500 dark:text-gray-400',+ success: 'text-green-600 dark:text-green-400',+ warning: 'text-yellow-600 dark:text-yellow-500',+ error: 'text-red-600 dark:text-red-400',+ inherit: '',+}++export const Text = ({+ children,+ as: Component = 'span',+ size = 'base',+ weight = 'normal',+ colour = 'primary',+ truncate,+ className,+ ...props+}: TextProps) => (+ <Component+ className={cn(sizeClasses[size], weightClasses[weight], colourClasses[colour], { truncate }, className)}+ {...props}+ >+ {children}+ </Component>+)