Skip to content

Commit

Permalink
app: Swap in react-use
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Dec 28, 2020
1 parent 2d8d2b3 commit cbccb98
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"react-select": "^3.1.0",
"react-test-renderer": "^16.8.6",
"react-textarea-autosize": "^8.2.0",
"react-use": "^15.3.4",
"regenerator-runtime": "^0.13.5",
"semver": "^7.3.2",
"serializr": "^2.0.3",
Expand All @@ -152,7 +153,6 @@
"terser-webpack-plugin": "^4.1.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.2",
"use-onclickoutside": "^0.3.1",
"webpack": "^4.44.1",
"webpack-merge": "^4.2.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/overlay/overlays/nowPlaying/ColorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as React from 'react';
import {ChromePicker, ColorResult} from 'react-color';
import {X} from 'react-feather';
import {usePopper} from 'react-popper';
import {useClickAway} from 'react-use';
import styled from '@emotion/styled';
import {AnimatePresence, motion} from 'framer-motion';
import {set} from 'mobx';
import {observer} from 'mobx-react';
import useOnClickOutside from 'use-onclickoutside';

import {NowPlayingConfig} from '.';

Expand Down Expand Up @@ -57,7 +57,7 @@ const Color = ({color, defaultColor, name, trimPrefix, onChange}: ColorProps) =>
modifiers: [{name: 'arrow'}, {name: 'offset', options: {offset: [0, 15]}}],
});

useOnClickOutside(containerRef, () => openPicker(false));
useClickAway(containerRef, () => openPicker(false));

return (
<div ref={containerRef}>
Expand Down
14 changes: 3 additions & 11 deletions src/renderer/components/ConnectingSplash.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import * as React from 'react';
import {useTimeout} from 'react-use';
import {keyframes} from '@emotion/core';
import styled from '@emotion/styled';
import {motion} from 'framer-motion';

const useTimeout = (timeout: number) => {
const [isExpired, setExpired] = React.useState(false);
React.useEffect(() => {
window.setTimeout(() => setExpired(true), timeout);
}, []);

return isExpired;
};

const ConnectingSplash = () => {
const showHelp = useTimeout(10000);
const [showHelp] = useTimeout(10000);

return (
<Container>
<Text layout transition={{duration: 0.2}}>
<Indicator />
Waiting for PROLINK devices
</Text>
{showHelp && (
{showHelp() && (
<Help initial={{y: 20, opacity: 0}} animate={{y: 0, opacity: 1}}>
Not seeing your CDJs? Ensure they are <strong>ON</strong> and connected to the{' '}
<strong>same network</strong> as this computer. If they are simply linked to one
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/components/HelpButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import {HelpCircle} from 'react-feather';
import {useClickAway} from 'react-use';
import styled from '@emotion/styled';
import {AnimatePresence, motion} from 'framer-motion';

Expand All @@ -9,6 +10,9 @@ import ActionButton from './ActionButton';

const HelpButton = () => {
const [show, toggle] = React.useState(false);
const containerRef = React.useRef<HTMLDivElement>(null);

useClickAway(containerRef, () => toggle(false));

return (
<React.Fragment>
Expand All @@ -17,8 +21,8 @@ const HelpButton = () => {
</Button>
<AnimatePresence>
{show && (
<Modal onClick={e => e.currentTarget === e.target && toggle(false)}>
<Info>
<Modal>
<Info ref={containerRef}>
<LogoBig />
<p>
Built by a DJ, for DJs. prolink tools is a hand-built collection of tools
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/overlayConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const OverlayConfig = observer(() => {
<a href="https://obsproject.com/wiki/Sources-Guide#browsersource">
OBS Browser Source
</a>{' '}
(or similar). Each instance of an overlay has it&aps;s own configuration.
(or similar). Each instance of an overlay has it&apos;s own configuration.
</HeaderInfo>
{addNewOpen ? (
<ActionButton muted onClick={() => setOpen(!addNewOpen)}>
Expand Down
Loading

0 comments on commit cbccb98

Please sign in to comment.