diff --git a/editor/src/components/canvas/design-panel-root.tsx b/editor/src/components/canvas/design-panel-root.tsx index 7d007c4b982e..a698ebcb451e 100644 --- a/editor/src/components/canvas/design-panel-root.tsx +++ b/editor/src/components/canvas/design-panel-root.tsx @@ -35,6 +35,8 @@ import { EditorModes, isCommentMode } from '../editor/editor-modes' import { useAllowedToEditProject } from '../editor/store/collaborative-editing' import { useCanComment } from '../../core/commenting/comment-hooks' import { ElementsOutsideVisibleAreaIndicator } from '../editor/elements-outside-visible-area-indicator' +import { isFeatureEnabled } from '../../utils/feature-switches' +import { RollYourOwnFeaturesPane } from '../navigator/left-pane/roll-your-own-pane' function isCodeEditorEnabled(): boolean { if (typeof window !== 'undefined') { @@ -158,6 +160,10 @@ export const RightPane = React.memo((props) => { onClickTab(RightMenuTab.Settings) }, [onClickTab]) + const onClickRollYourOwnTab = React.useCallback(() => { + onClickTab(RightMenuTab.RollYourOwn) + }, [onClickTab]) + const canComment = useCanComment() const allowedToEdit = useAllowedToEditProject() @@ -219,6 +225,14 @@ export const RightPane = React.memo((props) => { selected={selectedTab === RightMenuTab.Settings} onClick={onClickSettingsTab} /> + {when( + isFeatureEnabled('Roll Your Own'), + , + )} ((props) => { {when(selectedTab === RightMenuTab.Inspector, )} {when(selectedTab === RightMenuTab.Settings, )} {when(selectedTab === RightMenuTab.Comments, )} + {when(selectedTab === RightMenuTab.RollYourOwn, )} diff --git a/editor/src/components/editor/store/editor-state.ts b/editor/src/components/editor/store/editor-state.ts index 20e3549badea..4e2eeee82bc3 100644 --- a/editor/src/components/editor/store/editor-state.ts +++ b/editor/src/components/editor/store/editor-state.ts @@ -214,6 +214,7 @@ export enum RightMenuTab { Inspector = 'inspector', Settings = 'settings', Comments = 'comments', + RollYourOwn = 'roll-your-own', } // TODO: this should just contain an NpmDependency and a status diff --git a/editor/src/components/navigator/left-pane/roll-your-own-pane.tsx b/editor/src/components/navigator/left-pane/roll-your-own-pane.tsx new file mode 100644 index 000000000000..5a29e338b287 --- /dev/null +++ b/editor/src/components/navigator/left-pane/roll-your-own-pane.tsx @@ -0,0 +1,132 @@ +import React from 'react' +import { FlexColumn, FlexRow, Section } from '../../../uuiui' +import { when } from '../../../utils/react-conditionals' +import { atom, useAtom } from 'jotai' +import { UIGridRow } from '../../inspector/widgets/ui-grid-row' +import { atomWithStorage } from 'jotai/utils' +import { IS_TEST_ENVIRONMENT } from '../../../common/env-vars' + +const sections = ['Grid'] as const +type Section = (typeof sections)[number] + +type GridFeatures = { + foo: boolean +} + +type RollYourOwnFeaturesTypes = { + Grid: GridFeatures +} + +type RollYourOwnFeatures = { + [K in Section]: RollYourOwnFeaturesTypes[K] +} + +let defaultRollYourOwnFeatures: RollYourOwnFeatures = { + Grid: { + foo: true, + }, +} + +const ROLL_YOUR_OWN_FEATURES_KEY: string = 'roll-your-own-features' + +export const rollYourOwnFeatures = IS_TEST_ENVIRONMENT + ? atom(defaultRollYourOwnFeatures) + : atomWithStorage(ROLL_YOUR_OWN_FEATURES_KEY, defaultRollYourOwnFeatures) + +export const RollYourOwnFeaturesPane = React.memo(() => { + const [currentSection, setCurrentSection] = React.useState
(null) + + const onChangeSection = React.useCallback((e: React.ChangeEvent) => { + const maybeSectionValue = e.target.value as Section + if (sections.includes(maybeSectionValue)) { + setCurrentSection(maybeSectionValue) + } else { + setCurrentSection(null) + } + }, []) + + return ( + +
+ + Roll Your Own + + + + + + {when(currentSection === 'Grid', )} +
+
+ ) +}) +RollYourOwnFeaturesPane.displayName = 'RollYourOwnFeaturesPane' + +const GridSection = React.memo(() => { + const [features, setFeatures] = useAtom(rollYourOwnFeatures) + + const onChange = React.useCallback( + (feat: keyof GridFeatures) => (e: React.ChangeEvent) => { + setFeatures((existing) => { + return { + ...existing, + Grid: { + ...existing.Grid, + [feat]: e.target.checked, + }, + } + }) + }, + [setFeatures], + ) + + return ( + + {Object.entries(features.Grid).map(([feat, value]) => { + return ( + +
{feat}
+ {when( + typeof value === 'boolean', + , + )} +
+ ) + })} +
+ ) +}) +GridSection.displayName = 'GridSection' diff --git a/editor/src/utils/feature-switches.ts b/editor/src/utils/feature-switches.ts index 88d2b5b74c45..4d48a1772df5 100644 --- a/editor/src/utils/feature-switches.ts +++ b/editor/src/utils/feature-switches.ts @@ -15,6 +15,7 @@ export type FeatureName = | 'Debug - Print UIDs' | 'Debug – Connections' | 'Condensed Navigator Entries' + | 'Roll Your Own' export const AllFeatureNames: FeatureName[] = [ // 'Dragging Reparents By Default', // Removing this option so that we can experiment on this later @@ -30,6 +31,7 @@ export const AllFeatureNames: FeatureName[] = [ 'Debug - Print UIDs', 'Debug – Connections', 'Condensed Navigator Entries', + 'Roll Your Own', ] let FeatureSwitches: { [feature in FeatureName]: boolean } = { @@ -45,6 +47,7 @@ let FeatureSwitches: { [feature in FeatureName]: boolean } = { 'Debug - Print UIDs': false, 'Debug – Connections': false, 'Condensed Navigator Entries': !IS_TEST_ENVIRONMENT, + 'Roll Your Own': false, } export const STEGANOGRAPHY_ENABLED = false