diff --git a/.flowconfig b/.flowconfig index 9e73c0bd0..2c6b8839f 100644 --- a/.flowconfig +++ b/.flowconfig @@ -41,5 +41,14 @@ module.name_mapper='^web\/component\(.*\)$' -> '/web/component\1' module.name_mapper='^web\/effects\(.*\)$' -> '/web/effects\1' module.name_mapper='^web\/page\(.*\)$' -> '/web/page\1' module.name_mapper='^homepage\(.*\)$' -> '/ui/util/homepage\1' +module.name_mapper='^scss\/component\(.*\)$' -> '/ui/scss/component/\1' + +; Extensions +module.file_ext=.js +module.file_ext=.jsx +module.file_ext=.json +module.file_ext=.css +module.file_ext=.scss + [strict] diff --git a/package.json b/package.json index 03ec42389..f1545afa3 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "build": "cross-env NODE_ENV=production yarn compile:electron && electron-builder build", "build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null", "crossenv": "./node_modules/cross-env/dist/bin/cross-env", + "flow": "flow", "lint": "eslint 'ui/**/*.{js,jsx}' && eslint 'web/**/*.{js,jsx}' && eslint 'electron/**/*.js' && flow", "lint-fix": "eslint --fix --quiet 'ui/**/*.{js,jsx}' && eslint --fix --quiet 'web/**/*.{js,jsx}' && eslint --fix --quiet 'electron/**/*.js'", "format": "prettier 'src/**/*.{js,jsx,scss,json}' --write", diff --git a/ui/component/claimPreviewSubtitle/view.jsx b/ui/component/claimPreviewSubtitle/view.jsx index 0b58adb04..f26e08498 100644 --- a/ui/component/claimPreviewSubtitle/view.jsx +++ b/ui/component/claimPreviewSubtitle/view.jsx @@ -16,6 +16,7 @@ type Props = { isLivestream: boolean, }; +// previews used in channel overview and homepage (and other places?) function ClaimPreviewSubtitle(props: Props) { const { pending, uri, claim, type, beginPublish, isLivestream } = props; const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0; diff --git a/ui/component/claimPreviewTile/index.js b/ui/component/claimPreviewTile/index.js index e9372e4eb..40b3355c0 100644 --- a/ui/component/claimPreviewTile/index.js +++ b/ui/component/claimPreviewTile/index.js @@ -12,7 +12,7 @@ import { makeSelectDateForUri, } from 'lbry-redux'; import { selectMutedChannels } from 'redux/selectors/blocked'; -import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; +import { makeSelectViewCountForUri, selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc'; import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream'; import { selectShowMatureContent } from 'redux/selectors/settings'; import ClaimPreviewTile from './view'; @@ -38,6 +38,7 @@ const select = (state, props) => { isMature: makeSelectClaimIsNsfw(props.uri)(state), isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state), isLivestreamActive: makeSelectIsActiveLivestream(props.uri)(state), + viewCount: makeSelectViewCountForUri(props.uri)(state), }; }; diff --git a/ui/component/claimPreviewTile/view.jsx b/ui/component/claimPreviewTile/view.jsx index 235b86e4b..a5c515ffd 100644 --- a/ui/component/claimPreviewTile/view.jsx +++ b/ui/component/claimPreviewTile/view.jsx @@ -51,10 +51,11 @@ type Props = { collectionId?: string, showNoSourceClaims?: boolean, isLivestream: boolean, + viewCount: string, isLivestreamActive: boolean, }; -// preview image cards used in related video functionality +// preview image cards used in related video functionality, channel overview page and homepage function ClaimPreviewTile(props: Props) { const { history, @@ -80,6 +81,7 @@ function ClaimPreviewTile(props: Props) { isLivestreamActive, collectionId, mediaDuration, + viewCount, } = props; const isRepost = claim && claim.repost_channel_url; const isCollection = claim && claim.value_type === 'collection'; @@ -177,6 +179,10 @@ function ClaimPreviewTile(props: Props) { return null; } + const isChannelPage = window.location.pathname.startsWith('/@'); + + const shouldShowViewCount = !(!viewCount || (claim && claim.repost_url) || isLivestream || !isChannelPage); + if (placeholder || (!claim && isResolvingUri)) { return (
  • @@ -185,7 +191,9 @@ function ClaimPreviewTile(props: Props) {
    -
    +
  • ); @@ -245,7 +253,9 @@ function ClaimPreviewTile(props: Props) {
    -
    +
    {isChannel ? (
    diff --git a/ui/component/dateTime/view.jsx b/ui/component/dateTime/view.jsx index a372cbd74..b8e25210f 100644 --- a/ui/component/dateTime/view.jsx +++ b/ui/component/dateTime/view.jsx @@ -104,11 +104,11 @@ class DateTime extends React.Component { return null; } - return {DateTime.getTimeAgoStr(date)}; + return {DateTime.getTimeAgoStr(date)}; } return ( - + {date && show === DateTime.SHOW_DATE && moment(date).format('MMMM Do, YYYY')} {date && show === DateTime.SHOW_TIME && moment(date).format(clockFormat)} {!date && '...'} diff --git a/ui/component/fileViewCountInline/view.jsx b/ui/component/fileViewCountInline/view.jsx index 395195c3c..640cababf 100644 --- a/ui/component/fileViewCountInline/view.jsx +++ b/ui/component/fileViewCountInline/view.jsx @@ -1,5 +1,6 @@ // @flow import React from 'react'; +import 'scss/component/_view_count.scss'; type Props = { uri: string, @@ -15,12 +16,12 @@ export default function FileViewCountInline(props: Props) { let formattedViewCount; try { + // SI notation that changes 1234 to 1.2K, look up Intl.NumberFormat() for docs formattedViewCount = Number(viewCount).toLocaleString(lang || 'en', { compactDisplay: 'short', notation: 'compact', }); } catch (err) { - // No soup for you! formattedViewCount = Number(viewCount).toLocaleString(); } @@ -29,6 +30,7 @@ export default function FileViewCountInline(props: Props) { // clean up (only one place edit/remove). const isChannelPage = window.location.pathname.startsWith('/@'); + // dont show if no view count, if it's a repost, a livestream or isn't a channel page if (!viewCount || (claim && claim.repost_url) || isLivestream || !isChannelPage) { // (1) Currently, makeSelectViewCountForUri doesn't differentiate between // un-fetched view-count vs zero view-count. But since it's probably not diff --git a/ui/scss/component/_claim-list.scss b/ui/scss/component/_claim-list.scss index aece45bcb..8aed6c484 100644 --- a/ui/scss/component/_claim-list.scss +++ b/ui/scss/component/_claim-list.scss @@ -556,9 +556,9 @@ .claim-tile__info { display: flex; margin-top: var(--spacing-s); - padding: var(--spacing-s); border-top: 1px solid var(--color-border); color: var(--color-subtitle); + padding: var(--spacing-s); .channel-thumbnail { @include handleChannelGif(2.1rem); @@ -605,13 +605,6 @@ flex-wrap: wrap; } -.view_count { - &::after { - content: '•'; - margin: 0 var(--spacing-xxs); - } -} - .claim-preview__file-property-overlay { position: absolute; bottom: var(--spacing-xxs); diff --git a/ui/scss/component/_view_count.scss b/ui/scss/component/_view_count.scss new file mode 100644 index 000000000..842ed7bea --- /dev/null +++ b/ui/scss/component/_view_count.scss @@ -0,0 +1,34 @@ +@import '../init/vars'; + +.contains_view_count { + // accommodating for large view counts on channel overview + @media (min-width: $breakpoint-large) { + padding: var(--spacing-s) 4px; + + .date_time { + font-size: 11px; + } + } + + .channel-thumbnail { + // accommodating for large view counts on channel overview + @media (min-width: $breakpoint-large) { + margin-right: 7px; + } + } +} + +.view_count { + &::after { + content: '•'; + margin: 0 4px; + } + + @media (min-width: $breakpoint-large) { + &::after { + margin: 0 2.5px; + } + + font-size: 11px; + } +}