forked from Uniswap/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and add gif to prettier ignore
- Loading branch information
Showing
4 changed files
with
76 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
**/.hg | ||
*.mdx | ||
*.md | ||
*.hbs | ||
*.hbs | ||
*.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react' | ||
import { Sentiment } from '.' | ||
import { TraceEvent } from '@uniswap/analytics' | ||
import { BrowserEvent, DocsSentiment, DocsSentimentSection, SharedEventName } from '@uniswap/analytics-events' | ||
import cn from 'classnames' | ||
|
||
interface SentimentButtonProps { | ||
sentiment: Sentiment | ||
icon: React.ReactNode | ||
selected: boolean | ||
onSelect: (sentiment: Sentiment) => void | ||
analyticsSection: DocsSentimentSection | ||
} | ||
|
||
const SentimentButton: React.FC<SentimentButtonProps> = ({ sentiment, icon, selected, onSelect, analyticsSection }) => { | ||
const sentimentMap: Record<Sentiment, DocsSentiment> = { | ||
[Sentiment.POSITIVE]: DocsSentiment.POSITIVE_SENTIMENT, | ||
[Sentiment.NEUTRAL]: DocsSentiment.NEUTRAL_SENTIMENT, | ||
[Sentiment.NEGATIVE]: DocsSentiment.NEGATIVE_SENTIMENT, | ||
} | ||
|
||
const handleClick = () => onSelect(sentiment) | ||
|
||
return ( | ||
<TraceEvent | ||
element={sentimentMap[sentiment]} | ||
name={SharedEventName.SENTIMENT_SUBMITTED} | ||
events={[BrowserEvent.onClick]} | ||
section={analyticsSection} | ||
> | ||
<button | ||
onClick={handleClick} | ||
className={cn(`group/${sentiment.toLowerCase()}`, { selected })} | ||
aria-label={`Rate as ${sentiment.toLowerCase()}`} | ||
> | ||
{icon} | ||
</button> | ||
</TraceEvent> | ||
) | ||
} | ||
|
||
export default SentimentButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters