From d956cda20a92f368bed1ded701d7de4d238e62dd Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Wed, 5 Aug 2020 01:00:56 -0700 Subject: [PATCH] Show locked squeak with icon (#226) * Show lock icon when squeak thread item is locekd * Squeak thread item locked display now looks good * Show squeak detail item differently when locked --- .../SqueakDetailItem/SqueakDetailItem.js | 56 ++++++++++++++--- .../SqueakThreadItem/SqueakThreadItem.js | 62 ++++++++++++++----- 2 files changed, 95 insertions(+), 23 deletions(-) diff --git a/frontend/squeak-node-frontend/src/components/SqueakDetailItem/SqueakDetailItem.js b/frontend/squeak-node-frontend/src/components/SqueakDetailItem/SqueakDetailItem.js index 7b30e22d..5ccf34c1 100644 --- a/frontend/squeak-node-frontend/src/components/SqueakDetailItem/SqueakDetailItem.js +++ b/frontend/squeak-node-frontend/src/components/SqueakDetailItem/SqueakDetailItem.js @@ -14,6 +14,8 @@ import { MoreVert as MoreIcon } from "@material-ui/icons"; import {useHistory} from "react-router-dom"; import classnames from "classnames"; +import LockIcon from '@material-ui/icons/Lock'; + import ReplyIcon from '@material-ui/icons/Reply'; import RepeatIcon from '@material-ui/icons/Repeat'; import FavoriteIcon from '@material-ui/icons/Favorite'; @@ -65,11 +67,54 @@ export default function SqueakDetailItem({ } } + function SqueakUnlockedContent() { + return ( + {squeak.getContentStr()} + + ) + } + + function SqueakLockedContent() { + return ( + <> + + + ) + } + + function SqueakContent() { + return ( + <> + {squeak.getIsUnlocked() + ? SqueakUnlockedContent() + : SqueakLockedContent() + } + + ) + } + + function SqueakLockedBackgroundColor() { + return {backgroundColor: 'lightgray'}; + } + + function SqueakUnlockedBackgroundColor() { + return {backgroundColor: 'white'}; + } + + function SqueakBackgroundColor() { + return squeak.getIsUnlocked() + ? SqueakUnlockedBackgroundColor() + : SqueakLockedBackgroundColor() + } + return ( - {squeak.getIsUnlocked() - ? squeak.getContentStr() - : "Content is locked." - } - + {SqueakContent()} { @@ -49,11 +47,54 @@ export default function SqueakThreadItem({ } } + function SqueakUnlockedContent() { + return ( + {squeak.getContentStr()} + + ) + } + + function SqueakLockedContent() { + return ( + <> + + + ) + } + + function SqueakContent() { + return ( + <> + {squeak.getIsUnlocked() + ? SqueakUnlockedContent() + : SqueakLockedContent() + } + + ) + } + + function SqueakLockedBackgroundColor() { + return {backgroundColor: 'lightgray'}; + } + + function SqueakUnlockedBackgroundColor() { + return {backgroundColor: 'white'}; + } + + function SqueakBackgroundColor() { + return squeak.getIsUnlocked() + ? SqueakUnlockedBackgroundColor() + : SqueakLockedBackgroundColor() + } + return ( - {squeak.getIsUnlocked() - ? squeak.getContentStr() - : "Content is locked." - } - + {SqueakContent()} - + {new Date(squeak.getBlockTime()*1000).toString()} (Block # {squeak.getBlockHeight()})