📈 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
remove Pin and replace it with Badge component
Blue Mousebf1882f60e8f
diff --git a/app/pages/Dashboard/Dashboard.tsx b/app/pages/Dashboard/Dashboard.tsxindex 80846e927..f3e83f4ff 100644--- a/app/pages/Dashboard/Dashboard.tsx+++ b/app/pages/Dashboard/Dashboard.tsx@@ -25,9 +25,7 @@ import Modal from 'ui/Modal'import Select from 'ui/Select'import { withAuthentication, auth } from 'hoc/protected'import Loader from 'ui/Loader'-import {- ActivePin, InactivePin, WarningPin, CustomPin,-} from 'ui/Pin'+import { Badge } from 'ui/Badge'import routes from 'routesPath'import { nFormatter } from 'utils/generic'import {@@ -206,36 +204,53 @@ const ProjectCard = ({</a></div></div>- <div className='mt-1 flex-shrink-0 flex gap-2'>+ <div className='mt-1 flex-shrink-0 flex gap-2 flex-wrap'>{active ? (- <ActivePin label={t('dashboard.active')} />+ <Badge+ colour='green'+ label={t('dashboard.active')}+ />) : (- <InactivePin label={t('dashboard.disabled')} />+ <Badge+ colour='red'+ label={t('dashboard.disabled')}+ />)}{shared && (confirmed ? (- <ActivePin label={t('dashboard.shared')} />+ <Badge+ colour='green'+ label={t('dashboard.shared')}+ />) : (- <WarningPin label={t('common.pending')} />+ <Badge+ colour='yellow'+ label={t('common.pending')}+ />))}{isTransferring && (- <CustomPin- className='!bg-indigo-500 dark:!bg-indigo-600 !text-gray-50'+ <Badge+ colour='indigo'label={t('common.transferring')}/>)}{isPublic && (- <ActivePin label={t('dashboard.public')} />+ <Badge+ colour='green'+ label={t('dashboard.public')}+ />+ )}+ {_isNumber(members) && (+ <Badge+ colour='slate'+ label={members === 1+ ? t('common.oneMember')+ : t('common.xMembers', {+ number: members,+ })}+ />)}- <CustomPin- className='bg-slate-200 dark:bg-slate-600 text-gray-800 dark:text-gray-300'- label={members === 1- ? t('common.oneMember')- : t('common.xMembers', {- number: members,- })}- /></div><div className='mt-4 flex-shrink-0 flex gap-5'>{overall && (@@ -688,7 +703,6 @@ const Dashboard = ({return (<ProjectCardt={t}- members={1 + _size(project.share)}key={`${project?.id}-confirmed`}type='analytics'id={project?.id}diff --git a/app/pages/Project/Settings/Emails/Emails.tsx b/app/pages/Project/Settings/Emails/Emails.tsxindex d172c352a..474393c2e 100644--- a/app/pages/Project/Settings/Emails/Emails.tsx+++ b/app/pages/Project/Settings/Emails/Emails.tsx@@ -27,7 +27,7 @@ import Modal from 'ui/Modal'import Loader from 'ui/Loader'import Beta from 'ui/Beta'import cx from 'clsx'-import { WarningPin } from 'ui/Pin'+import { Badge } from 'ui/Badge'import { ISubscribers } from 'redux/models/ISubscribers'const ModalMessage = ({@@ -212,9 +212,10 @@ const EmailList = ({</div>) : (<div className='flex items-center justify-end'>- <WarningPin+ <Badge+ colour='yellow'+ className='mr-3'label={t('common.pending')}- className='inline-flex items-center shadow-sm px-2.5 py-0.5 mr-3'/><Buttontype='button'diff --git a/app/pages/Project/Settings/People/People.tsx b/app/pages/Project/Settings/People/People.tsxindex 97efb6602..9f6fd17bf 100644--- a/app/pages/Project/Settings/People/People.tsx+++ b/app/pages/Project/Settings/People/People.tsx@@ -13,7 +13,7 @@ import _map from 'lodash/map'import { deleteShareProjectUsers, shareProject, changeShareRole } from 'api'import { isValidEmail } from 'utils/validator'import Input from 'ui/Input'-import { WarningPin } from 'ui/Pin'+import { Badge } from 'ui/Badge'import Button from 'ui/Button'import Modal from 'ui/Modal'import PaidFeature from 'modals/PaidFeature'@@ -132,9 +132,10 @@ const UsersList = ({</div>) : (<div className='flex items-center justify-end'>- <WarningPin+ <Badge+ colour='yellow'+ className='mr-3'label={t('common.pending')}- className='inline-flex items-center shadow-sm px-2.5 py-0.5 mr-3'/><Buttontype='button'diff --git a/app/ui/Badge.tsx b/app/ui/Badge.tsxnew file mode 100644index 000000000..3a35c0144--- /dev/null+++ b/app/ui/Badge.tsx@@ -0,0 +1,26 @@+import React from 'react'+import cx from 'clsx'++interface IBadge {+ label: string,+ className?: string,+ colour?: 'red' | 'yellow' | 'green' | 'indigo' | 'slate',+}++const Badge = ({ label, className, colour }: IBadge): JSX.Element => (+ <span+ className={cx('inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset', className, {+ 'ring-slate-500/10 text-slate-600 bg-slate-50 dark:bg-slate-400/10 dark:text-slate-400 dark:ring-slate-400/20': colour === 'slate',+ 'bg-indigo-50 text-indigo-700 ring-indigo-700/10 dark:bg-indigo-400/10 dark:text-indigo-400 dark:ring-indigo-400/30': colour === 'indigo',+ 'bg-yellow-50 text-yellow-800 ring-yellow-600/20 dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20': colour === 'yellow',+ 'bg-green-50 text-green-700 ring-green-600/20 dark:bg-green-500/10 dark:text-green-400 dark:ring-green-500/20': colour === 'green',+ 'bg-red-50 text-red-700 ring-red-600/10 dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20': colour === 'red',+ })}+ >+ {label}+ </span>+)++export {+ Badge,+}diff --git a/app/ui/Beta.tsx b/app/ui/Beta.tsxindex 6a0c956d4..d40f2cc74 100644--- a/app/ui/Beta.tsx+++ b/app/ui/Beta.tsx@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'import { useTranslation } from 'react-i18next'import Tooltip from './Tooltip'-import { WarningPin } from './Pin'+import { Badge } from './Badge'// Define the prop types for the componentinterface IBeta {@@ -20,7 +20,7 @@ const Beta = ({<TooltipclassName='max-w-content !w-full'tooltipNode={(- <WarningPin className={className} label={t('beta.title')} />+ <Badge className={className} label={t('beta.title')} colour='yellow' />)}text={t('beta.description')}/>diff --git a/app/ui/Pin.tsx b/app/ui/Pin.tsxdeleted file mode 100644index 90f8d83e6..000000000--- a/app/ui/Pin.tsx+++ /dev/null@@ -1,60 +0,0 @@-import React from 'react'-import cx from 'clsx'-import PropTypes from 'prop-types'--interface IPin {- label: string,- className?: string,-}--const ActivePin = ({ label, className }: IPin): JSX.Element => (- <p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-md bg-green-100 text-green-800 dark:text-gray-300 dark:bg-slate-600', className)}>- {label}- </p>-)--const InactivePin = ({ label, className }: IPin): JSX.Element => (- <p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-md bg-red-100 text-red-800 dark:text-gray-300 dark:bg-slate-600', className)}>- {label}- </p>-)--const WarningPin = ({ label, className }: IPin): JSX.Element => (- <p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-md bg-yellow-200 text-yellow-800 dark:text-gray-300 dark:bg-slate-600', className)}>- {label}- </p>-)--const CustomPin = ({ label, className }: IPin): JSX.Element => (- <p className={cx('px-2 inline-flex text-sm leading-5 font-normal rounded-md', className)}>- {label}- </p>-)--const propTypes = {- label: PropTypes.string.isRequired,- className: PropTypes.string,-}--const defaultProps = {- className: '',-}--ActivePin.propTypes = propTypes-ActivePin.defaultProps = defaultProps--WarningPin.propTypes = propTypes-WarningPin.defaultProps = defaultProps--InactivePin.propTypes = propTypes-InactivePin.defaultProps = defaultProps--CustomPin.propTypes = propTypes-CustomPin.defaultProps = defaultProps--export {- ActivePin,- InactivePin,- WarningPin,- CustomPin,-}diff --git a/app/ui/__test__/Pin.test.tsx b/app/ui/__test__/Pin.test.tsxdeleted file mode 100644index 0bca08e9b..000000000--- a/app/ui/__test__/Pin.test.tsx+++ /dev/null@@ -1,43 +0,0 @@-/* eslint-disable testing-library/prefer-screen-queries */-/* eslint-disable import/no-extraneous-dependencies */-import React from 'react'-import { render } from '@testing-library/react'-import '@testing-library/jest-dom'-import {- WarningPin, ActivePin, InactivePin, CustomPin,-} from '../Pin'--describe('Pin', () => {- const defaultProps: {- label: string,- className?: string,- } = {- label: 'label',- className: 'className',- }-- it('renders the warning pin', () => {- const { getByText } = render(<WarningPin {...defaultProps} />)- expect(getByText('label')).toBeInTheDocument()- })-- it('renders the active pin', () => {- const { getByText } = render(<ActivePin {...defaultProps} />)- expect(getByText('label')).toBeInTheDocument()- })-- it('renders the inactive pin', () => {- const { getByText } = render(<InactivePin {...defaultProps} />)- expect(getByText('label')).toBeInTheDocument()- })-- it('renders the custom pin', () => {- const { getByText } = render(<CustomPin {...defaultProps} />)- expect(getByText('label')).toBeInTheDocument()- })-- it('renders the custom pin with custom className', () => {- const { getByText } = render(<CustomPin {...defaultProps} className='customClassName' />)- expect(getByText('label')).toBeInTheDocument()- })-})