🎥 Make videos programmatically with React
Add combined settings and update button to Studio toolbar
JonnyBurger520348545427
diff --git a/packages/studio/src/components/MenuToolbar.tsx b/packages/studio/src/components/MenuToolbar.tsxindex be7eb59548..b447892420 100644--- a/packages/studio/src/components/MenuToolbar.tsx+++ b/packages/studio/src/components/MenuToolbar.tsx@@ -17,9 +17,9 @@ import {MENU_TOOLBAR_HEIGHT} from './menu-toolbar-height';import type {MenuId} from './Menu/MenuItem';import {MenuItem} from './Menu/MenuItem';import {MenuBuildIndicator} from './MenuBuildIndicator';+import {SettingsButton} from './SettingsButton';import {SidebarCollapserControl} from './SidebarCollapserControls';import {UndoRedoButtons} from './UndoRedoButtons';-import {UpdateCheck} from './UpdateCheck';const row: React.CSSProperties = {alignItems: 'center',@@ -205,13 +205,13 @@ export const MenuToolbar: React.FC<{);})}</div>- {showUpdates ? <UpdateCheck /> : null}</div>{mobileLayout ? null : <div style={flex} />}<MenuBuildIndicator mobileLayout={mobileLayout} /><div style={flex} /><div style={fixedWidthRight}>{canUndoAndRedo ? <UndoRedoButtons /> : null}+ <SettingsButton showUpdates={showUpdates} /><SidebarCollapserControl side="right" /></div></Row>diff --git a/packages/studio/src/components/SettingsButton.tsx b/packages/studio/src/components/SettingsButton.tsxnew file mode 100644index 0000000000..916b9af878--- /dev/null+++ b/packages/studio/src/components/SettingsButton.tsx@@ -0,0 +1,74 @@+import React, {useCallback, useContext} from 'react';+import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';+import {WARNING_COLOR, WHITE_ALPHA_80} from '../helpers/colors';+import {GearIcon} from '../icons/gear';+import {SetSelectedModalContext} from '../state/modals';+import type {RenderInlineAction} from './InlineAction';+import {InlineAction} from './InlineAction';+import {useUpdateStatus} from './UpdateStatusContext';++export const SettingsButton: React.FC<{+ readonly showUpdates: boolean;+}> = ({showUpdates}) => {+ const {setSelectedModal} = useContext(SetSelectedModalContext);+ const {info, knownBugs} = useUpdateStatus();+ const updateAvailable =+ showUpdates &&+ Boolean(info?.updateAvailable || info?.skillsUpdateAvailable);+ const hasBugfixesAvailable =+ showUpdates &&+ Boolean(info?.updateAvailable && knownBugs && knownBugs.length > 0);++ const openModal = useCallback(() => {+ setSelectedModal({+ type: 'settings',+ initialTab: updateAvailable+ ? 'updates'+ : getBrowserStudioOperations() === null+ ? 'rendering'+ : 'shortcuts',+ initialPublicLicenseKey:+ window.remotion_renderDefaults?.publicLicenseKey ?? null,+ });+ }, [setSelectedModal, updateAvailable]);++ const renderGearIcon: RenderInlineAction = useCallback((color) => {+ return <GearIcon color={color} width={16} height={16} />;+ }, []);++ const renderUpdateIcon: RenderInlineAction = useCallback((color) => {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ style={{+ height: 16,+ width: 16,+ color,+ flexShrink: 0,+ }}+ viewBox="0 0 512 512"+ >+ <path+ fill={color}+ d="M256 32a224 224 0 1 1 0 448 224 224 0 1 1 0-448zm0 480a256 256 0 1 0 0-512 256 256 0 1 0 0 512zM377 231L273 127c-9.4-9.4-24.6-9.4-33.9 0L135 231c-6.9 6.9-8.9 17.2-5.2 26.2S142.3 272 152 272l40 0 0 72c0 22.1 17.9 40 40 40l48 0c22.1 0 40-17.9 40-40l0-72 40 0c9.7 0 18.5-5.8 22.2-14.8s1.7-19.3-5.2-26.2z"+ />+ </svg>+ );+ }, []);++ return (+ <InlineAction+ variant={null}+ onClick={openModal}+ renderAction={updateAvailable ? renderUpdateIcon : renderGearIcon}+ unhoveredColor={hasBugfixesAvailable ? WARNING_COLOR : WHITE_ALPHA_80}+ title={+ hasBugfixesAvailable+ ? 'Bugfixes available'+ : updateAvailable+ ? 'Update available'+ : 'Settings'+ }+ />+ );+};diff --git a/packages/studio/src/components/UpdateCheck.tsx b/packages/studio/src/components/UpdateCheck.tsxdeleted file mode 100644index fceea40657..0000000000--- a/packages/studio/src/components/UpdateCheck.tsx+++ /dev/null@@ -1,125 +0,0 @@-import React, {useCallback, useContext, useMemo, useState} from 'react';-import {- TRANSPARENT,- WARNING_COLOR,- WHITE,- WHITE_ALPHA_80,-} from '../helpers/colors';-import {SetSelectedModalContext} from '../state/modals';-import {useZIndex} from '../state/z-index';-import type {RenderInlineAction} from './InlineAction';-import {InlineAction} from './InlineAction';-import {useUpdateStatus} from './UpdateStatusContext';--const buttonStyle: React.CSSProperties = {- appearance: 'none',- border: 'none',- fontWeight: 'bold',- backgroundColor: TRANSPARENT,- cursor: 'pointer',- fontSize: 14,- display: 'inline-flex',- justifyContent: 'center',- marginLeft: 8,-};--const updateIconContainer: React.CSSProperties = {- alignItems: 'center',- display: 'flex',- flexShrink: 0,-};--export const UpdateCheck = () => {- const {setSelectedModal} = useContext(SetSelectedModalContext);- const {tabIndex} = useZIndex();- const {info, knownBugs} = useUpdateStatus();- const [hovered, setHovered] = useState(false);-- const hasBugfixesAvailable = useMemo(() => {- return Boolean(info?.updateAvailable && knownBugs && knownBugs.length > 0);- }, [info?.updateAvailable, knownBugs]);-- const openModal = useCallback(() => {- setSelectedModal({- type: 'settings',- initialTab: 'updates',- initialPublicLicenseKey:- window.remotion_renderDefaults?.publicLicenseKey ?? null,- });- }, [setSelectedModal]);-- const dynButtonStyle: React.CSSProperties = useMemo(() => {- return {- ...buttonStyle,- color: hovered- ? WHITE- : hasBugfixesAvailable- ? WARNING_COLOR- : WHITE_ALPHA_80,- };- }, [hasBugfixesAvailable, hovered]);-- const onPointerEnter = useCallback(() => {- setHovered(true);- }, []);-- const onPointerLeave = useCallback(() => {- setHovered(false);- }, []);-- const renderUpdateIcon: RenderInlineAction = useCallback((color) => {- return (- <svg- xmlns="http://www.w3.org/2000/svg"- style={{- height: 16,- width: 16,- color,- flexShrink: 0,- }}- viewBox="0 0 512 512"- >- <path- fill={color}- d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM135.1 217.4c-4.5 4.2-7.1 10.1-7.1 16.3c0 12.3 10 22.3 22.3 22.3H208v96c0 17.7 14.3 32 32 32h32c17.7 0 32-14.3 32-32V256h57.7c12.3 0 22.3-10 22.3-22.3c0-6.2-2.6-12.1-7.1-16.3L269.8 117.5c-3.8-3.5-8.7-5.5-13.8-5.5s-10.1 2-13.8 5.5L135.1 217.4z"- />- </svg>- );- }, []);-- if (!info) {- return null;- }-- if (!info.updateAvailable && !info.skillsUpdateAvailable) {- return null;- }-- if (!hasBugfixesAvailable) {- return (- <div style={updateIconContainer}>- <InlineAction- variant={null}- onClick={openModal}- renderAction={renderUpdateIcon}- unhoveredColor={WHITE_ALPHA_80}- title="Update available"- />- </div>- );- }-- return (- <button- tabIndex={tabIndex}- style={dynButtonStyle}- onClick={openModal}- onPointerEnter={onPointerEnter}- onPointerLeave={onPointerLeave}- type="button"- title="Bugfixes available"- >- Bugfixes available- </button>- );-};diff --git a/packages/studio/src/components/UpdatesSettings.tsx b/packages/studio/src/components/UpdatesSettings.tsxindex 731c38eca6..2c30670547 100644--- a/packages/studio/src/components/UpdatesSettings.tsx+++ b/packages/studio/src/components/UpdatesSettings.tsx@@ -200,7 +200,7 @@ const RenderedReleaseNotes: React.FC<{return (<><div style={releaseNotesTitle}>- {release.version}+ v{release.version}{formattedReleaseDate === null? null: ` \u2013\u00a0${formattedReleaseDate}`}@@ -225,7 +225,7 @@ const RenderedReleaseNotes: React.FC<{scrolling="no"srcDoc={document}style={{...releaseNotesFrame, height}}- title={`Release notes for Remotion ${release.version}`}+ title={`Release notes for Remotion v${release.version}`}/>)}</>@@ -390,7 +390,7 @@ export const UpdatesSettings: React.FC = () => {<div style={container}><div style={title}>You{"'re"} up to date.</div><div style={text}>- Remotion {info.currentVersion} and your Remotion Agent Skills are up+ Remotion v{info.currentVersion} and your Remotion Agent Skills are upto date.</div></div>@@ -399,14 +399,14 @@ export const UpdatesSettings: React.FC = () => {return (<div style={container}>+ {info.updateAvailable ? (+ <div style={title}>A new Remotion update is available.</div>+ ) : null}{info.updateAvailable && info.packageManager !== 'unknown' ? (- <div style={{paddingTop: 12}}>+ <div><ModalButton onClick={onUpgrade}>- Upgrade to {info.latestVersion}+ Upgrade to v{info.latestVersion}</ModalButton>- <div style={{...text, marginTop: 8}}>- You will need to restart Studio after upgrading.- </div></div>) : null}{upgradeError ? (@@ -419,7 +419,7 @@ export const UpdatesSettings: React.FC = () => {{hasKnownBugs && info.updateAvailable ? (<><div style={title}>- The currently installed version {info.currentVersion} has the+ The currently installed version v{info.currentVersion} has thefollowing known bugs:</div><KnownBugs bugs={knownBugs ?? []} />@@ -428,8 +428,7 @@ export const UpdatesSettings: React.FC = () => {</>) : info.updateAvailable ? (<div style={titleBeforeCommand}>- A new Remotion update is available. You can also run the following{' '}- {updateActionType}:+ You can also run the following {updateActionType}:</div>) : (<div style={titleBeforeCommand}>@@ -448,11 +447,7 @@ export const UpdatesSettings: React.FC = () => {</div>{info.updateAvailable ? (<div style={text}>- This will update Remotion from {info.currentVersion} to{' '}- {info.latestVersion}- {info.skillsUpdateAvailable- ? ' and update your project Remotion Agent Skills.'- : '.'}+ You{"'re"} currently running Remotion v{info.currentVersion}.</div>) : null}{info.updateAvailable ? (@@ -460,7 +455,7 @@ export const UpdatesSettings: React.FC = () => {releaseNotes.latestVersion === info.latestVersion ? (releaseNotes.releases.length === 0 ? (<>- <div style={releaseNotesTitle}>{info.latestVersion}</div>+ <div style={releaseNotesTitle}>v{info.latestVersion}</div><div style={text}>Release notes could not be loaded.{' '}<a