import * as React from "react"; import * as Constants from "~/common/constants"; import * as SVG from "~/common/svg"; import { css } from "@emotion/react"; import { ProcessedText } from "~/components/system/components/Typography"; import { Boundary } from "~/components/system/components/fragments/Boundary"; import { PopoverNavigation } from "~/components/system/components/PopoverNavigation"; import { TooltipWrapper } from "~/components/system/components/fragments/GlobalTooltip"; import { dispatchCustomEvent } from "~/common/custom-events"; import SlateMediaObjectPreview from "~/components/core/SlateMediaObjectPreview"; const STYLES_IMAGE_ROW = css` display: flex; flex-direction: row; flex-wrap: wrap; height: 160px; overflow: hidden; margin: 0px -18px; @media (max-width: ${Constants.sizes.mobile}px) { justify-content: center; } `; const STYLES_ITEM_BOX = css` width: 160px; height: 160px; margin: 0px 18px; display: flex; align-items: center; justify-content: center; box-shadow: 0px 0px 0px 1px rgba(229, 229, 229, 0.5) inset; cursor: pointer; @media (max-width: ${Constants.sizes.mobile}px) { margin: 0 auto; } :hover { color: ${Constants.system.brand}; } `; const STYLES_IMAGE_ROW_SMALL = css` display: flex; flex-direction: row; flex-wrap: wrap; height: 56px; overflow: hidden; margin: 0px -8px; @media (max-width: ${Constants.sizes.mobile}px) { justify-content: center; } `; const STYLES_ITEM_BOX_SMALL = css` width: 56px; height: 56px; margin: 0px 8px; display: flex; align-items: center; justify-content: center; box-shadow: 0px 0px 0px 1px rgba(229, 229, 229, 0.5) inset; @media (max-width: ${Constants.sizes.mobile}px) { margin: 0 auto; } `; export function SlatePreviewRow(props) { let numItems = props.numItems || 5; let objects = props.slate.data.objects.length > numItems ? props.slate.data.objects.slice(0, numItems) : props.slate.data.objects; return (
{objects.map((each) => (
))}
); } const STYLES_BLOCK = css` border: 1px solid ${Constants.system.border}; border-radius: 8px; padding: 32px 40px; font-size: 12px; text-align: left; margin: 24px auto 48px auto; max-width: 1026px; cursor: pointer; `; const STYLES_TITLE_LINE = css` display: grid; grid-template-columns: auto auto 1fr; align-items: center; font-size: ${Constants.typescale.lvl1}; margin-bottom: 16px; `; const STYLES_BUTTON = css` display: inline-block; margin-left: 12px; padding: 4px 8px; cursor: pointer; color: ${Constants.system.brand}; `; const STYLES_COPY_INPUT = css` pointer-events: none; position: absolute; tabindex: -1; opacity: 0; `; const STYLES_TAG = css` margin-left: 16px; padding: 4px 8px; border-radius: 2px; border: 1px solid ${Constants.system.black}; color: ${Constants.system.black}; font-family: ${Constants.font.semiBold}; font-size: 0.9rem; `; const STYLES_BODY = css` font-family: ${Constants.font.text}; font-size: 0.9rem; margin-bottom: 24px; line-height: 20px; white-space: pre-wrap; `; const STYLES_CREATE_NEW = css` color: ${Constants.system.darkGray}; box-shadow: 0px 0px 0px 1px rgba(229, 229, 229, 0.5) inset; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 160px; height: 160px; `; const STYLES_ICON_BOX = css` height: 32px; width: 32px; display: flex; align-items: center; justify-content: center; position: relative; color: ${Constants.system.darkGray}; `; const STYLES_CONTEXT_MENU = css` position: absolute; `; export default class SlatePreviewBlock extends React.Component { _ref; _test; state = { showMenu: false, copyValue: "", }; _componentDidMount = () => { console.log(this._test.getBoundingClientRect()); }; _handleCopy = (e, value) => { e.stopPropagation(); this.setState({ copyValue: value }, () => { this._ref.select(); document.execCommand("copy"); this._handleHide(); }); }; _handleClick = (e) => { e.stopPropagation(); if (this.state.showMenu) { this._handleHide(); return; } this.setState({ showMenu: true }); // dispatchCustomEvent({ // name: "show-tooltip", // detail: { // id: `slate-tooltip-${this.props.slate.id}`, // }, // }); }; _handleHide = (e) => { this.setState({ showMenu: false }); // dispatchCustomEvent({ // name: "hide-tooltip", // detail: { // id: `slate-tooltip-${this.props.slate.id}`, // }, // }); }; render() { console.log(this.props); if (!this.props.editing && !this.props.slate.data.objects.length) { return null; } let contextMenu = ( this._handleCopy( e, `https://slate.host/${this.props.slate.owner.username}/${this.props.slate.slatename}` ), }, { text: "Copy slate ID", onClick: (e) => this._handleCopy(e, this.props.slate.id), }, ] : [ { text: "Copy URL", onClick: (e) => this._handleCopy( e, `https://slate.host/${this.props.slate.owner.username}/${this.props.slate.slatename}` ), }, ] } /> { this._ref = c; }} value={this.state.copyValue} css={STYLES_COPY_INPUT} /> ); return (
{this.props.slate.data.name}
{this.props.editing ? ( this.props.slate.data.public ? (
Public
) : (
Private
) ) : (
)} {this.props.external ? null : (
{ this._test = c; }} > {/* */}
{this.state.showMenu ? (
{contextMenu}
) : null}
{/*
*/}
)}
{this.props.slate.data.body ? (
) : (
)} {this.props.slate.data.objects.length ? ( ) : (
Add Files
)}
); } }