From 723da10dadf356eda162224e25238c543218419d Mon Sep 17 00:00:00 2001 From: btzr-io Date: Thu, 30 May 2019 14:51:23 -0600 Subject: [PATCH 01/25] extend markdown support for lbry urls --- .../common/markdown-preview-internal.jsx | 6 +- src/ui/component/externalLink/view.jsx | 4 -- src/ui/util/remark-lbry.js | 68 +++++++++++++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/ui/util/remark-lbry.js diff --git a/src/ui/component/common/markdown-preview-internal.jsx b/src/ui/component/common/markdown-preview-internal.jsx index 78af2273d..04701cc6d 100644 --- a/src/ui/component/common/markdown-preview-internal.jsx +++ b/src/ui/component/common/markdown-preview-internal.jsx @@ -1,8 +1,9 @@ // @flow import * as React from 'react'; import remark from 'remark'; -import reactRenderer from 'remark-react'; +import remarkLBRY from 'util/remark-lbry'; import remarkEmoji from 'remark-emoji'; +import reactRenderer from 'remark-react'; import ExternalLink from 'component/externalLink'; import defaultSchema from 'hast-util-sanitize/lib/github.json'; @@ -30,7 +31,7 @@ const SimpleLink = (props: SimpleLinkProps) => { const schema = { ...defaultSchema }; // Extend sanitation schema to support lbry protocol -schema.protocols.href[3] = 'lbry'; +schema.protocols.href.push('lbry'); const MarkdownPreview = (props: MarkdownProps) => { const { content, promptLinks } = props; @@ -44,6 +45,7 @@ const MarkdownPreview = (props: MarkdownProps) => {
{ remark() + .use(remarkLBRY) .use(remarkEmoji) .use(reactRenderer, remarkOptions) .processSync(content).contents diff --git a/src/ui/component/externalLink/view.jsx b/src/ui/component/externalLink/view.jsx index ccab6ad27..632339842 100644 --- a/src/ui/component/externalLink/view.jsx +++ b/src/ui/component/externalLink/view.jsx @@ -20,14 +20,11 @@ class ExternalLink extends React.PureComponent { createLink() { const { href, title, children, openModal } = this.props; - // Regex for url protocol const protocolRegex = new RegExp('^(https?|lbry)+:', 'i'); const protocol = href ? protocolRegex.exec(href) : null; - // Return plain text if no valid url let element = {children}; - // Return external link if protocol is http or https if (protocol && (protocol[0] === 'http:' || protocol[0] === 'https:')) { element = ( @@ -41,7 +38,6 @@ class ExternalLink extends React.PureComponent { /> ); } - // Return local link if protocol is lbry uri if (protocol && protocol[0] === 'lbry:' && isURIValid(href)) { element = - ); + return {inner}; } } diff --git a/src/ui/page/channel/index.js b/src/ui/page/channel/index.js index a4715823e..53c18e514 100644 --- a/src/ui/page/channel/index.js +++ b/src/ui/page/channel/index.js @@ -9,11 +9,11 @@ import { import ChannelPage from './view'; const select = (state, props) => ({ + page: selectCurrentChannelPage(state), + cover: makeSelectCoverForUri(props.uri)(state), title: makeSelectTitleForUri(props.uri)(state), thumbnail: makeSelectThumbnailForUri(props.uri)(state), - cover: makeSelectCoverForUri(props.uri)(state), channelIsMine: makeSelectClaimIsMine(props.uri)(state), - page: selectCurrentChannelPage(state), }); export default connect( diff --git a/src/ui/page/channel/view.jsx b/src/ui/page/channel/view.jsx index 8cc4ca472..028abf3ce 100644 --- a/src/ui/page/channel/view.jsx +++ b/src/ui/page/channel/view.jsx @@ -9,7 +9,7 @@ import { withRouter } from 'react-router'; import { formatLbryUriForWeb } from 'util/uri'; import ChannelContent from 'component/channelContent'; import ChannelAbout from 'component/channelAbout'; -import ChannelThumbnail from 'component/channelThumbnail'; +import ChannelThumbnail from 'component/common/channelThumbnail'; const PAGE_VIEW_QUERY = `view`; const ABOUT_PAGE = `about`; @@ -26,7 +26,7 @@ type Props = { }; function ChannelPage(props: Props) { - const { uri, title, cover, history, location, page } = props; + const { uri, title, cover, thumbnail, history, location, page } = props; const { channelName, claimName, claimId } = parseURI(uri); const { search } = location; const urlParams = new URLSearchParams(search); @@ -54,7 +54,7 @@ function ChannelPage(props: Props) { {cover && }
- +

{title || channelName}

diff --git a/src/ui/scss/component/_channel.scss b/src/ui/scss/component/_channel.scss index 3abfb87c1..b4f9f02ec 100644 --- a/src/ui/scss/component/_channel.scss +++ b/src/ui/scss/component/_channel.scss @@ -88,19 +88,23 @@ $metadata-z-index: 1; // Tooltip -.channel-tooltip__thumbnail { - width: 4rem; - height: 4rem; - background: #fff; - margin-right: 8px; - border: 0; - border-radius: var(--card-radius); - background-size: cover; - box-shadow: 0px 8px 40px -3px $lbry-black; +.channel-tooltip { + width: 20rem; + + .channel-thumbnail { + left: 0; + position: relative; + margin-right: 0; + flex-shrink: 0; + text-align: center; + display: flex; + max-width: 5rem; + max-height: 5rem; + } } -.channel-tooltip { - width: 18rem; +.channel-tooltip .media-tile { + align-items: center; } .channel-tooltip__description { @@ -110,28 +114,15 @@ $metadata-z-index: 1; border-bottom: 1px solid rgba(0, 0, 0, 0.2); } -.channel-tooltip__description p { - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; - text-overflow: ellipsis; - overflow: hidden; - - /* - This fixes the line-clamp issue on resize: - https://stackoverflow.com/questions/38989475/css-multi-line-line-clamp-ellipsis-doesnt-work - */ - +.channel-tooltip__description { visibility: visible; } .channel-tooltip__info { - display: flex; - justify-content: flex-start; - align-items: center; - flex-direction: row; padding: 8px; margin: 4px 0; + align-items: center; + visibility: visible; } .channel-tooltip__title { -- 2.45.2 From ce7d488fd6b9e83d039feccf87a0a2b8e3914913 Mon Sep 17 00:00:00 2001 From: btzr-io Date: Tue, 11 Jun 2019 20:22:21 -0600 Subject: [PATCH 13/25] fix channel tooltip styles / render issues --- package.json | 2 +- src/ui/component/button/view.jsx | 4 ++ src/ui/component/channelLink/index.js | 3 + src/ui/component/channelLink/view.jsx | 58 +++++++++---------- src/ui/component/common/channel-tooltip.jsx | 40 ++++++++----- .../common/channelThumbnail/index.jsx | 4 +- .../common/markdown-preview-internal.jsx | 1 + src/ui/component/common/preview-link.jsx | 2 +- src/ui/component/externalLink/view.jsx | 1 + src/ui/scss/component/_channel.scss | 27 ++++----- src/ui/scss/init/_gui.scss | 2 +- yarn.lock | 31 ++-------- 12 files changed, 80 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index 074778f31..426087f5e 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,6 @@ "remark-attr": "^0.8.3", "remark-emoji": "^2.0.1", "remark-react": "^4.0.3", - "remark-squeeze-paragraphs": "^3.0.3", "render-media": "^3.1.0", "reselect": "^3.0.0", "sass-loader": "^7.1.0", @@ -176,6 +175,7 @@ "three": "^0.93.0", "three-full": "^17.1.0", "tree-kill": "^1.1.0", + "uniqid": "^5.0.3", "unist-util-visit": "^1.4.1", "video.js": "^7.2.2", "villain": "btzr-io/Villain", diff --git a/src/ui/component/button/view.jsx b/src/ui/component/button/view.jsx index d1c8c89a0..e023edf18 100644 --- a/src/ui/component/button/view.jsx +++ b/src/ui/component/button/view.jsx @@ -7,6 +7,7 @@ import { formatLbryUriForWeb } from 'util/uri'; import { OutboundLink } from 'react-ga'; type Props = { + id: ?string, href: ?string, title: ?string, label: ?string, @@ -37,6 +38,7 @@ class Button extends React.PureComponent { render() { const { + id, onClick, onMouseEnter, onMouseLeave, @@ -109,6 +111,7 @@ class Button extends React.PureComponent { return path ? ( { ) : ( ); } else { return null; diff --git a/src/ui/scss/component/_tooltip.scss b/src/ui/scss/component/_tooltip.scss index fafe9b3c7..7ae09e535 100644 --- a/src/ui/scss/component/_tooltip.scss +++ b/src/ui/scss/component/_tooltip.scss @@ -150,107 +150,3 @@ margin-left: -5px; } } - -// Channel-tooltip - -.channel-tooltip { - color: $lbry-black; - background-color: $lbry-white; - width: 20rem; - border: none; - border-radius: var(--card-radius); - z-index: 2; - - html[data-mode='dark'] & { - color: mix($lbry-white, $lbry-gray-3, 50%); - background-color: mix($lbry-black, $lbry-gray-3, 90%); - } - - box-shadow: 0px 2px 10px -2px black; -} - -.channel-tooltip__content { - width: 100%; - margin: 0; - display: block; - word-break: break-all; - word-wrap: break-word; - white-space: pre-wrap; - - .channel-thumbnail { - left: 0; - position: relative; - flex-shrink: 0; - text-align: center; - display: flex; - max-width: 5rem; - max-height: 5rem; - margin-right: 1rem; - box-shadow: 0px 2px 10px -2px $lbry-black; - } -} - -.channel-tooltip__arrow { - width: 0; - height: 0; - border-left: 10px solid transparent; - border-right: 10px solid transparent; - - html[data-mode='dark'] & { - z-index: 3; - } -} - -.channel-tooltip__arrow--top { - border-top: 10px solid $lbry-gray-5; - border-bottom: 0; - - html[data-mode='dark'] & { - z-index: 3; - border-top: 10px solid mix($lbry-black, $lbry-gray-3, 90%); - border-bottom: 0; - } -} - -.channel-tooltip__arrow--bottom { - border-top: 0; - border-bottom: 10px solid $lbry-gray-5; - - html[data-mode='dark'] & { - z-index: 3; - border-top: 0; - border-bottom: 10px solid mix($lbry-black, $lbry-gray-3, 90%); - } -} - -.channel-tooltip__profile { - display: flex; - align-items: center; - padding: 1rem; -} - -.channel-tooltip__description { - padding: 1rem; - visibility: visible; - border-top: 1px solid rgba($lbry-gray-4, 0.4); - width: 100%; - - html[data-mode='dark'] & { - border-top: 1px solid rgba($lbry-black, 0.8); - } -} - -.channel-tooltip__info { -} - -.channel-tooltip__title { - font-weight: bold; - font-size: 1.4rem; - line-height: 1.5em; - visibility: visible; -} - -.channel-tooltip__url { - font-size: 1rem; - visibility: visible; -} -- 2.45.2