Skip to content

🎥 Make videos programmatically with React

Elements: Explain local network permission during discovery

Igor Samokhovets344621442814
diff --git a/packages/docs/src/components/Elements/ElementPage.module.css b/packages/docs/src/components/Elements/ElementPage.module.css
index ff00ac8bc1..480506a9fc 100644
--- a/packages/docs/src/components/Elements/ElementPage.module.css
+++ b/packages/docs/src/components/Elements/ElementPage.module.css
@@ -156,12 +156,17 @@
font-weight: 600;
}
+.installingStatus,
.successStatus,
.errorStatus {
margin: 12px 0 0;
font-size: 0.875rem;
}
+.installingStatus {
+ color: var(--ifm-color-emphasis-700);
+}
+
.successStatus {
color: var(--ifm-color-success-dark);
}
diff --git a/packages/docs/src/components/Elements/ElementPage.tsx b/packages/docs/src/components/Elements/ElementPage.tsx
index 144cec0eea..10b37c0954 100644
--- a/packages/docs/src/components/Elements/ElementPage.tsx
+++ b/packages/docs/src/components/Elements/ElementPage.tsx
@@ -51,6 +51,7 @@ export const ElementPage: React.FC<ElementPageProps> = ({
const [installStatus, setInstallStatus] = useState<InstallStatus>({
type: 'idle',
});
+ const [isInstallHintVisible, setIsInstallHintVisible] = useState(false);
const [isSourceVisible, setIsSourceVisible] = useState(false);
const [isBrowserStudioActionVisible, setIsBrowserStudioActionVisible] =
useState(false);
@@ -72,6 +73,17 @@ export const ElementPage: React.FC<ElementPageProps> = ({
setIsEmbeddedInStudio(isInsideStudio());
}, []);
+ useEffect(() => {
+ if (installStatus.type !== 'installing') {
+ return;
+ }
+
+ const timeout = window.setTimeout(() => {
+ setIsInstallHintVisible(true);
+ }, 1000);
+ return () => window.clearTimeout(timeout);
+ }, [installStatus.type]);
+
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
if (
@@ -109,6 +121,7 @@ export const ElementPage: React.FC<ElementPageProps> = ({
return;
}
+ setIsInstallHintVisible(false);
setInstallStatus({type: 'installing'});
const result = await installInStudio({payload: elementPayload});
if (!result.success) {
@@ -259,17 +272,21 @@ export const ElementPage: React.FC<ElementPageProps> = ({
</span>
</div>
) : null}
- {installStatus.type === 'success' ||
- installStatus.type === 'error' ? (
+ {installStatus.type !== 'idle' &&
+ (installStatus.type !== 'installing' || isInstallHintVisible) ? (
<p
aria-live="polite"
className={
- installStatus.type === 'success'
- ? styles.successStatus
- : styles.errorStatus
+ installStatus.type === 'installing'
+ ? styles.installingStatus
+ : installStatus.type === 'success'
+ ? styles.successStatus
+ : styles.errorStatus
}
>
- {installStatus.message}
+ {installStatus.type === 'installing'
+ ? 'If your browser prompts you, allow local network access so this page can find Remotion Studio.'
+ : installStatus.message}
</p>
) : null}
</>