Skip to content

🎥 Make videos programmatically with React

Elements: Integrate drag handle into install button

Igor Samokhovets0ea100a06be1
diff --git a/packages/docs/components/layout/Button.tsx b/packages/docs/components/layout/Button.tsx
index c56e9b8623..3614989ca1 100644
--- a/packages/docs/components/layout/Button.tsx
+++ b/packages/docs/components/layout/Button.tsx
@@ -28,14 +28,26 @@ type PrestyledProps = DetailedHTMLProps<
MandatoryProps;
export const Button: React.FC<Props> = (props) => {
- const {children, loading, hoverColor, fullWidth, color, size, ...other} =
- props;
+ const {
+ children,
+ loading,
+ hoverColor,
+ fullWidth,
+ color,
+ size,
+ className,
+ ...other
+ } = props;
const actualDisabled = other.disabled || loading;
return (
<button
type="button"
- className={styles.buttoncontainer}
+ className={
+ className
+ ? `${styles.buttoncontainer} ${className}`
+ : styles.buttoncontainer
+ }
disabled={actualDisabled}
{...other}
style={{
diff --git a/packages/docs/src/components/Elements/ElementPage.module.css b/packages/docs/src/components/Elements/ElementPage.module.css
index f1a09bfac2..3d04259995 100644
--- a/packages/docs/src/components/Elements/ElementPage.module.css
+++ b/packages/docs/src/components/Elements/ElementPage.module.css
@@ -97,16 +97,22 @@
.actionRow {
display: flex;
- align-items: flex-start;
+ flex-direction: column;
gap: 10px;
}
-.actionButtons {
+.studioAction {
display: flex;
- flex: 1;
- flex-direction: column;
- gap: 10px;
- min-width: 0;
+ align-items: stretch;
+ width: 100%;
+ border-radius: 8px;
+ background: var(--blue-underlay);
+}
+
+.studioAction .installButtonWithDragHandle {
+ border-top-right-radius: 0;
+ border-right-width: 0;
+ border-bottom-right-radius: 0;
}
.dragHandle {
@@ -114,39 +120,31 @@
align-items: center;
justify-content: center;
width: 46px;
- height: 46px;
+ min-height: 46px;
flex: none;
- border: 1px solid var(--ifm-color-emphasis-300);
- border-radius: 50%;
- background: var(--ifm-background-surface-color);
- box-shadow: 0 2px 5px rgb(0 0 0 / 12%);
- color: var(--ifm-color-emphasis-800);
+ border: 2px solid black;
+ border-bottom-width: 4px;
+ border-left: 1px solid rgb(0 0 0 / 30%);
+ border-radius: 0 8px 8px 0;
+ background: transparent;
+ color: white;
cursor: grab;
user-select: none;
}
.dragHandle:hover {
- background: var(--ifm-color-emphasis-100);
+ background: rgb(0 0 0 / 8%);
}
.dragHandle:active {
cursor: grabbing;
}
-[data-theme='dark'] .dragHandle {
- border-color: var(--ifm-color-emphasis-200);
- color: var(--ifm-color-emphasis-700);
-}
-
.dragHandleIcon {
font-size: 1.5rem;
line-height: 1;
}
-[data-theme='dark'] .dragHandleIcon {
- color: var(--ifm-color-emphasis-500);
-}
-
.successStatus,
.errorStatus {
margin: 12px 0 0;
@@ -226,9 +224,7 @@
}
.contributors:not(:first-child) {
- margin-top: 16px;
- padding-top: 16px;
- border-top: 1px solid var(--ifm-color-emphasis-200);
+ margin-top: 32px;
}
.contributorsLabel {
diff --git a/packages/docs/src/components/Elements/ElementPage.tsx b/packages/docs/src/components/Elements/ElementPage.tsx
index 608ba3263c..c70a74462e 100644
--- a/packages/docs/src/components/Elements/ElementPage.tsx
+++ b/packages/docs/src/components/Elements/ElementPage.tsx
@@ -214,8 +214,13 @@ export const ElementPage: React.FC<ElementPageProps> = ({
{elementPayload === null ? null : (
<>
<div className={styles.actionRow}>
- <div className={styles.actionButtons}>
+ <div className={styles.studioAction}>
<BlueButton
+ className={
+ isEmbeddedInStudio === false
+ ? styles.installButtonWithDragHandle
+ : undefined
+ }
fullWidth
loading={installStatus.type === 'installing'}
onClick={installElement}
@@ -227,39 +232,42 @@ export const ElementPage: React.FC<ElementPageProps> = ({
? 'Finding Studio…'
: 'Install in Studio'}
</BlueButton>
- {isBrowserStudioActionVisible ? (
- <PlainButton
- fullWidth
- loading={false}
- onClick={openInBrowserStudio}
- size="sm"
- style={{padding: '7px 12px'}}
+ {isEmbeddedInStudio === false ? (
+ <div
+ aria-label="Drag into Studio"
+ className={styles.dragHandle}
+ draggable
+ onDragStart={(event) => {
+ setStudioDragData({
+ dataTransfer: event.dataTransfer,
+ payload: elementPayload,
+ });
+ setElementDragImage(
+ event.dataTransfer,
+ posterRef.current,
+ );
+ }}
+ title="Drag into your Studio browser tab to choose where the element is placed on the canvas or timeline"
>
- Open in Browser Studio
- </PlainButton>
+ <span
+ aria-hidden="true"
+ className={styles.dragHandleIcon}
+ >
+ â ¿
+ </span>
+ </div>
) : null}
</div>
- {isEmbeddedInStudio === false ? (
- <div
- aria-label="Drag into Studio"
- className={styles.dragHandle}
- draggable
- onDragStart={(event) => {
- setStudioDragData({
- dataTransfer: event.dataTransfer,
- payload: elementPayload,
- });
- setElementDragImage(
- event.dataTransfer,
- posterRef.current,
- );
- }}
- title="Drag into your Studio browser tab to choose where the element is placed on the canvas or timeline"
+ {isBrowserStudioActionVisible ? (
+ <PlainButton
+ fullWidth
+ loading={false}
+ onClick={openInBrowserStudio}
+ size="sm"
+ style={{padding: '7px 12px'}}
>
- <span aria-hidden="true" className={styles.dragHandleIcon}>
- â ¿
- </span>
- </div>
+ Open in Browser Studio
+ </PlainButton>
) : null}
</div>
{installStatus.type === 'success' ||