🎥 Make videos programmatically with React
Elements: Add dedicated page drag handle (#10530)
Igor Samokhovetsff691e351283
diff --git a/packages/docs/src/components/Elements/ElementPage.module.css b/packages/docs/src/components/Elements/ElementPage.module.cssindex 2360232af9..3631e56656 100644--- a/packages/docs/src/components/Elements/ElementPage.module.css+++ b/packages/docs/src/components/Elements/ElementPage.module.css@@ -95,13 +95,6 @@border-radius: 0 !important;}-.useIt {- padding: 12px;- border: 1px solid var(--ifm-color-emphasis-300);- border-radius: 12px;- background: var(--ifm-background-surface-color);-}-.actionRow {display: flex;flex-wrap: wrap;@@ -109,6 +102,59 @@gap: 10px;}+.dragHandle {+ position: relative;+ display: flex;+ align-items: center;+ margin-top: 8px;+ padding: 8px 40px;+ border: 1px solid var(--ifm-color-emphasis-300);+ border-radius: 8px;+ background: var(--ifm-background-surface-color);+ color: var(--ifm-color-emphasis-800);+ cursor: grab;+ font-size: 0.8125rem;+ user-select: none;+}++.dragHandle:hover {+ background: var(--ifm-color-emphasis-100);+}++.dragHandle:active {+ cursor: grabbing;+}++[data-theme='dark'] .dragHandle {+ border-color: var(--ifm-color-emphasis-200);+ color: var(--ifm-color-emphasis-700);+}++.dragHandleIcon {+ position: absolute;+ left: 12px;+ top: 50%;+ font-size: 1.5rem;+ line-height: 1;+ transform: translateY(-50%);+}++[data-theme='dark'] .dragHandleIcon {+ color: var(--ifm-color-emphasis-500);+}++.dragHandleText {+ display: flex;+ flex: 1;+ flex-direction: column;+ line-height: 1.3;+ text-align: center;+}++.dragHandleText strong {+ font-weight: 600;+}+.successStatus,.errorStatus {margin: 12px 0 0;diff --git a/packages/docs/src/components/Elements/ElementPage.tsx b/packages/docs/src/components/Elements/ElementPage.tsxindex 02d97beef9..7cf02561d0 100644--- a/packages/docs/src/components/Elements/ElementPage.tsx+++ b/packages/docs/src/components/Elements/ElementPage.tsx@@ -44,7 +44,6 @@ export const ElementPage: React.FC<ElementPageProps> = ({const [installStatus, setInstallStatus] = useState<InstallStatus>({type: 'idle',});- const [isDragging, setIsDragging] = useState(false);const [isSourceVisible, setIsSourceVisible] = useState(false);const posterRef = useRef<HTMLImageElement>(null);const sourceId = useId();@@ -146,36 +145,42 @@ export const ElementPage: React.FC<ElementPageProps> = ({aria-label="Element details and actions"className={styles.actionsColumn}>- <div className={styles.useIt}>+ <div>{elementPayload === null ? null : (<><div className={styles.actionRow}><BlueButton- draggablefullWidthloading={installStatus.type === 'installing'}onClick={installElement}- onDragEnd={() => setIsDragging(false)}- onDragStart={(event) => {- setIsDragging(true);- setStudioDragData({- dataTransfer: event.dataTransfer,- payload: elementPayload,- });- setElementDragImage(event.dataTransfer, posterRef.current);- }}size="sm"- style={{- cursor: isDragging ? 'grabbing' : undefined,- padding: '7px 12px',- }}- title="Click to install in the most recently focused Remotion Studio, or drag onto the Studio canvas"+ style={{padding: '7px 12px'}}+ title="Install in the most recently focused Remotion Studio">{installStatus.type === 'installing'? 'Finding Studio…': 'Install in Studio'}</BlueButton></div>+ <div+ className={styles.dragHandle}+ draggable+ onDragStart={(event) => {+ setStudioDragData({+ dataTransfer: event.dataTransfer,+ payload: elementPayload,+ });+ setElementDragImage(event.dataTransfer, posterRef.current);+ }}+ title="Hover over your Studio browser tab, then drop on the canvas or timeline"+ >+ <span aria-hidden="true" className={styles.dragHandleIcon}>+ ⠿+ </span>+ <span className={styles.dragHandleText}>+ <strong>Drag to your Studio canvas or timeline</strong>+ </span>+ </div>{installStatus.type === 'success' ||installStatus.type === 'error' ? (<p