From f07ca8a76ab054f6e0f8cd5efac42237ca16cfa5 Mon Sep 17 00:00:00 2001 From: Robin Andeer Date: Tue, 18 Jul 2023 10:09:00 +0200 Subject: [PATCH] Refactor styling of debug dialog (#2802) ## Describe your changes ![Screenshot 2023-07-18 at 09.38.27.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/OgXegTwxM9IeuXHZyw5h/857b4981-56a0-45af-9515-2b894e265a8e/Screenshot%202023-07-18%20at%2009.38.27.png) - Update styling for debug dialog elements ## Justify why they are needed - I wanted it go along with input fields - The button height doesn't match input fields so they look a little strange ## Checklist before requesting a review - [ ] I have performed a self-review of my code --- .../components/CartPage/PageDebugDialog.tsx | 13 ++--- .../DebugDialog/CopyToClipboard.tsx | 51 +++++++++---------- .../components/DebugDialog/DebugDialog.tsx | 3 +- .../DebugDialog/DebugResumeSessionSection.tsx | 6 +-- .../DebugDialog/DebugShopSessionSection.tsx | 31 +++-------- .../ProductPage/PageDebugDialog.tsx | 13 ++--- 6 files changed, 39 insertions(+), 78 deletions(-) diff --git a/apps/store/src/components/CartPage/PageDebugDialog.tsx b/apps/store/src/components/CartPage/PageDebugDialog.tsx index 35a9e731b1..554fd6bec9 100644 --- a/apps/store/src/components/CartPage/PageDebugDialog.tsx +++ b/apps/store/src/components/CartPage/PageDebugDialog.tsx @@ -1,7 +1,7 @@ 'use client' import { useMemo } from 'react' -import { Space, Text } from 'ui' +import { Space } from 'ui' import { CopyToClipboard } from '@/components/DebugDialog/CopyToClipboard' import { DebugDialog } from '@/components/DebugDialog/DebugDialog' import { DebugShopSessionSection } from '@/components/DebugDialog/DebugShopSessionSection' @@ -12,7 +12,7 @@ import { PageLink } from '@/utils/PageLink' export const PageDebugDialog = () => { return ( - + @@ -33,12 +33,5 @@ const LinkToCartSection = () => { }) }, [shopSession, routingLocale]) - return ( - - - Share link to cart - - {cartLink ?? ''} - - ) + return {cartLink ?? ''} } diff --git a/apps/store/src/components/DebugDialog/CopyToClipboard.tsx b/apps/store/src/components/DebugDialog/CopyToClipboard.tsx index f4c03b22eb..4fc6b921a3 100644 --- a/apps/store/src/components/DebugDialog/CopyToClipboard.tsx +++ b/apps/store/src/components/DebugDialog/CopyToClipboard.tsx @@ -2,15 +2,17 @@ import styled from '@emotion/styled' import { useEffect, useState } from 'react' -import { CheckIcon, Text, theme } from 'ui' -import { SpaceFlex } from '@/components/SpaceFlex/SpaceFlex' +import { Text, theme } from 'ui' +import { useHighlightAnimation } from '@/utils/useHighlightAnimation' -export const CopyToClipboard = (props: { children: string }) => { +export const CopyToClipboard = (props: { label: string; children: string }) => { + const { highlight, animationProps } = useHighlightAnimation() const [copied, setCopied] = useState(false) const copy = () => { navigator.clipboard.writeText(props.children) setCopied(true) + highlight() } useEffect(() => { @@ -24,38 +26,34 @@ export const CopyToClipboard = (props: { children: string }) => { }, [copied]) return ( - - + + + {props.label} + + + {props.children} - - {copied ? ( - - - Copied - - ) : ( - 'Copy' - )} - ) } -const CopyToClipboardWrapper = styled.div({ +const CopyToClipboardWrapper = styled.button({ display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', - gap: theme.space.lg, + flexDirection: 'column', + justifyContent: 'center', + height: '3.25rem', + width: '100%', - backgroundColor: theme.colors.gray100, - paddingInline: theme.space.xs, - borderRadius: theme.radius.xs, - height: '2.5rem', + borderRadius: theme.radius.sm, + backgroundColor: theme.colors.translucent1, + paddingInline: theme.space.md, '@media (hover: hover)': { + cursor: 'pointer', + '&:hover': { - backgroundColor: theme.colors.gray200, + backgroundColor: theme.colors.translucent2, }, }, }) @@ -66,7 +64,4 @@ const Elipsis = styled(Text)({ whiteSpace: 'nowrap', }) -const CopyToClipboardButton = styled.button({ - cursor: 'pointer', - flexShrink: 0, -}) +const SlimText = styled(Text)({ lineHeight: 1 }) diff --git a/apps/store/src/components/DebugDialog/DebugDialog.tsx b/apps/store/src/components/DebugDialog/DebugDialog.tsx index 49e3df758b..3498aee959 100644 --- a/apps/store/src/components/DebugDialog/DebugDialog.tsx +++ b/apps/store/src/components/DebugDialog/DebugDialog.tsx @@ -36,8 +36,7 @@ const DialogContent = styled(Dialog.Content)({ }) const DialogWindow = styled(Dialog.Window)({ - padding: theme.space.lg, - paddingTop: theme.space.md, + padding: theme.space.md, borderBottomRightRadius: theme.radius.sm, borderBottomLeftRadius: theme.radius.sm, maxWidth: `calc(100% - ${theme.space.xs} * 2)`, diff --git a/apps/store/src/components/DebugDialog/DebugResumeSessionSection.tsx b/apps/store/src/components/DebugDialog/DebugResumeSessionSection.tsx index f6c9e36d99..bcbdfbc0f5 100644 --- a/apps/store/src/components/DebugDialog/DebugResumeSessionSection.tsx +++ b/apps/store/src/components/DebugDialog/DebugResumeSessionSection.tsx @@ -38,7 +38,7 @@ export const DebugResumeSessionSection = () => { - @@ -47,7 +47,7 @@ export const DebugResumeSessionSection = () => { const Layout = styled.form({ display: 'grid', - gridTemplateColumns: '4fr 1fr', + gridTemplateColumns: '4fr minmax(8rem, 1fr)', alignItems: 'center', - gap: theme.space.xs, + gap: theme.space.xxs, }) diff --git a/apps/store/src/components/DebugDialog/DebugShopSessionSection.tsx b/apps/store/src/components/DebugDialog/DebugShopSessionSection.tsx index 915509735d..6f6bd0d50c 100644 --- a/apps/store/src/components/DebugDialog/DebugShopSessionSection.tsx +++ b/apps/store/src/components/DebugDialog/DebugShopSessionSection.tsx @@ -1,6 +1,5 @@ -import styled from '@emotion/styled' import { useRouter } from 'next/router' -import { Button, Space, Text, theme } from 'ui' +import { Button, Space } from 'ui' import { useShopSession } from '@/services/shopSession/ShopSessionContext' import { PageLink } from '@/utils/PageLink' import { CopyToClipboard } from './CopyToClipboard' @@ -15,32 +14,14 @@ export const DebugShopSessionSection = () => { const nextUrl = `/${router.locale}${router.pathname}` return ( - - - - - Shop Session - - {shopSession.id} - + + {shopSession.id} - - + ) } - -const Layout = styled.div({ - display: 'grid', - gridTemplateColumns: '4fr 1fr', - alignItems: 'flex-end', - gap: theme.space.xs, -}) diff --git a/apps/store/src/components/ProductPage/PageDebugDialog.tsx b/apps/store/src/components/ProductPage/PageDebugDialog.tsx index 37b45be73d..1f44e29889 100644 --- a/apps/store/src/components/ProductPage/PageDebugDialog.tsx +++ b/apps/store/src/components/ProductPage/PageDebugDialog.tsx @@ -1,7 +1,7 @@ 'use client' import { useMemo } from 'react' -import { Space, Text } from 'ui' +import { Space } from 'ui' import { CopyToClipboard } from '@/components/DebugDialog/CopyToClipboard' import { DebugDialog } from '@/components/DebugDialog/DebugDialog' import { DebugShopSessionSection } from '@/components/DebugDialog/DebugShopSessionSection' @@ -13,7 +13,7 @@ import { usePriceIntent } from './PriceIntentContext' export const PageDebugDialog = () => { return ( - + @@ -36,12 +36,5 @@ const LinkToOfferSection = () => { }) }, [routingLocale, shopSession, priceIntent]) - return ( - - - Share link to offer - - {link ?? ''} - - ) + return {link ?? ''} }