Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newnew #2144

Merged
merged 8 commits into from
Dec 19, 2018
Merged

Newnew #2144

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"electron-log": "^2.2.12",
"electron-updater": "^2.23.3",
"electron-window-state": "^4.1.1",
"filewatcher-webpack-plugin": "^1.2.0",
"find-process": "^1.1.0",
"formik": "^0.10.4",
"hast-util-sanitize": "^1.1.2",
Expand Down Expand Up @@ -89,6 +90,7 @@
},
"devDependencies": {
"@lbry/color": "^1.0.2",
"@lbry/components": "^1.5.1",
"axios": "^0.18.0",
"babel-eslint": "^8.2.2",
"babel-plugin-module-resolver": "^3.1.1",
Expand All @@ -113,7 +115,6 @@
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.7.0",
"filewatcher-webpack-plugin": "^1.2.0",
"flow-bin": "^0.69.0",
"flow-typed": "^2.3.0",
"husky": "^0.14.3",
Expand Down
1 change: 0 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ app.on('ready', async () => {
// Windows WMIC returns lbrynet start with 2 spaces. https://github.com/yibn2008/find-process/issues/18
const processListArgs = process.platform === 'win32' ? 'lbrynet start' : 'lbrynet start';
const processList = await findProcess('name', processListArgs);

const isDaemonRunning = processList.length > 0;

if (!isDaemonRunning) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/component/address/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Address extends React.PureComponent<Props> {
const { address, doToast } = this.props;

return (
<FormRow verticallyCentered padded stretch>
<FormRow verticallyCentered stretch>
<input
className="input-copyable form-field__input"
readOnly
Expand Down
1 change: 1 addition & 0 deletions src/renderer/component/app/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class App extends React.PureComponent<Props> {

scrollListener() {
const { recordScroll } = this.props;

if (this.mainContent) {
recordScroll(this.mainContent.scrollTop);
}
Expand Down
12 changes: 7 additions & 5 deletions src/renderer/component/button/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type Props = {
noPadding: ?boolean, // to remove padding and allow circular buttons
uppercase: ?boolean,
iconColor?: string,
tourniquet: ?boolean, // to shorten the button and ellipsis, only use for links
iconSize?: number,
constrict: ?boolean, // to shorten the button and ellipsis, only use for links
};

class Button extends React.PureComponent<Props> {
Expand Down Expand Up @@ -51,7 +52,8 @@ class Button extends React.PureComponent<Props> {
noPadding,
uppercase,
iconColor,
tourniquet,
iconSize,
constrict,
...otherProps
} = this.props;

Expand All @@ -71,7 +73,7 @@ class Button extends React.PureComponent<Props> {
'btn--link': button === 'link',
'btn--external-link': button === 'link' && href,
'btn--uppercase': uppercase,
'btn--tourniquet': tourniquet,
'btn--constrict': constrict,
}
: 'btn--no-style',
className
Expand All @@ -87,10 +89,10 @@ class Button extends React.PureComponent<Props> {

const content = (
<span className="btn__content">
{icon && <Icon icon={icon} iconColor={iconColor} />}
{icon && <Icon icon={icon} iconColor={iconColor} size={iconSize} />}
{label && <span className="btn__label">{label}</span>}
{children && children}
{iconRight && <Icon icon={iconRight} iconColor={iconColor} />}
{iconRight && <Icon icon={iconRight} iconColor={iconColor} size={iconSize} />}
</span>
);

Expand Down
16 changes: 8 additions & 8 deletions src/renderer/component/cardMedia/view.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from 'react';
import classnames from 'classnames';
import Native from 'native';

type Props = {
thumbnail: ?string, // externally sourced image
Expand All @@ -12,13 +12,13 @@ class CardMedia extends React.PureComponent<Props> {

return (
<div
style={thumbnail ? { backgroundImage: `url('${thumbnail}')` } : {}}
className={classnames('card__media', {
'card__media--no-img': !thumbnail,
})}
>
{!thumbnail && <span className="card__media-text">LBRY</span>}
</div>
style={
thumbnail
? { backgroundImage: `url('${thumbnail}')` }
: { backgroundImage: `url('${Native.imagePath('placeholder.png')}')` }
}
className="media__thumb"
/>
);
}
}
Expand Down
66 changes: 26 additions & 40 deletions src/renderer/component/categoryList/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ToolTip from 'component/common/tooltip';
import FileCard from 'component/fileCard';
import Button from 'component/button';
import SubscribeButton from 'component/subscribeButton';
import classnames from 'classnames';

type Props = {
category: string,
Expand All @@ -17,7 +16,6 @@ type Props = {
channelClaims: ?Array<Claim>,
fetchChannel: string => void,
obscureNsfw: boolean,
isSubComponent: boolean,
};

type State = {
Expand All @@ -28,7 +26,6 @@ type State = {
class CategoryList extends PureComponent<Props, State> {
static defaultProps = {
categoryLink: '',
isSubComponent: false,
};

constructor() {
Expand Down Expand Up @@ -210,32 +207,29 @@ class CategoryList extends PureComponent<Props, State> {
}

render() {
const {
category,
categoryLink,
names,
channelClaims,
obscureNsfw,
isSubComponent,
} = this.props;
const { category, categoryLink, names, channelClaims, obscureNsfw } = this.props;
const { canScrollNext, canScrollPrevious } = this.state;
const isCommunityTopBids = category.match(/^community/i);
const showScrollButtons = isCommunityTopBids ? !obscureNsfw : true;

// isSubComponent is a hack, this component should be able to handle this with proper overflow styling

return (
NetOpWibby marked this conversation as resolved.
Show resolved Hide resolved
<div className="card-row">
<div
className={classnames('card-row__header', {
'card-row__header--sub-component': isSubComponent,
})}
>
<div className="card-row__title">
<section className="media-group--row">
<header className="media-group__header">
<div className="media-group__header-title">
{categoryLink ? (
<div className="card__actions card__actions--no-margin">
<Button label={category} navigate="/show" navigateParams={{ uri: categoryLink }} />
<SubscribeButton uri={`lbry://${categoryLink}`} showSnackBarOnSubscribe />
<div className="channel-info__actions">
<div className="channel-info__actions__group">
<Button
label={category}
navigate="/show"
navigateParams={{ uri: categoryLink }}
/>
<SubscribeButton
button="alt"
showSnackBarOnSubscribe
uri={`lbry://${categoryLink}`}
/>
</div>
</div>
) : (
category
Expand All @@ -250,38 +244,30 @@ class CategoryList extends PureComponent<Props, State> {
)}
</div>
{showScrollButtons && (
<div
className={classnames('card-row__scroll-btns', {
'card-row__scroll-btns--sub-component': isSubComponent,
})}
>
<nav className="media-group__header-navigation">
<Button
className="btn--arrow"
disabled={!canScrollPrevious}
onClick={this.handleScrollPrevious}
icon={ICONS.ARROW_LEFT}
/>
<Button
className="btn--arrow"
disabled={!canScrollNext}
onClick={this.handleScrollNext}
icon={ICONS.ARROW_RIGHT}
/>
</div>
</nav>
)}
</div>
</header>
{obscureNsfw && isCommunityTopBids ? (
<div className="card-row__message help">
<p className="media__message media__message--help">
{__(
'The community top bids section is only visible if you allow mature content in the app. You can change your content viewing preferences'
)}{' '}
<Button button="link" navigate="/settings" label={__('here')} />.
</div>
</p>
) : (
<div
className={classnames('card-row__scrollhouse', {
'card-row__scrollhouse--sub-component': isSubComponent,
})}
<ul
NetOpWibby marked this conversation as resolved.
Show resolved Hide resolved
className="media-scrollhouse"
NetOpWibby marked this conversation as resolved.
Show resolved Hide resolved
ref={ref => {
this.rowItems = ref;
}}
Expand Down Expand Up @@ -314,9 +300,9 @@ class CategoryList extends PureComponent<Props, State> {
new Array(10).fill(1).map((x, i) => <FileCard placeholder key={i} />)
/* eslint-enable react/no-array-index-key */
}
</div>
</ul>
)}
</div>
</section>
);
}
}
Expand Down
32 changes: 22 additions & 10 deletions src/renderer/component/channelTile/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import type { Claim } from 'types/claim';
type Props = {
uri: string,
isResolvingUri: boolean,
isSearchResult: boolean,
totalItems: number,
size: string,
claim: ?Claim,
resolveUri: string => void,
navigate: (string, ?{}) => void,
buttonStyle: string,
};

class ChannelTile extends React.PureComponent<Props> {
Expand All @@ -36,7 +38,16 @@ class ChannelTile extends React.PureComponent<Props> {
}

render() {
const { claim, navigate, isResolvingUri, totalItems, uri, size } = this.props;
const {
claim,
navigate,
isResolvingUri,
isSearchResult,
totalItems,
uri,
size,
buttonStyle,
} = this.props;

let channelName;
let subscriptionUri;
Expand All @@ -51,20 +62,21 @@ class ChannelTile extends React.PureComponent<Props> {
<section
onClick={onClick}
role="button"
className={classnames('file-tile card--link', {
'file-tile--small': size === 'small',
'file-tile--large': size === 'large',
className={classnames('media-tile card--link', {
'media--search-result': isSearchResult,
'media--small': size === 'small',
'media--large': size === 'large',
})}
>
<CardMedia title={channelName} thumbnail={null} />
<div className="file-tile__info">
{isResolvingUri && <div className="file-tile__title">{__('Loading...')}</div>}
<div className="media__info">
{isResolvingUri && <div className="media__title">{__('Loading...')}</div>}
{!isResolvingUri && (
<React.Fragment>
<div className="file-tile__title">
<div className="media__title">
<TruncatedText text={channelName || uri} lines={1} />
</div>
<div className="card__subtitle">
<div className="media__subtitle">
{totalItems > 0 && (
<span>
{totalItems} {totalItems === 1 ? 'file' : 'files'}
Expand All @@ -75,8 +87,8 @@ class ChannelTile extends React.PureComponent<Props> {
</React.Fragment>
)}
{subscriptionUri && (
<div className="card__actions">
<SubscribeButton uri={subscriptionUri} />
<div className="media__actions">
<SubscribeButton buttonStyle="inverse" uri={subscriptionUri} />
</div>
)}
</div>
Expand Down
17 changes: 8 additions & 9 deletions src/renderer/component/common/credit-amount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Props = {
large?: boolean,
showLBC?: boolean,
fee?: boolean,
inheritStyle?: boolean,
badge?: boolean,
};

Expand All @@ -37,7 +36,6 @@ class CreditAmount extends React.PureComponent<Props> {
isEstimate,
fee,
showLBC,
inheritStyle,
badge,
} = this.props;

Expand Down Expand Up @@ -66,7 +64,11 @@ class CreditAmount extends React.PureComponent<Props> {
}

if (showLBC) {
amountText = `${amountText} ${__('LBC')}`;
amountText = (
<span>
{amountText} {__('LBC')}
</span>
);
}

if (fee) {
Expand All @@ -77,14 +79,11 @@ class CreditAmount extends React.PureComponent<Props> {
return (
<span
title={fullPrice}
className={classnames('credit-amount', {
'credit-amount--large': large,
// TODO: remove inheritStyle prop
// It just complicates things
'credit-amount--inherit': inheritStyle,
className={classnames('badge', {
badge,
'badge--cost': badge && !isFree,
'badge--cost': (badge && !isFree) || amount > 0,
'badge--free': badge && isFree,
'badge--large': large,
})}
>
{amountText}
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/component/common/form-components/form-field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ export class FormField extends React.PureComponent<Props> {
if (type) {
if (type === 'select') {
input = (
<select className="form-field__select" id={name} {...inputProps}>
{children}
</select>
<div className="form-field__select-wrapper">
<select className="form-field__select" id={name} {...inputProps}>
{children}
</select>
</div>
);
} else if (type === 'markdown') {
const handleEvents = {
Expand Down
Loading