From 057bb0f10afdbac9f013e478ae2a0911a0a90ad2 Mon Sep 17 00:00:00 2001 From: keyan Date: Thu, 29 Apr 2021 13:43:17 -0500 Subject: [PATCH] localstorage price as sats --- components/comment.js | 2 +- components/comment.module.css | 9 +++++++-- components/price.js | 25 +++++++++++++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/components/comment.js b/components/comment.js index 7d6b925b..0c16446a 100644 --- a/components/comment.js +++ b/components/comment.js @@ -80,7 +80,7 @@ export default function Comment ({ item, children, replyOpen, includeParent, cac {reply ? 'cancel' : 'reply'} } {reply && -
+
setReply(replyOpen || false)} cacheId={cacheId} />
} {children} diff --git a/components/comment.module.css b/components/comment.module.css index e279ae41..de4700ee 100644 --- a/components/comment.module.css +++ b/components/comment.module.css @@ -8,7 +8,7 @@ .text { margin-top: .1rem; - padding-right: .75rem; + padding-right: 15px; } .reply { @@ -17,6 +17,11 @@ padding-bottom: .5rem; } +.replyWrapper { + padding-right: 15px; + padding-bottom: .5rem; +} + .children { margin-top: .25rem; } @@ -32,7 +37,7 @@ .skeleton .text { height: 80px; border-radius: .4rem; - margin-right: .75rem; + margin-right: 15px; } .skeleton .reply { diff --git a/components/price.js b/components/price.js index 28f177d3..b6748793 100644 --- a/components/price.js +++ b/components/price.js @@ -1,11 +1,14 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { Button } from 'react-bootstrap' import useSWR from 'swr' const fetcher = url => fetch(url).then(res => res.json()) export default function Price () { - const [asSats, setAsSats] = useState(false) + const [asSats, setAsSats] = useState(undefined) + useEffect(() => { + setAsSats(localStorage.getItem('asSats')) + }, []) const { data } = useSWR( 'https://api.coinbase.com/v2/prices/BTC-USD/spot', @@ -16,19 +19,29 @@ export default function Price () { if (!data) return null - const fixed = n => Number.parseFloat(n).toFixed(2) - const handleClick = () => setAsSats(!asSats) + const fixed = (n, f) => Number.parseFloat(n).toFixed(f) + const handleClick = () => { + if (asSats) { + localStorage.removeItem('asSats') + setAsSats(undefined) + } else { + localStorage.setItem('asSats', 'yep') + setAsSats('yep') + } + } + if (asSats) { + console.log(asSats, 'as sats') return ( ) } return ( ) }