import * as React from "react"; import * as Constants from "~/common/constants"; import * as Strings from "~/common/strings"; import * as Actions from "~/common/actions"; import { css } from "@emotion/react"; import { LoaderSpinner } from "~/components/system/components/Loaders"; import { ProcessedText } from "~/components/system/components/Typography"; import TextareaAutoSize from "~/vendor/react-textarea-autosize"; const STYLES_SIDEBAR_INPUT = css` position: relative; `; const STYLES_SIDEBAR_TEXTAREA = css` resize: none; box-sizing: border-box; line-height: 1.255; font-size: 16px; outline: 0; border: 0; background: transparent; width: 100%; white-space: pre-wrap; padding: 48px 24px 24px 24px; color: ${Constants.system.white}; font-family: ${Constants.font.text}; scrollbar-width: none; -ms-overflow-style: -ms-autohiding-scrollbar; ::-webkit-scrollbar { display: none; } `; const STYLES_SIDEBAR_INPUT_LABEL = css` font-family: ${Constants.font.code}; letter-spacing: 0.1px; color: #999; font-size: 10px; text-transform: uppercase; width: 100%; position: absolute; padding: 16px 24px 0px 24px; `; class SidebarInput extends React.Component { render() { return (
); } } const STYLES_SIDEBAR = css` width: 420px; flex-shrink: 0; height: 100%; background-color: ${Constants.system.pitchBlack}; border-left: 1px solid #222; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; @media (max-width: ${Constants.sizes.mobile}px) { display: none; } `; const STYLES_BUTTON = css` border-top: 1px solid #222222; flex-shrink: 0; color: ${Constants.system.white}; width: 100%; padding: 16px 24px 16px 24px; min-height: 56px; font-size: 14px; font-family: ${Constants.font.semiBold}; transition: 200ms ease all; cursor: pointer; overflow-wrap: break-word; text-decoration: none; :hover { background-color: ${Constants.system.brand}; } `; const STYLES_SIDEBAR_SECTION = css` flex-shrink: 0; width: 100%; `; const STYLES_SIDEBAR_CONTENT = css` width: 100%; height: 100%; overflow-y: scroll; scrollbar-width: none; -ms-overflow-style: -ms-autohiding-scrollbar; ::-webkit-scrollbar { display: none; } `; const STYLES_HEADING = css` font-family: ${Constants.font.medium}; font-size: 16px; line-height: 1.225; font-weight: 400; padding: 16px 24px 24px 24px; overflow-wrap: break-word; white-space: pre-wrap; `; const STYLES_BODY = css` font-size: 16px; line-height: 1.225; padding: 24px; overflow-wrap: break-word; white-space: pre-wrap; `; export default class SlateMediaObjectSidebar extends React.Component { state = { title: this.props.data.title ? this.props.data.title : "", body: this.props.data.body ? this.props.data.body : "", source: this.props.data.source ? this.props.data.source : "", author: this.props.data.author ? this.props.data.author : "", deeplink: this.props.data.deeplink ? this.props.data.deeplink : "", }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; _handleChangeDeepLink = (e) => { this.setState({ [e.target.name]: Strings.createSlug(e.target.value, "") }); }; render() { const elements = []; if (this.props.data) { if (this.props.editing) { elements.push(
); elements.push( this.props.onObjectSave({ ...this.props.data, ...this.state }) } > {this.props.saving ? ( ) : ( Save   ⭢ )} ); } else { const hasTitle = !Strings.isEmpty(this.props.data.title); const hasBody = !Strings.isEmpty(this.props.data.body); const hasSource = !Strings.isEmpty(this.props.data.source); const hasAuthor = !Strings.isEmpty(this.props.data.author); if (hasTitle) { elements.push(

); } if (hasBody || hasTitle || hasSource || hasAuthor) { elements.push(

); } if (hasSource) { elements.push(
Source

); } if (hasAuthor) { elements.push(
Author

); } } } if (this.props.cid) { elements.push(
Open file in new tab   ⭢ Download file   ⭢
); } if (this.props.onDelete && this.props.editing) { elements.push( this.props.onDelete(this.props.id)} onTouchEnd={() => this.props.onDelete(this.props.id)} > {this.props.loading ? ( ) : ( Delete from slate   ⭢ )} ); } if (!elements.length) { return null; } return
{elements}
; } }