Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental: Advanced style panel mode #4840

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/builder/app/builder/features/inspector/inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { getInstanceLabel } from "~/shared/instance-utils";
import { BindingPopoverProvider } from "~/builder/shared/binding-popover";
import { $activeInspectorPanel } from "~/builder/shared/nano-states";
import { $selectedInstance, $selectedPage } from "~/shared/awareness";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";

const InstanceInfo = ({ instance }: { instance: Instance }) => {
const metas = useStore($registeredComponentMetas);
Expand Down Expand Up @@ -177,7 +176,7 @@ export const Inspector = ({ navigatorLayout }: InspectorProps) => {
}}
>
<InstanceInfo instance={selectedInstance} />
{isFeatureEnabled("stylePanelModes") && <ModeMenu />}
<ModeMenu />
</Flex>
<StylePanel />
</PanelTabsContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
} from "~/shared/nano-states";
import { useClientSupports } from "~/shared/client-supports";
import { $selectedInstancePath } from "~/shared/awareness";
import { $settings } from "~/builder/shared/client-settings";

// Only here to keep the same section module interface
export const properties = [];
Expand Down Expand Up @@ -381,8 +382,16 @@ const $advancedProperties = computed(
$styleSourceSelections,
$matchingBreakpoints,
$styles,
$settings,
],
(instancePath, metas, styleSourceSelections, matchingBreakpoints, styles) => {
(
instancePath,
metas,
styleSourceSelections,
matchingBreakpoints,
styles,
settings
) => {
if (instancePath === undefined) {
return [];
}
Expand All @@ -402,6 +411,11 @@ const $advancedProperties = computed(
}
const advancedProperties = new Set<StyleProperty>(initialProperties);
for (const { property, listed } of definedStyles) {
// In advanced mode we show all defined properties
if (settings.stylePanelMode === "advanced") {
advancedProperties.add(property);
continue;
}
// exclude properties from style panel UI unless edited in advanced section
if (baseProperties.has(property) === false || listed) {
advancedProperties.add(property);
Expand Down
21 changes: 17 additions & 4 deletions apps/builder/app/builder/features/style-panel/style-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
type Settings,
} from "~/builder/shared/client-settings";
import { useState } from "react";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";

const $selectedInstanceTag = computed(
[$selectedInstance, $instanceTags],
Expand Down Expand Up @@ -83,10 +84,15 @@ export const ModeMenu = () => {
<Text>Focus mode</Text> <Kbd value={["alt", "shift", "s"]} />
</Flex>
</DropdownMenuRadioItem>
{/*
<DropdownMenuRadioItem value="advanced" icon={<MenuCheckedIcon />}>
Advanced mode
</DropdownMenuRadioItem> */}
{isFeatureEnabled("stylePanelAdvancedMode") && (
<DropdownMenuRadioItem
value="advanced"
icon={<MenuCheckedIcon />}
onFocus={() => setFocusedValue("advanced")}
>
Advanced mode
</DropdownMenuRadioItem>
)}
</DropdownMenuRadioGroup>
<DropdownMenuSeparator />

Expand All @@ -100,6 +106,9 @@ export const ModeMenu = () => {
Only one section is open at a time.
</DropdownMenuItem>
)}
{focusedValue === "advanced" && (
<DropdownMenuItem hint>Advanced section only.</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
);
Expand Down Expand Up @@ -128,6 +137,10 @@ export const StylePanel = () => {
const all = [];

for (const [category, { Section }] of sections.entries()) {
// In advanced mode we only need to show advanced panel
if (stylePanelMode === "advanced" && category !== "advanced") {
continue;
}
// show flex child UI only when parent is flex or inline-flex
if (category === "flexChild" && displayValue.includes("flex") === false) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion packages/feature-flags/src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const staticExport = false;
export const contentEditableMode = false;
export const command = false;
export const headSlotComponent = false;
export const stylePanelModes = false;
export const stylePanelAdvancedMode = false;