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

Icons for grid autoflow dropdown #6214

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 28 additions & 1 deletion editor/src/components/inspector/common/css-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import type { ParseError } from '../../../utils/value-parser-utils'
import { descriptionParseError } from '../../../utils/value-parser-utils'
import * as csstree from 'css-tree'
import { expandCssTreeNodeValue, parseCssTreeNodeValue } from './css-tree-utils'
import type { IcnProps } from '../../../uuiui'

var combineRegExp = function (regexpList: Array<RegExp | string>, flags?: string) {
let source: string = ''
Expand Down Expand Up @@ -982,9 +983,35 @@ export function parseGridPosition(
}
}

export const GridAutoFlowValues = ['row', 'column', 'dense', 'row dense', 'column dense'] as const
export const GridAutoFlowValues = ['dense', 'column', 'column dense', 'row', 'row dense'] as const
export type GridAutoFlow = (typeof GridAutoFlowValues)[number]

export function gridAutoFlowIcon(value: GridAutoFlow): IcnProps {
switch (value) {
case 'column':
case 'column dense':
return {
category: 'inspector-element',
type: 'arrowDown',
color: 'black',
width: 16,
height: 16,
}
case 'dense':
case 'row':
case 'row dense':
return {
category: 'inspector-element',
type: 'arrowRight',
color: 'black',
width: 16,
height: 16,
}
default:
assertNever(value)
}
}

export function parseGridAutoFlow(rawValue: string): GridAutoFlow | null {
if (GridAutoFlowValues.some((v) => v === rawValue)) {
return rawValue as GridAutoFlow
Expand Down
2 changes: 2 additions & 0 deletions editor/src/components/inspector/flex-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
cssKeyword,
cssNumber,
cssNumberToString,
gridAutoFlowIcon,
gridCSSKeyword,
gridCSSNumber,
isCSSKeyword,
Expand Down Expand Up @@ -828,6 +829,7 @@ const AutoFlowPopupId = 'auto-flow-control'
const selectOption = (value: GridAutoFlow | 'unset'): SelectOption => ({
label: value,
value: value,
icon: value === 'unset' ? undefined : gridAutoFlowIcon(value),
})

const GRID_AUTO_FLOW_DROPDOWN_OPTIONS: Array<SelectOption> = GridAutoFlowValues.map(selectOption)
Expand Down
Loading