Reaction Button Styling
This commit is contained in:
parent
11cba5caf0
commit
1bdc48f5c9
3 changed files with 30 additions and 19 deletions
|
|
@ -8,23 +8,23 @@ export default function Reaction({ slug }: { slug: string }) {
|
|||
const [haveReacted, setHaveReacted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let browserId = localStorage.getItem(BROWSER_ID)
|
||||
let browserId = localStorage.getItem(BROWSER_ID)
|
||||
|
||||
if (!browserId) {
|
||||
browserId = uuidv7()
|
||||
localStorage.setItem(BROWSER_ID, browserId)
|
||||
}
|
||||
if (!browserId) {
|
||||
browserId = uuidv7()
|
||||
localStorage.setItem(BROWSER_ID, browserId)
|
||||
}
|
||||
|
||||
api.haveIReacted({ ...reaction, browser_id: browserId }).then((response: boolean) => {
|
||||
setHaveReacted(response)
|
||||
})
|
||||
api.haveIReacted({ ...reaction, browser_id: browserId }).then((response: boolean) => {
|
||||
setHaveReacted(response)
|
||||
})
|
||||
|
||||
api.reactionCount(slug).then((count) => {
|
||||
setReactionCount(count)
|
||||
})
|
||||
api.reactionCount(slug).then((count) => {
|
||||
setReactionCount(count)
|
||||
})
|
||||
|
||||
setReaction(prev => ({ ...prev, browser_id: browserId }))
|
||||
}, [])
|
||||
setReaction(prev => ({ ...prev, browser_id: browserId }))
|
||||
}, [])
|
||||
|
||||
const handleReaction = () => {
|
||||
let hasError = false
|
||||
|
|
@ -51,8 +51,17 @@ export default function Reaction({ slug }: { slug: string }) {
|
|||
|
||||
|
||||
return (
|
||||
<button onClick={handleReaction}>
|
||||
{haveReacted ? "♥" : "🧭"} {reactionCount}
|
||||
<button onClick={handleReaction}
|
||||
|
||||
style="
|
||||
font-size: 1rem;
|
||||
width: 100%;
|
||||
padding:8px;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
">
|
||||
|
||||
|
||||
{haveReacted ? "♥ Yeah!" : "Hattest du Spaß beim Lesen?"} {reactionCount}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
|
@ -30,12 +30,14 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
<h3 id="subtitle">{postData.subtitle}</h3>
|
||||
<span id="introduction">{postData.introduction}</span>
|
||||
</div>
|
||||
<Reaction slug={postData.slug} client:load />
|
||||
<div id="hr-knast">
|
||||
<hr />
|
||||
</div>
|
||||
<article class="markdown-content">
|
||||
<slot />
|
||||
<div id="react">
|
||||
<Reaction slug={postData.slug} client:load />
|
||||
</div>
|
||||
<NavBack client:load />
|
||||
<p class="disclaimer">
|
||||
Disclaimer: Dieser Artikel ist ausschließlich privat und wird nicht
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ body {
|
|||
font-weight: bolder;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
padding: 12px 12px 12px 0;
|
||||
padding: 48px 12px 12px 0;
|
||||
}
|
||||
|
||||
.back-btn:hover {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue