lbry-desktop/ui/component/common/card.jsx
Sean Yesmunt 2677cd17d8
new signin/signup (#3960)
* new signin/signup

* cleanup and password reset

* new flow working

* cleanup

* add 'autoComplete' props

* fix prop

* try to call email/confirm before resetting password

* Dont use password reset token for email confirmation.

* add password reset

* password manager improvements

* update lbryinc

* cleanup

* slightly improve close button on sign up page

* moar fixes

* fix password autofil

Co-authored-by: Mark Beamer Jr <markbeamerjr@gmail.com>
2020-04-13 15:16:07 -04:00

82 lines
2.2 KiB
JavaScript

// @flow
import type { Node } from 'react';
import React, { useState } from 'react';
import classnames from 'classnames';
import Icon from 'component/common/icon';
import Button from 'component/button';
import { toCapitalCase } from 'util/string';
import * as ICONS from 'constants/icons';
type Props = {
title?: string | Node,
subtitle?: string | Node,
body?: string | Node,
actions?: string | Node,
icon?: string,
className?: string,
isPageTitle?: boolean,
isBodyTable?: boolean,
defaultExpand?: boolean,
nag?: Node,
};
export default function Card(props: Props) {
const {
title,
subtitle,
body,
actions,
icon,
className,
isPageTitle = false,
isBodyTable = false,
defaultExpand,
nag,
} = props;
const [expanded, setExpanded] = useState(defaultExpand);
const expandable = defaultExpand !== undefined;
return (
<section className={classnames(className, 'card')}>
{(title || subtitle) && (
<div className="card__header--between">
<div className="card__section--flex">
{icon && <Icon sectionIcon icon={icon} />}
<div>
{isPageTitle && <h1 className="card__title">{title}</h1>}
{!isPageTitle && <h2 className="card__title">{title}</h2>}
{subtitle && <div className="card__subtitle">{subtitle}</div>}
</div>
</div>
{expandable && (
<div className="card__expand-btn">
<Button
button={'alt'}
aria-label={__('More')}
icon={expanded ? toCapitalCase(ICONS.SUBTRACT) : toCapitalCase(ICONS.ADD)}
onClick={() => setExpanded(!expanded)}
/>
</div>
)}
</div>
)}
{(!expandable || (expandable && expanded)) && (
<>
{body && (
<div
className={classnames('card__body', {
'card__body--no-title': !title && !subtitle,
'card__body--table': isBodyTable,
})}
>
{body}
</div>
)}
{actions && <div className="card__main-actions">{actions}</div>}
</>
)}
{nag}
</section>
);
}