-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tailwind-compatible flex section: round 1 (#6650)
## Problem The controls to set `justify-contents`, `align-items` and `flex-direction` don't work with Tailwind ## Fix - Add the necessary class names to `TailwindClassNameMapping`, so that the Tailwind style plugin can write these classes. These controls read props from `specialSizeMeasurements`, so I'm leaving `StyleInfo` unchanged in this PR, and add the flex-related classes I added to `TailwindClassNameMapping` when something actually needs to read them through `StyleInfo`. - Add tests for Tailwind editing in the affected controls ### Commit Details - Add the necessary class names to `TailwindClassNameMapping` - Add tests for `NineBlockControl` (used to set `justify-contents` and `align-items`) - Add tests for `ThreebarControl` (used to set `align-items` when `justify-contents` is set to `space-between`) - Add tests for `SpacedPackedControls` (sets `justify-contents` to either `space-between` for spaced or to `flex-start` for `packed`) - Add tests for `FlexDirectionToggle` (used to set flex direction) ### Out of scope There are two other controls in the flex section, used for setting `flex-wrap` and `flex-gap`. These controls use `useInspectorInfo` under the hood, making that work is left to a follow-up PR ## 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
- Loading branch information
Showing
6 changed files
with
274 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
editor/src/components/inspector/sections/flex-section.test-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { TailwindConfigPath } from '../../../core/tailwind/tailwind-config' | ||
import { createModifiedProject } from '../../../sample-projects/sample-project-utils.test-utils' | ||
import { StoryboardFilePath } from '../../editor/store/editor-state' | ||
|
||
export const JustifyContentClassMapping = { | ||
'flex-start': 'justify-start', | ||
center: 'justify-center', | ||
'flex-end': 'justify-end', | ||
} as const | ||
|
||
export const AlignItemsClassMapping = { | ||
'flex-start': 'items-start', | ||
center: 'items-center', | ||
'flex-end': 'items-end', | ||
} as const | ||
|
||
export const TailwindProject = (classes: string) => | ||
createModifiedProject({ | ||
[StoryboardFilePath]: ` | ||
import React from 'react' | ||
import { Scene, Storyboard } from 'utopia-api' | ||
export var storyboard = ( | ||
<Storyboard data-uid='sb'> | ||
<Scene | ||
id='scene' | ||
commentId='scene' | ||
data-uid='scene' | ||
style={{ | ||
width: 700, | ||
height: 759, | ||
position: 'absolute', | ||
left: 212, | ||
top: 128, | ||
}} | ||
> | ||
<div | ||
data-uid='mydiv' | ||
data-testid='mydiv' | ||
className='top-10 left-10 w-64 h-64 bg-slate-100 absolute ${classes}' | ||
> | ||
<div className='bg-red-500 w-10 h-10' data-uid='child-1' /> | ||
<div className='bg-red-500 w-10 h-10' data-uid='child-2' /> | ||
</div> | ||
</Scene> | ||
</Storyboard> | ||
) | ||
`, | ||
[TailwindConfigPath]: ` | ||
const TailwindConfig = { } | ||
export default TailwindConfig | ||
`, | ||
'app.css': ` | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities;`, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.