Lint fix.

This commit is contained in:
Mike Cao 2022-01-14 19:10:46 -08:00
parent 6bfaa4d40c
commit 2f18aa29eb
3 changed files with 75 additions and 57 deletions

View File

@ -4,19 +4,22 @@ import classNames from 'classnames';
import Head from 'next/head'; import Head from 'next/head';
import Link from 'next/link'; import Link from 'next/link';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import Page from '../layout/Page'; import Page from 'components/layout/Page';
import PageHeader from '../layout/PageHeader'; import PageHeader from 'components/layout/PageHeader';
import useFetch from '../../hooks/useFetch'; import DropDown from 'components/common/DropDown';
import DropDown from '../common/DropDown'; import WebsiteChart from 'components/metrics/WebsiteChart';
import EventsChart from 'components/metrics/EventsChart';
import Button from 'components/common/Button';
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
import Icon from 'components/common/Icon';
import useFetch from 'hooks/useFetch';
import ChevronDown from 'assets/chevron-down.svg';
import styles from './TestConsole.module.css'; import styles from './TestConsole.module.css';
import WebsiteChart from '../metrics/WebsiteChart';
import EventsChart from '../metrics/EventsChart';
import Button from '../common/Button';
import EmptyPlaceholder from '../common/EmptyPlaceholder';
export default function TestConsole() { export default function TestConsole() {
const user = useSelector(state => state.user); const user = useSelector(state => state.user);
const [website, setWebsite] = useState(); const [website, setWebsite] = useState();
const [show, setShow] = useState(true);
const { basePath } = useRouter(); const { basePath } = useRouter();
const { data } = useFetch('/api/websites'); const { data } = useFetch('/api/websites');
@ -55,6 +58,14 @@ export default function TestConsole() {
{!selectedValue && <EmptyPlaceholder msg="I hope you know what you're doing here" />} {!selectedValue && <EmptyPlaceholder msg="I hope you know what you're doing here" />}
{selectedValue && ( {selectedValue && (
<> <>
<div>
<Icon
icon={<ChevronDown />}
className={classNames({ [styles.hidden]: !show })}
onClick={() => setShow(!show)}
/>
</div>
{show && (
<div className={classNames(styles.test, 'row')}> <div className={classNames(styles.test, 'row')}>
<div className="col-4"> <div className="col-4">
<PageHeader>Page links</PageHeader> <PageHeader>Page links</PageHeader>
@ -71,7 +82,11 @@ export default function TestConsole() {
</div> </div>
<div className="col-4"> <div className="col-4">
<PageHeader>CSS events</PageHeader> <PageHeader>CSS events</PageHeader>
<Button id="primary-button" className="umami--click--primary-button" variant="action"> <Button
id="primary-button"
className="umami--click--primary-button"
variant="action"
>
Send event Send event
</Button> </Button>
</div> </div>
@ -82,6 +97,7 @@ export default function TestConsole() {
</Button> </Button>
</div> </div>
</div> </div>
)}
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<WebsiteChart <WebsiteChart

View File

@ -3,3 +3,7 @@
border-radius: 5px; border-radius: 5px;
padding: 0 20px 20px 20px; padding: 0 20px 20px 20px;
} }
.hidden {
transform: rotate(-90deg);
}

View File

@ -108,7 +108,13 @@ import { removeTrailingSlash } from '../lib/url';
/* Handle events */ /* Handle events */
const addEvents = node => {
const elements = node.querySelectorAll(eventSelect);
Array.prototype.forEach.call(elements, addEvent);
};
const addEvent = element => { const addEvent = element => {
element.className &&
element.className.split(' ').forEach(className => { element.className.split(' ').forEach(className => {
if (!eventClass.test(className)) return; if (!eventClass.test(className)) return;
@ -125,8 +131,7 @@ import { removeTrailingSlash } from '../lib/url';
mutations.forEach(mutation => { mutations.forEach(mutation => {
const element = mutation.target; const element = mutation.target;
addEvent(element); addEvent(element);
const elements = element.querySelectorAll(eventSelect); addEvents(element);
Array.prototype.forEach.call(elements, addEvent);
}); });
}; };
@ -166,19 +171,12 @@ import { removeTrailingSlash } from '../lib/url';
history.replaceState = hook(history, 'replaceState', handlePush); history.replaceState = hook(history, 'replaceState', handlePush);
const update = () => { const update = () => {
switch (document.readyState) { if (document.readyState === 'complete') {
/* DOM rendered, add event listeners */ addEvents(document);
case 'interactive': { trackView();
const events = document.querySelectorAll(eventSelect);
Array.prototype.forEach.call(events, addEvent);
const observer = new MutationObserver(monitorMutate); const observer = new MutationObserver(monitorMutate);
observer.observe(document, { childList: true, subtree: true }); observer.observe(document, { childList: true, subtree: true });
break;
}
/* Page loaded, track our view */
case 'complete':
trackView();
break;
} }
}; };
document.addEventListener('readystatechange', update, true); document.addEventListener('readystatechange', update, true);