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

feat: Add vertical alignment to ui.inline #1640

Closed
wants to merge 7 commits into from
11 changes: 8 additions & 3 deletions ui/src/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ interface Inline {
justify?: 'start' | 'end' | 'center' | 'between' | 'around'
/** Whether to display the components inset from the parent form, with a contrasting background. */
inset?: B
/** Add align prop to Inline component for all flexbox properties */
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'
}

/** Create a form. */
Expand Down Expand Up @@ -215,9 +217,10 @@ const
})

type XComponentAlignment = 'start' | 'end' | 'center' | 'between' | 'around'
type YComponentAlignment = 'start' | 'end' | 'center' | 'baseline' | 'stretch'

export const
XComponents = ({ items, alignment, inset }: { items: Component[], alignment?: XComponentAlignment, inset?: B }) => {
XComponents = ({ items, alignment, inset, align }: { items: Component[], alignment?: XComponentAlignment, inset?: B, align?: YComponentAlignment }) => {
const
components = items.map((m: any, i) => {
const
Expand All @@ -235,13 +238,15 @@ export const
</div>
)
})
return <div className={clas(alignment ? css.horizontal : css.vertical, inset ? css.inset : '')} style={{ justifyContent: justifications[alignment || ''] }}>{components}</div>
/** Add align prop to return statement */
return <div className={clas(alignment ? css.horizontal : css.vertical, inset ? css.inset : '', align ? css.align : '' )} style={{ justifyContent: justifications[alignment || ''] }}>{components}</div>
},
XInline = ({ model: m }: { model: Inline }) => (
<XComponents
items={m.items}
alignment={m.justify || 'start'}
alignment={m.justify || 'center'}
inset={m.inset}
align={m.align}
/>
)

Expand Down