Skip to content

Commit

Permalink
perf(app-board): remove arrow and inline objects
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Jan 28, 2021
1 parent 1ad8936 commit 419f97a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';
import { ExpandIcon, PanelContent, PanelContentWrapper, PanelHeader, PanelWrapper } from './ExpandableTopPanel.styled';
import Typography from '../Typography';

Expand All @@ -21,8 +21,12 @@ type Props = {
const ExpandableTopPanel: React.FC<Props> = ({ className, label, children }) => {
const [collapsed, setCollapsed] = useState(true);

const toggle = useCallback(() => {
setCollapsed(c => !c);
}, []);

return (
<PanelWrapper className={className} onClick={() => setCollapsed(c => !c)}>
<PanelWrapper className={className} onClick={toggle}>
<PanelHeader>
<Typography variant="content" fontWeight="600">
{label}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import { useTranslate } from '@pipeline/i18n';
import { Box, IconButton, Typography, Dialog, Button, Input } from '@pipeline/components';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -26,9 +26,11 @@ const ShareGameDialog: React.FC<Props> = ({ isOpen, close }) => {

const game: GameEntity | null = useSelector(selectors.getGame);

if (!game) return null;
const url = `${window.location.origin}/game/${game?.id}`;

const url = `${window.location.origin}/game/${game.id}`;
const copyUrl = useCallback(() => {
copy(url);
}, [url]);

return (
<Dialog open={isOpen} title={t('game.share.title')}>
Expand All @@ -37,7 +39,7 @@ const ShareGameDialog: React.FC<Props> = ({ isOpen, close }) => {
</Typography>
<Box display="flex" flexDirection="row" mt={4}>
<Input flex={1} readOnly variant="clear" color="activeAccentLight" value={url} />
<IconButton variant="clear" onClick={() => copy(url)}>
<IconButton variant="clear" onClick={copyUrl}>
<CopyIcon />
</IconButton>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { Box, Button, Dialog, Typography } from '@pipeline/components';
import { useTranslate } from '@pipeline/i18n';
import { TriggerDialogContainer } from './TriggerReviewDialog.styled';
Expand All @@ -22,12 +22,16 @@ const TriggerReviewDialog: React.FC<Props> = ({ isOpen, close }) => {
setShowReviewPosition(true);
}, [dispatch]);

const containerProps = useMemo(() => {
return { showReviewPosition };
}, [showReviewPosition]);

return (
<Dialog
open={isOpen}
title={t(!showReviewPosition ? 'game.triggerReview.title' : 'game.triggerReview.reviewTime')}
DialogContainerComponent={TriggerDialogContainer}
DialogContainerProps={{ showReviewPosition }}
DialogContainerProps={containerProps}
>
<Typography mt={4} variant="content">
{t(!showReviewPosition ? 'game.triggerReview.subtitle' : 'game.triggerReview.reviewUnlocked')}
Expand Down

0 comments on commit 419f97a

Please sign in to comment.