🎥 Make videos programmatically with React
collapse button working
Patric Salvisbergd69b76ea1a3a
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsxindex 20bf782b14..cdc89135b4 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModalData.tsx@@ -24,6 +24,7 @@ import {NoDefaultProps,NoSchemaDefined,} from './SchemaEditor/SchemaErrorMessages';+import {WarningIndicatorButton} from './WarningIndicatorButton';type Mode = 'json' | 'schema';@@ -62,6 +63,7 @@ const tabWrapper: React.CSSProperties = {display: 'flex',marginBottom: '4px',flexDirection: 'row',+ alignItems: 'center',};const spacer: React.CSSProperties = {@@ -90,7 +92,7 @@ export const RenderModalData: React.FC<{const zodValidationResult = useMemo(() => {return composition.schema.safeParse(inputProps);}, [composition.schema, inputProps]);-+ const [showWarning, setShowWarning] = useState<boolean>(true);const cliProps = getInputProps();const [canSaveDefaultProps, setCanSaveDefaultProps] =useState<TypeCanSaveState>({@@ -167,6 +169,21 @@ export const RenderModalData: React.FC<{const connectionStatus = useContext(PreviewServerConnectionCtx).type;+ const warningCount = useMemo(() => {+ let count = 0;+ if (Object.keys(cliProps).length > 0) {+ count += 1;+ }++ if (+ canSaveDefaultProps.canUpdate === false &&+ canSaveDefaultProps.determined+ ) {+ count += 1;+ }++ return count;+ }, [canSaveDefaultProps, cliProps]);if (connectionStatus === 'disconnected') {return (<div style={explainer}>@@ -197,8 +214,13 @@ export const RenderModalData: React.FC<{<div style={tabWrapper}><SegmentedControl items={modeItems} needsWrapping={false} /><div style={spacer} />+ <WarningIndicatorButton+ setShowWarning={setShowWarning}+ showWarning={showWarning}+ warningCount={warningCount}+ /></div>- {Object.keys(cliProps).length > 0 ? (+ {Object.keys(cliProps).length > 0 && showWarning ? (<><Spacing y={1} /><ValidationMessage@@ -208,7 +230,8 @@ export const RenderModalData: React.FC<{/></>) : null}- {canSaveDefaultProps.canUpdate === false &&+ {showWarning &&+ canSaveDefaultProps.canUpdate === false &&canSaveDefaultProps.determined ? (<><Spacing y={1} />diff --git a/packages/cli/src/editor/components/RenderModal/WarningIndicatorButton.tsx b/packages/cli/src/editor/components/RenderModal/WarningIndicatorButton.tsxnew file mode 100644index 0000000000..122a9f3c12--- /dev/null+++ b/packages/cli/src/editor/components/RenderModal/WarningIndicatorButton.tsx@@ -0,0 +1,49 @@+import type {SVGProps} from 'react';+import React from 'react';+import {LIGHT_TEXT, WARNING_COLOR} from '../../helpers/colors';+import {Spacing} from '../layout';++const buttonStyle: React.CSSProperties = {+ height: '20px',+ width: '30px',+ fontSize: 10,+ display: 'inline-flex',+ justifyContent: 'center',+ alignItems: 'center',+ backgroundColor: 'transparent',+ color: LIGHT_TEXT,+ border: 'none',+ cursor: 'pointer',+};++const triangleStyle: React.CSSProperties = {+ width: 11,+ height: 11,+ flexShrink: 0,+ fill: WARNING_COLOR,+};+const WarningTriangle: React.FC<SVGProps<SVGSVGElement>> = (props) => {+ return (+ <svg viewBox="0 0 576 512" {...props}>+ <path d="M248.747 204.705l6.588 112c.373 6.343 5.626 11.295 11.979 11.295h41.37a12 12 0 0 0 11.979-11.295l6.588-112c.405-6.893-5.075-12.705-11.979-12.705h-54.547c-6.903 0-12.383 5.812-11.978 12.705zM330 384c0 23.196-18.804 42-42 42s-42-18.804-42-42 18.804-42 42-42 42 18.804 42 42zm-.423-360.015c-18.433-31.951-64.687-32.009-83.154 0L6.477 440.013C-11.945 471.946 11.118 512 48.054 512H527.94c36.865 0 60.035-39.993 41.577-71.987L329.577 23.985zM53.191 455.002L282.803 57.008c2.309-4.002 8.085-4.002 10.394 0l229.612 397.993c2.308 4-.579 8.998-5.197 8.998H58.388c-4.617.001-7.504-4.997-5.197-8.997z" />+ </svg>+ );+};++export const WarningIndicatorButton: React.FC<{+ setShowWarning: React.Dispatch<React.SetStateAction<boolean>>;+ showWarning: boolean;+ warningCount: number;+}> = ({setShowWarning, showWarning, warningCount}) => {+ const onClick = () => {+ setShowWarning(!showWarning);+ };++ return (+ <button type={'button'} style={buttonStyle} onClick={onClick}>+ {warningCount}+ <Spacing x={0.5} />+ <WarningTriangle style={triangleStyle} />+ </button>+ );+};