Skip to content

Commit 50fbb25

Browse files
laraharrowLuke Bowerman
andauthored
update width from InputText (#794)
* update width from InputText * Full-width fields * A few more tweaks to get to 100% width consistently Co-authored-by: Luke Bowerman <[email protected]>
1 parent 7062ede commit 50fbb25

File tree

15 files changed

+426
-496
lines changed

15 files changed

+426
-496
lines changed

packages/components/src/Form/Fields/Field.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { ResponsiveValue, TLengthStyledSystem } from 'styled-system'
3030
import { CustomizableAttributes, SpacingSizes } from '@looker/design-tokens'
3131
import omit from 'lodash/omit'
3232
import pick from 'lodash/pick'
33-
import { InputText, Select } from '../Inputs'
3433
import { inputHeight } from '../Inputs/InputText/InputText'
3534
import { Label } from '../Label/Label'
3635
import { Paragraph } from '../../Text/Paragraph'
@@ -70,11 +69,14 @@ export interface FieldProps extends FieldBaseProps {
7069

7170
/**
7271
* Specifies for horizontally aligned labels how much space to take up.
72+
* @default '150px'
7373
*/
7474
labelWidth?: ResponsiveSpaceValue
75+
7576
/**
7677
*
77-
* Specify the width of the FieldText if different then 13rem
78+
* Specify the width of the FieldText if different then 100%
79+
* @default '100%'
7880
*/
7981
width?: ResponsiveSpaceValue
8082
}
@@ -157,6 +159,8 @@ export const Field = styled(FieldLayout)`
157159
inline
158160
? '"label input detail" ". messages messages"'
159161
: '"label detail" "input input" "messages messages"'};
162+
grid-template-columns: ${({ inline, labelWidth }) =>
163+
inline ? `${labelWidth} 1fr` : undefined};
160164
161165
${InputArea} {
162166
display: flex;
@@ -167,14 +171,6 @@ export const Field = styled(FieldLayout)`
167171
grid-area: messages;
168172
}
169173
170-
${InputText} {
171-
width: ${({ width }) => width};
172-
}
173-
174-
${Select} {
175-
width: 100%;
176-
}
177-
178174
${Label} {
179175
grid-area: label;
180176
@@ -186,13 +182,13 @@ export const Field = styled(FieldLayout)`
186182
justify-self: end;
187183
height: ${inputHeight};
188184
padding-right: ${theme.space.small};
189-
width: 150px;
190185
`
191186
: `
192187
padding-bottom: ${theme.space.xsmall};
193188
194189
`}
195190
}
191+
196192
${FieldDetail} {
197193
grid-area: detail;
198194
justify-self: end;
@@ -210,3 +206,5 @@ export const Field = styled(FieldLayout)`
210206
margin-top: ${({ theme }) => theme.space.xsmall};
211207
}
212208
`
209+
210+
Field.defaultProps = { labelWidth: '150px', width: '100%' }

0 commit comments

Comments
 (0)