@@ -28,8 +28,7 @@ import type {
2828 FormFieldStyleProps
2929} from './props'
3030import type { FormFieldLayoutTheme } from '@instructure/shared-types'
31- // TODO If the label is invisible the top gap is too large
32- // TODO DateTimeInput renders empty messages, these leave too large gaps too
31+
3332/**
3433 * ---
3534 * private: true
@@ -45,7 +44,7 @@ const generateStyle = (
4544 props : FormFieldLayoutProps ,
4645 styleProps : FormFieldStyleProps
4746) : FormFieldLayoutStyle => {
48- const { inline, layout } = props
47+ const { inline, layout, vAlign } = props
4948 const { hasMessages, hasVisibleLabel } = styleProps
5049 // This is quite ugly, we should simplify it
5150 const inlineContainerAndLabel = layout === 'inline' && ! inline
@@ -77,7 +76,7 @@ const generateStyle = (
7776 fontWeight : componentTheme . fontWeight ,
7877 fontSize : componentTheme . fontSize ,
7978 lineHeight : componentTheme . lineHeight ,
80- margin : 0 ,
79+ margin : '0 0 0.75rem 0' ,
8180 textAlign : inlineContainerAndLabel ? 'end' : 'start' ,
8281 ...( isInlineLayout &&
8382 inline && {
@@ -95,6 +94,14 @@ const generateStyle = (
9594 }
9695 }
9796
97+ let alignItems = 'start'
98+ if ( vAlign == 'top' ) {
99+ alignItems = 'start'
100+ } else if ( vAlign == 'middle' ) {
101+ alignItems = 'center'
102+ } else if ( vAlign == 'bottom' ) {
103+ alignItems = 'end'
104+ }
98105 return {
99106 formFieldLayout : {
100107 label : 'formFieldLayout' ,
@@ -107,6 +114,7 @@ const generateStyle = (
107114 textAlign : 'start' ,
108115 opacity : 'inherit' ,
109116 display : 'grid' ,
117+ alignItems : alignItems ,
110118 gridTemplateColumns : gridTemplateColumns ,
111119 gridTemplateAreas : gridTemplateAreas ,
112120 [ `@media screen and (max-width: ${ componentTheme . stackedOrInlineBreakpoint } )` ] :
@@ -119,19 +127,10 @@ const generateStyle = (
119127 gridTemplateColumns : '100%'
120128 } )
121129 } ,
122- [ `@media screen and (min-width: ${ componentTheme . stackedOrInlineBreakpoint } )` ] :
123- {
124- ...( isInlineLayout &&
125- inline && {
126- textAlign : 'end' // TODO this is a bug, remove it!
127- } )
128- } ,
129- rowGap : '0.75rem' ,
130130 columnGap : '0.375rem' ,
131131 width : '100%' ,
132132 ...( inline && {
133133 display : 'inline-grid' ,
134- verticalAlign : 'middle' ,
135134 width : 'auto'
136135 } )
137136 } ,
@@ -147,7 +146,7 @@ const generateStyle = (
147146 formFieldChildren : {
148147 label : 'formFieldLayout__children' ,
149148 gridArea : 'controls' ,
150- alignSelf : 'center' ,
149+ ... ( hasMessages && { marginBottom : '0.75rem' } ) ,
151150 ...( isInlineLayout &&
152151 inline && {
153152 [ `@media screen and (min-width: ${ componentTheme . stackedOrInlineBreakpoint } )` ] :
0 commit comments