Skip to content

🎥 Make videos programmatically with React

Elements: Show Browser Studio action below contributors

Igor Samokhovets1e12e214450e
diff --git a/packages/docs/src/components/Elements/ElementPage.module.css b/packages/docs/src/components/Elements/ElementPage.module.css
index 73afb8a738..efbed493c8 100644
--- a/packages/docs/src/components/Elements/ElementPage.module.css
+++ b/packages/docs/src/components/Elements/ElementPage.module.css
@@ -98,7 +98,40 @@
.actionRow {
display: flex;
flex-direction: column;
- gap: 10px;
+}
+
+.browserStudioAction {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 4px;
+ min-height: 32px;
+ margin-top: 24px;
+ padding: 4px 0;
+ border: 0;
+ appearance: none;
+ background: transparent;
+ color: var(--ifm-color-emphasis-800);
+ cursor: pointer;
+ font: inherit;
+ font-size: 0.875rem;
+ font-weight: 500;
+ line-height: 1.5;
+}
+
+.browserStudioAction svg {
+ flex: none;
+}
+
+.browserStudioAction:hover {
+ color: var(--ifm-color-primary);
+ text-decoration: underline;
+ text-underline-offset: 2px;
+}
+
+.browserStudioAction:focus-visible {
+ outline: 2px solid var(--ifm-color-primary);
+ outline-offset: 2px;
}
.studioGuidance {
@@ -292,6 +325,13 @@
}
}
+@media (pointer: coarse) {
+ .browserStudioAction {
+ min-height: 48px;
+ padding: 8px;
+ }
+}
+
@media (max-width: 600px) {
.sourceViewportCollapsed {
height: 160px;
diff --git a/packages/docs/src/components/Elements/ElementPage.tsx b/packages/docs/src/components/Elements/ElementPage.tsx
index 79da0420a1..ee5672ec67 100644
--- a/packages/docs/src/components/Elements/ElementPage.tsx
+++ b/packages/docs/src/components/Elements/ElementPage.tsx
@@ -15,7 +15,7 @@ import React, {
type ReactNode,
} from 'react';
import {InlineStep} from '../../../components/InlineStep';
-import {PlainButton} from '../../../components/layout/Button';
+import {ExternalLinkIcon} from '../../theme/DocBreadcrumbs/icons';
import {Seo} from '../Seo';
import type {ElementDefinition} from './element-definitions';
import {
@@ -54,8 +54,6 @@ export const ElementPage: React.FC<ElementPageProps> = ({
});
const [isInstallHintVisible, setIsInstallHintVisible] = useState(false);
const [isSourceVisible, setIsSourceVisible] = useState(false);
- const [isBrowserStudioActionVisible, setIsBrowserStudioActionVisible] =
- useState(false);
const [isEmbeddedInStudio, setIsEmbeddedInStudio] = useState<boolean | null>(
null,
);
@@ -79,38 +77,6 @@ export const ElementPage: React.FC<ElementPageProps> = ({
return () => window.clearTimeout(timeout);
}, [installStatus.type]);
- useEffect(() => {
- const onKeyDown = (event: KeyboardEvent) => {
- if (
- event.repeat ||
- !event.altKey ||
- !event.shiftKey ||
- event.ctrlKey ||
- event.metaKey ||
- event.code !== 'KeyB'
- ) {
- return;
- }
-
- const {target} = event;
- if (
- target instanceof HTMLElement &&
- (target.isContentEditable ||
- target.tagName === 'INPUT' ||
- target.tagName === 'SELECT' ||
- target.tagName === 'TEXTAREA')
- ) {
- return;
- }
-
- event.preventDefault();
- setIsBrowserStudioActionVisible(true);
- };
-
- window.addEventListener('keydown', onKeyDown);
- return () => window.removeEventListener('keydown', onKeyDown);
- }, []);
-
const installElement = useCallback(async () => {
if (!sourceCode) {
return;
@@ -265,17 +231,6 @@ export const ElementPage: React.FC<ElementPageProps> = ({
: 'Install in the most recently focused Remotion Studio'
}
/>
- {isBrowserStudioActionVisible ? (
- <PlainButton
- fullWidth
- loading={false}
- onClick={openInBrowserStudio}
- size="sm"
- style={{padding: '7px 12px'}}
- >
- Open in Browser Studio
- </PlainButton>
- ) : null}
</div>
{installStatus.type === 'error' &&
(installStatus.code === 'no-compatible-studio' ||
@@ -417,6 +372,17 @@ export const ElementPage: React.FC<ElementPageProps> = ({
</div>
</div>
) : null}
+ {sourceCode ? (
+ <button
+ aria-label="Try this Element in Browser Studio in a new tab"
+ className={styles.browserStudioAction}
+ onClick={openInBrowserStudio}
+ type="button"
+ >
+ Try in Browser Studio
+ <ExternalLinkIcon />
+ </button>
+ ) : null}
</div>
</aside>
</div>