Skip to content

Commit 2fd17f8

Browse files
Merge pull request #371 from storybookjs/update/form-icon-scale
Increase size of icons in standard form elements
2 parents 98ff821 + e952046 commit 2fd17f8

2 files changed

Lines changed: 11218 additions & 11551 deletions

File tree

src/components/Input.tsx

Lines changed: 91 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -106,99 +106,126 @@ const getStackLevelStyling = (props: Pick<Props, 'error' | 'stackLevel'>) => {
106106
};
107107

108108
// prettier-ignore
109-
const InputWrapper = styled.div<Pick<Props, 'error' | 'stackLevel' | 'appearance' | 'startingType' | 'icon'>>`
109+
const InputWrapper = styled.div<
110+
Pick<Props, 'error' | 'stackLevel' | 'appearance' | 'startingType' | 'icon'>
111+
>`
110112
display: inline-block;
111113
position: relative;
112114
vertical-align: top;
113115
width: 100%;
114116
115117
${InputEl} {
116118
position: relative;
117-
${props => getStackLevelStyling(props)}
119+
${(props) => getStackLevelStyling(props)}
118120
119121
background: ${color.lightest};
120122
color: ${color.darkest};
121123
font-size: ${typography.size.s2}px;
122124
line-height: 20px;
123125
padding: 10px 15px; //40px tall
124126
box-shadow: ${color.border} 0 0 0 1px inset;
125-
&:focus { box-shadow: ${color.secondary} 0 0 0 1px inset; }
126-
127-
128-
${props => props.appearance === 'pill' && css`
129-
font-size: ${typography.size.s1}px;
130-
line-height: 16px;
131-
padding: 6px 12px; //28px tall
132-
border-radius: 3em;
133-
background: transparent;
134-
`}
135-
136-
${props => props.appearance === 'code' && css`
137-
font-size: ${typography.size.s1 - 1}px;
138-
line-height: 16px;
139-
font-family: ${typography.type.code};
140-
border-radius: ${spacing.borderRadius.small}px;
141-
background: ${color.lightest};
142-
padding: 8px 10px;
143-
`}
144-
}
145-
146-
${props => props.startingType === 'password' && css`
147-
${InputEl} {
148-
padding-right: 52px;
127+
&:focus {
128+
box-shadow: ${color.secondary} 0 0 0 1px inset;
149129
}
150-
`}
151130
152-
${props => props.icon && css`
153-
> svg {
154-
transition: all 150ms ease-out;
155-
position: absolute;
156-
top: 50%;
157-
${props.appearance === 'pill' || props.appearance === 'code' ? css`
131+
${(props) =>
132+
props.appearance === 'pill' &&
133+
css`
158134
font-size: ${typography.size.s1}px;
159-
` : css `
160-
font-size: ${typography.size.s2}px;
135+
line-height: 16px;
136+
padding: 6px 12px; //28px tall
137+
border-radius: 3em;
138+
background: transparent;
161139
`}
162-
height: 12px;
163-
width: 12px;
164-
margin-top: -6px;
165-
z-index: 3;
166-
${props.appearance === 'pill' || props.appearance === 'code' ? css`
167-
left: 10px;
168-
` : css `
169-
left: ${props.appearance === 'tertiary' ? 0 : `15px` };
140+
141+
${(props) =>
142+
props.appearance === 'code' &&
143+
css`
144+
font-size: ${typography.size.s1 - 1}px;
145+
line-height: 16px;
146+
font-family: ${typography.type.code};
147+
border-radius: ${spacing.borderRadius.small}px;
148+
background: ${color.lightest};
149+
padding: 8px 10px;
170150
`}
151+
}
171152
172-
background: transparent;
153+
${(props) =>
154+
props.startingType === 'password' &&
155+
css`
156+
${InputEl} {
157+
padding-right: 52px;
158+
}
159+
`}
173160
174-
path {
161+
${(props) =>
162+
props.icon &&
163+
css`
164+
> svg {
175165
transition: all 150ms ease-out;
176-
fill: ${color.mediumdark};
166+
position: absolute;
167+
top: 50%;
168+
${props.appearance === 'pill' || props.appearance === 'code'
169+
? css`
170+
font-size: ${typography.size.s1}px;
171+
height: 12px;
172+
margin-top: -6px;
173+
width: 12px;
174+
`
175+
: css`
176+
font-size: ${typography.size.s2}px;
177+
height: 14px;
178+
margin-top: -7px;
179+
width: 14px;
180+
`}
181+
z-index: 3;
182+
${props.appearance === 'pill' || props.appearance === 'code'
183+
? css`
184+
left: 10px;
185+
`
186+
: css`
187+
left: ${props.appearance === 'tertiary' ? 0 : `15px`};
188+
`}
189+
190+
background: transparent;
191+
192+
path {
193+
transition: all 150ms ease-out;
194+
fill: ${color.mediumdark};
195+
}
177196
}
178-
}
179197
180-
${InputEl}:focus + svg path {
181-
fill: ${color.darker};
182-
}
198+
${InputEl}:focus + svg path {
199+
fill: ${color.darker};
200+
}
183201
184-
${InputEl} {
185-
padding-left: 40px;
202+
${InputEl} {
203+
padding-left: 40px;
186204
187-
${(props.appearance === 'pill' || props.appearance === 'code') && css` padding-left: 30px; `};
188-
}
189-
`}
205+
${(props.appearance === 'pill' || props.appearance === 'code') &&
206+
css`
207+
padding-left: 30px;
208+
`};
209+
}
210+
`}
190211
191-
${props => props.error && css`
192-
${InputEl} {
212+
${(props) =>
213+
props.error &&
214+
css`
215+
${InputEl} {
193216
box-shadow: ${color.red} 0 0 0 1px inset;
194-
&:focus { box-shadow: ${color.red} 0 0 0 1px inset !important; }
195-
}
217+
&:focus {
218+
box-shadow: ${color.red} 0 0 0 1px inset !important;
219+
}
220+
}
196221
197-
svg {
198-
animation: ${jiggle} 700ms ease-out;
199-
path { fill: ${color.red}; }
200-
}
201-
`}
222+
svg {
223+
animation: ${jiggle} 700ms ease-out;
224+
path {
225+
fill: ${color.red};
226+
}
227+
}
228+
`}
202229
`;
203230
// prettier-ignore
204231
const InputContainer = styled.div<Pick<Props, 'orientation'>>`

0 commit comments

Comments
 (0)