Skip to content

Commit

Permalink
Remove unnecessary props from StyleInfoFactory context param (#6634)
Browse files Browse the repository at this point in the history
## Problem
`metadata` and `elementPathTree` are required by the context param of
`StylePlugin.styleInfoFactory`, but they weren't used by the plugins.
Because of this, having to pass `metadata` and `elementPathTree` in the
context param created unnecessary boilerplate

## Fix
Remove `metadata` and `elementPathTree` from the context param of
`StylePlugin.styleInfoFactory`, but keep the context param itself so
other data can be added to the context later on.
  • Loading branch information
bkrmendy authored Nov 13, 2024
1 parent 9e34bde commit f196d14
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ export function pickCanvasStateFromEditorState(
propertyControlsInfo: editorState.propertyControlsInfo,
styleInfoReader: activePlugin.styleInfoFactory({
projectContents: editorState.projectContents,
metadata: editorState.jsxMetadata,
elementPathTree: editorState.elementPathTree,
}),
}
}
Expand Down Expand Up @@ -254,8 +252,6 @@ export function pickCanvasStateFromEditorStateWithMetadata(
propertyControlsInfo: editorState.propertyControlsInfo,
styleInfoReader: activePlugin.styleInfoFactory({
projectContents: editorState.projectContents,
metadata: metadata,
elementPathTree: editorState.elementPathTree,
}),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ export type StyleInfoReader = (elementPath: ElementPath) => StyleInfo | null

export type StyleInfoFactory = (context: {
projectContents: ProjectContentTreeRoot
metadata: ElementInstanceMetadataMap
elementPathTree: ElementPathTrees
}) => StyleInfoReader

export interface InteractionCanvasState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export const runAdjustCssLengthProperties = (

const styleInfoReader = getActivePlugin(withConflictingPropertiesRemoved).styleInfoFactory({
projectContents: withConflictingPropertiesRemoved.projectContents,
metadata: withConflictingPropertiesRemoved.jsxMetadata,
elementPathTree: withConflictingPropertiesRemoved.elementPathTree,
})

const styleInfo = styleInfoReader(command.target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ export const FlexGapControl = controlForStrategyMemoized<FlexGapControlProps>((p
maybeFlexGapData(
getActivePlugin(store.editor).styleInfoFactory({
projectContents: store.editor.projectContents,
metadata: metadata,
elementPathTree: store.editor.elementPathTree,
})(selectedElement),
MetadataUtils.findElementByElementPath(store.editor.jsxMetadata, selectedElement),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export const SubduedFlexGapControl = React.memo<SubduedFlexGapControlProps>((pro
maybeFlexGapData(
getActivePlugin(store.editor).styleInfoFactory({
projectContents: store.editor.projectContents,
metadata: store.editor.jsxMetadata,
elementPathTree: store.editor.elementPathTree,
})(selectedElement),
MetadataUtils.findElementByElementPath(store.editor.jsxMetadata, selectedElement),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ function getStyleInfoFromInlineStyle(editor: EditorRenderResult) {
const { jsxMetadata, projectContents, elementPathTree } = editor.getEditorState().editor

const styleInfoReader = InlineStylePlugin.styleInfoFactory({
metadata: jsxMetadata,
projectContents: projectContents,
elementPathTree: elementPathTree,
})
const styleInfo = styleInfoReader(EP.fromString('sb/scene/div'))
return styleInfo
Expand Down
2 changes: 0 additions & 2 deletions editor/src/components/canvas/plugins/style-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ function getPropertiesToZero(
export function patchRemovedProperties(editorState: EditorState): EditorState {
const styleInfoReader = getActivePlugin(editorState).styleInfoFactory({
projectContents: editorState.projectContents,
metadata: editorState.jsxMetadata,
elementPathTree: editorState.elementPathTree,
})

const propertiesUpdatedDuringInteraction = getPropertiesUpdatedDuringInteraction(editorState)
Expand Down

0 comments on commit f196d14

Please sign in to comment.