-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from Jaewoook/feat/developer-contact
feat: feedback popover
- Loading branch information
Showing
13 changed files
with
130 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"noEmit": false, | ||
"outDir": "./build/background", | ||
"isolatedModules": false | ||
}, | ||
"include": [ | ||
"background/*" | ||
] | ||
} |
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,6 @@ | ||
module.exports = { | ||
extends: "../.eslintrc.js", | ||
parserOptions: { | ||
project: "./background.tsconfig.json", | ||
}, | ||
}; |
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 @@ | ||
console.log("background test"); |
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
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,4 @@ | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
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
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
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,75 @@ | ||
/* eslint-disable jsx-a11y/accessible-emoji */ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { Button, Input, Popover, Typography } from "antd"; | ||
import axios from "axios"; | ||
|
||
const EMAIL_API = "https://api.jaewook.me/email/addr-extension-feedback"; | ||
|
||
const PopoverTitleWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
`; | ||
|
||
const PopoverTitle = (props: { children: React.ReactNode; }) => { | ||
return <PopoverTitleWrapper>{props.children}</PopoverTitleWrapper>; | ||
}; | ||
|
||
const FeedbackSenderWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
> button.ant-btn { | ||
margin-top: 8px; | ||
width: 100%; | ||
} | ||
`; | ||
|
||
const PopoverContentStyle = { | ||
width: "270px", | ||
}; | ||
|
||
const FeedbackForm = () => { | ||
const [message, setMessage] = React.useState(""); | ||
const [sending, setSending] = React.useState(false); | ||
const [sent, setSent] = React.useState(false); | ||
|
||
const handleSendClick = React.useCallback(async () => { | ||
if (sent) { | ||
return; | ||
} | ||
setSending(true); | ||
try { | ||
await axios.post(EMAIL_API, { feedbackContent: message }); | ||
setSent(true); | ||
} catch (err) { | ||
console.error(err); | ||
} finally { | ||
setSending(false); | ||
} | ||
}, [message, sent, setSent, setSending]); | ||
return <FeedbackSenderWrapper> | ||
<Input.TextArea disabled={sent || sending} | ||
value={message} | ||
rows={3} | ||
placeholder="이곳에 피드백 내용을 입력해주세요. 작성해주신 소중한 피드백이 더 좋은 주소검색을 만들어요!" | ||
onChange={(ev) => setMessage(ev.target.value)} /> | ||
<Button disabled={sent || sending} type="primary" onClick={handleSendClick}> | ||
{!sent ? "보내기 🎉" : "피드백 전달 완료! 💛"} | ||
</Button> | ||
</FeedbackSenderWrapper>; | ||
}; | ||
|
||
export const FeedbackPopover = () => { | ||
return ( | ||
<Popover | ||
placement="top" | ||
overlayStyle={PopoverContentStyle} | ||
title={<PopoverTitle>피드백 보내기</PopoverTitle>} | ||
content={<FeedbackForm />} | ||
> | ||
<Typography.Text keyboard>피드백 보내기</Typography.Text> | ||
</Popover> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ interface Window { | |
__ENV__: { | ||
NODE_ENV: string; | ||
}; | ||
ga: any; | ||
} |