diff --git a/src/components/BoardStats.jsx b/src/components/BoardStats.jsx index 5f1adc98..504b4791 100644 --- a/src/components/BoardStats.jsx +++ b/src/components/BoardStats.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import { useSubplebbitStats } from "@plebbit/plebbit-react-hooks/dist"; import { BoardStatsContainer } from "./styled/BoardStats.styled"; import { Break } from "./styled/views/Board.styled"; @@ -8,29 +8,45 @@ import useGeneralStore from '../hooks/stores/useGeneralStore'; const BoardStats = ({ subplebbitAddress }) => { const { selectedStyle } = useGeneralStore(state => state); const stats = useSubplebbitStats({subplebbitAddress}); + const [showStats, setShowStats] = useState(true); + + const handleToggleStats = () => { + setShowStats(!showStats); + }; return ( - + - - - - - - - - - - - - - - - - - - -
In the past hour: {stats.hourActiveUserCount} users, {stats.hourPostCount} posts.  Past day: {stats.dayActiveUserCount} users, {stats.dayPostCount} posts.
Past week: {stats.weekActiveUserCount} users, {stats.weekPostCount} posts.  Past month: {stats.monthActiveUserCount} users, {stats.monthPostCount} posts.
Since inception: {stats.allActiveUserCount} users browsed; {stats.allPostCount} posts made.
+ + {showStats && ( + + + + + + + + + + + + + + + + )} + + + + + +
Since this board was created, {stats.allActiveUserCount} users made {stats.allPostCount} posts in it.
In the past month, {stats.monthActiveUserCount} users made {stats.monthPostCount} posts.  In the past week, {stats.weekActiveUserCount} users made {stats.weekPostCount} posts.
In the past day, {stats.dayActiveUserCount} users made {stats.dayPostCount} posts.  In the past hour, {stats.hourActiveUserCount} users made {stats.hourPostCount} posts.
+ [ + + {showStats ? 'Hide Stats' : 'Show Stats'} + + ] +
); }; diff --git a/src/components/styled/BoardStats.styled.jsx b/src/components/styled/BoardStats.styled.jsx index c1e2aecc..f47f2baa 100644 --- a/src/components/styled/BoardStats.styled.jsx +++ b/src/components/styled/BoardStats.styled.jsx @@ -8,10 +8,10 @@ export const BoardStatsContainer = styled.div` @media (min-width: 480px) { width: 468px; margin: auto; + line-height: 1; table { border-spacing: 0px; - text-align: center; width: 100%; } @@ -20,4 +20,79 @@ export const BoardStatsContainer = styled.div` font-size: 11px; } } + + tfoot { + text-align: right; + } + + .hide-button:hover { + cursor: pointer; + } + + ${({ selectedStyle }) => { + switch (selectedStyle) { + case 'Yotsuba': + return ` + #stat-number { + color: #00e; + } + + .hide-button:hover { + color: red !important; + }`; + + case 'Yotsuba-B': + return ` + #stat-number { + color: #34345c; + } + + .hide-button:hover { + color: #d00 !important; + }`; + + case 'Futaba': + return ` + #stat-number { + color: #00e; + } + + .hide-button:hover { + color: red !important; + }`; + + case 'Burichan': + return ` + #stat-number { + color: #34345c; + } + + .hide-button:hover { + color: red !important; + }`; + + case 'Tomorrow': + return ` + #stat-number { + color: #81a2be; + } + + .hide-button:hover { + color: #5f89ab !important; + }`; + + case 'Photon': + return ` + #stat-number { + color: #f60; + } + + .hide-button:hover { + color: #ff3300 !important; + }`; + + default: + return ''; + } + }} `; \ No newline at end of file