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

Grid advanced modal color/stretch tweaks #6559

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 12 additions & 6 deletions editor/src/components/inspector/controls/advanced-grid-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
separatorRadixSelectOption,
} from '../../../uuiui/radix-components'
import { optionalMap } from '../../../core/shared/optional-utils'
import type { FlexAlignment } from 'utopia-api/core'
import { FlexAlignment } from 'utopia-api/core'
import { FlexJustifyContent } from 'utopia-api/core'
import { GridAutoColsOrRowsControlInner } from '../grid-auto-cols-or-rows-control'
import { Substores, useEditorState, useRefEditorState } from '../../editor/store/store-hook'
Expand Down Expand Up @@ -79,12 +79,18 @@ export const AdvancedGridModal = React.memo((props: AdvancedGridModalProps) => {
[alignItemsLayoutInfo],
)

const contentOptions = [
const justifyOptions = [
unsetSelectOption,
separatorRadixSelectOption(),
...Object.values(FlexJustifyContent).map(selectOption),
]

const alignOptions = [
unsetSelectOption,
separatorRadixSelectOption(),
...Object.values(FlexAlignment).map(selectOption),
]

const onSubmitJustifyContent = React.useCallback(
(value: string) => {
if (value === 'unset') {
Expand Down Expand Up @@ -187,7 +193,7 @@ export const AdvancedGridModal = React.memo((props: AdvancedGridModalProps) => {
<RadixSelect
id='grid.justifyContent'
value={currentJustifyContentValue ?? unsetSelectOption}
options={contentOptions}
options={justifyOptions}
onValueChange={onSubmitJustifyContent}
contentClassName={`ignore-react-onclickoutside-${props.id}`}
contentStyle={{
Expand All @@ -205,7 +211,7 @@ export const AdvancedGridModal = React.memo((props: AdvancedGridModalProps) => {
<RadixSelect
id='grid.alignContent'
value={currentAlignContentValue ?? unsetSelectOption}
options={contentOptions}
options={alignOptions}
onValueChange={onSubmitAlignContent}
contentClassName={`ignore-react-onclickoutside-${props.id}`}
contentStyle={{
Expand Down Expand Up @@ -301,11 +307,11 @@ const justifyItemsOptions = itemsOptions('justify')
const alignItemsOptions = itemsOptions('align')
const rowVariant: GridRowVariant = '|--67px--|<--------1fr-------->'

function selectOption(value: FlexJustifyContent) {
function selectOption(value: FlexJustifyContent | FlexAlignment) {
return regularRadixSelectOption({
label: value.replace('-', ' '),
value: value,
placeholder: true,
placeholder: false,
})
}

Expand Down
2 changes: 2 additions & 0 deletions utopia-api/src/layout/flex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export enum FlexJustifyContent {
SpaceAround = 'space-around',
SpaceBetween = 'space-between',
SpaceEvenly = 'space-evenly',
Stretch = 'stretch',
}

export const AllFlexJustifyContents: Array<FlexJustifyContent> = [
Expand All @@ -224,6 +225,7 @@ export const AllFlexJustifyContents: Array<FlexJustifyContent> = [
FlexJustifyContent.SpaceAround,
FlexJustifyContent.SpaceBetween,
FlexJustifyContent.SpaceEvenly,
FlexJustifyContent.Stretch,
]

export enum FlexDirection {
Expand Down
Loading