From e6a2c1adcf578ab4c573cd1176a77e39e0473df5 Mon Sep 17 00:00:00 2001 From: nahbee10 Date: Fri, 15 Nov 2024 11:17:31 -0500 Subject: [PATCH] refactor and add gif to prettier ignore --- .prettierignore | 3 +- src/components/Icons/index.tsx | 16 ++-- .../SentimentTracking/SentimentButton.tsx | 42 ++++++++++ src/components/SentimentTracking/index.tsx | 82 ++++++------------- 4 files changed, 76 insertions(+), 67 deletions(-) create mode 100644 src/components/SentimentTracking/SentimentButton.tsx diff --git a/.prettierignore b/.prettierignore index 3e1358bbc..af1f7c669 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,4 +7,5 @@ **/.hg *.mdx *.md -*.hbs \ No newline at end of file +*.hbs +*.gif \ No newline at end of file diff --git a/src/components/Icons/index.tsx b/src/components/Icons/index.tsx index 22d0842bf..3730b48a2 100644 --- a/src/components/Icons/index.tsx +++ b/src/components/Icons/index.tsx @@ -218,7 +218,7 @@ export const Happy: FC<{ cy="10" r="9" className={cn({ - 'stroke-light-neutral-2 dark:stroke-dark-neutral-2 group-hover/happy:stroke-light-neutral-1 group-hover/happy:dark:stroke-dark-neutral-1 group-[.selected]/happy:fill-light-status-success-1 group-[.selected]/happy:dark:fill-dark-status-success-1 group-[.selected]/happy:stroke-light-neutral-1 group-[.selected]/happy:dark:stroke-dark-neutral-1': + 'stroke-light-neutral-2 dark:stroke-dark-neutral-2 group-hover/positive:stroke-light-neutral-1 group-hover/positive:dark:stroke-dark-neutral-1 group-[.selected]/positive:fill-light-status-success-1 group-[.selected]/positive:dark:fill-dark-status-success-1 group-[.selected]/positive:stroke-light-neutral-1 group-[.selected]/positive:dark:stroke-dark-neutral-1': color === 'neutral-2', })} strokeWidth="2" @@ -228,7 +228,7 @@ export const Happy: FC<{ cy="8" r="1" className={cn({ - 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/happy:fill-light-neutral-1 group-hover/happy:dark:fill-dark-neutral-1 group-[.selected]/happy:fill-light-neutral-1 group-[.selected]/happy:dark:fill-dark-neutral-1': + 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/positive:fill-light-neutral-1 group-hover/positive:dark:fill-dark-neutral-1 group-[.selected]/positive:fill-light-neutral-1 group-[.selected]/positive:dark:fill-dark-neutral-1': color === 'neutral-2', })} /> @@ -237,14 +237,14 @@ export const Happy: FC<{ cy="8" r="1" className={cn({ - 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/happy:fill-light-neutral-1 group-hover/happy:dark:fill-dark-neutral-1 group-[.selected]/happy:fill-light-neutral-1 group-[.selected]/happy:dark:fill-dark-neutral-1': + 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/positive:fill-light-neutral-1 group-hover/positive:dark:fill-dark-neutral-1 group-[.selected]/positive:fill-light-neutral-1 group-[.selected]/positive:dark:fill-dark-neutral-1': color === 'neutral-2', })} /> @@ -331,14 +331,14 @@ export const Sad: FC<{ cy="8" r="1" className={cn({ - 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/sad:fill-light-neutral-1 group-hover/sad:dark:fill-dark-neutral-1 group-[.selected]/sad:fill-light-neutral-1 group-[.selected]/sad:dark:fill-dark-neutral-1': + 'fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/negative:fill-light-neutral-1 group-hover/negative:dark:fill-dark-neutral-1 group-[.selected]/negative:fill-light-neutral-1 group-[.selected]/negative:dark:fill-dark-neutral-1': color === 'neutral-2', })} /> void + analyticsSection: DocsSentimentSection +} + +const SentimentButton: React.FC = ({ sentiment, icon, selected, onSelect, analyticsSection }) => { + const sentimentMap: Record = { + [Sentiment.POSITIVE]: DocsSentiment.POSITIVE_SENTIMENT, + [Sentiment.NEUTRAL]: DocsSentiment.NEUTRAL_SENTIMENT, + [Sentiment.NEGATIVE]: DocsSentiment.NEGATIVE_SENTIMENT, + } + + const handleClick = () => onSelect(sentiment) + + return ( + + + + ) +} + +export default SentimentButton diff --git a/src/components/SentimentTracking/index.tsx b/src/components/SentimentTracking/index.tsx index 84b4f5d62..675882828 100644 --- a/src/components/SentimentTracking/index.tsx +++ b/src/components/SentimentTracking/index.tsx @@ -1,10 +1,9 @@ -import { TraceEvent } from '@uniswap/analytics' -import { BrowserEvent, DocsSentiment, DocsSentimentSection, SharedEventName } from '@uniswap/analytics-events' +import { DocsSentimentSection } from '@uniswap/analytics-events' import React, { useCallback, useState } from 'react' import { Happy, Sad, Neutral } from '../Icons' -import cn from 'classnames' +import SentimentButton from './SentimentButton' -enum Sentiment { +export enum Sentiment { NEGATIVE = 'NEGATIVE', NEUTRAL = 'NEUTRAL', POSITIVE = 'POSITIVE', @@ -22,60 +21,27 @@ export default function SentimentTracking({ analyticsSection }: { analyticsSecti
Was this helpful?
- - - - - - - - - + } + selected={isSentimentSelected(Sentiment.POSITIVE)} + onSelect={setSelectedSentiment} + analyticsSection={analyticsSection} + /> + } + selected={isSentimentSelected(Sentiment.NEUTRAL)} + onSelect={setSelectedSentiment} + analyticsSection={analyticsSection} + /> + } + selected={isSentimentSelected(Sentiment.NEGATIVE)} + onSelect={setSelectedSentiment} + analyticsSection={analyticsSection} + />
)