Skip to content

Commit 7283a1d

Browse files
authored
Flex wrap control and tailwind (#6666)
**Problem:** Setting flex wrap doesn't work with tailwind projects. **Fix:** I added flexWrap to StyleInfo and to the inline style and tailwind plugins. After the flex wrap control in the inspector works. **Note:** This PR depends on #6668 , without that you can't set a flex-wrap property on elements which do not have it set yet. **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Play mode
1 parent a1c0308 commit 7283a1d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

editor/src/components/canvas/canvas-types.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { ReactElement } from 'react'
22
import type { JSExpression, PartOfJSXAttributeValue } from '../../core/shared/element-template'
3-
import { ElementInstanceMetadataMap } from '../../core/shared/element-template'
43
import type { PropertyPath, ElementPath } from '../../core/shared/project-file-types'
54
import type { KeysPressed } from '../../utils/keyboard'
65
import type { Modifiers } from '../../utils/modifiers'
7-
import { keepDeepReferenceEqualityIfPossible } from '../../utils/react-performance'
86
import type {
97
CanvasPoint,
108
CanvasRectangle,
@@ -16,20 +14,17 @@ import type {
1614
import type { EditorPanel } from '../common/actions/index'
1715
import type { Mode } from '../editor/editor-modes'
1816
import type { EditorState } from '../editor/store/editor-state'
19-
import { OriginalCanvasAndLocalFrame } from '../editor/store/editor-state'
20-
import { isFeatureEnabled } from '../../utils/feature-switches'
21-
import { assertNever, xor } from '../../core/shared/utils'
17+
import { assertNever } from '../../core/shared/utils'
2218
import type { LayoutTargetableProp } from '../../core/layout/layout-helpers-new'
2319
import type {
2420
DragInteractionData,
2521
InteractionSessionWithoutMetadata,
2622
} from './canvas-strategies/interaction-state'
27-
import { InteractionSession } from './canvas-strategies/interaction-state'
2823
import type { CanvasStrategyId } from './canvas-strategies/canvas-strategy-types'
2924
import type { MouseButtonsPressed } from '../../utils/mouse'
25+
import type { FlexWrap } from 'utopia-api/core'
3026
import type {
3127
CSSBorderRadius,
32-
CSSBorderRadiusIndividual,
3328
CSSNumber,
3429
CSSOverflow,
3530
CSSPadding,
@@ -604,6 +599,7 @@ export type PaddingSideInfo = CSSStyleProperty<CSSNumber>
604599
export type BorderRadiusInfo = CSSStyleProperty<CSSBorderRadius>
605600
export type BorderRadiusCornerInfo = CSSStyleProperty<CSSNumber>
606601
export type ZIndexInfo = CSSStyleProperty<CSSNumber>
602+
export type FlexWrapInfo = CSSStyleProperty<FlexWrap>
607603
export type OverflowInfo = CSSStyleProperty<CSSOverflow>
608604

609605
export interface StyleInfo {
@@ -627,6 +623,7 @@ export interface StyleInfo {
627623
borderBottomRightRadius: BorderRadiusCornerInfo | null
628624
borderBottomLeftRadius: BorderRadiusCornerInfo | null
629625
zIndex: ZIndexInfo | null
626+
flexWrap: FlexWrapInfo | null
630627
overflow: OverflowInfo | null
631628
}
632629

@@ -651,6 +648,7 @@ const emptyStyleInfo: StyleInfo = {
651648
borderBottomRightRadius: null,
652649
borderBottomLeftRadius: null,
653650
zIndex: null,
651+
flexWrap: null,
654652
overflow: null,
655653
}
656654

editor/src/components/canvas/plugins/inline-style-plugin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const InlineStylePlugin: StylePlugin = {
9090
element.props,
9191
)
9292
const zIndex = getPropertyFromInstance('zIndex', element.props)
93+
const flexWrap = getPropertyFromInstance('flexWrap', element.props)
9394

9495
const overflow = getPropertyFromInstance('overflow', element.props)
9596

@@ -114,6 +115,7 @@ export const InlineStylePlugin: StylePlugin = {
114115
borderBottomRightRadius: borderBottomRightRadius,
115116
borderBottomLeftRadius: borderBottomLeftRadius,
116117
zIndex: zIndex,
118+
flexWrap: flexWrap,
117119
overflow: overflow,
118120
}
119121
},

editor/src/components/canvas/plugins/tailwind-style-plugin.ts

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export const TailwindPlugin = (config: Config | null): StylePlugin => ({
183183
'borderBottomLeftRadius',
184184
),
185185
zIndex: parseTailwindProperty(mapping[TailwindPropertyMapping.zIndex], 'zIndex'),
186+
flexWrap: parseTailwindProperty(mapping[TailwindPropertyMapping.flexWrap], 'flexWrap'),
186187
overflow: parseTailwindProperty(mapping[TailwindPropertyMapping.overflow], 'overflow'),
187188
}
188189
},

0 commit comments

Comments
 (0)