Skip to content

Commit 6205337

Browse files
langermankericwbaileyactions-user
authored
Add styling for readonly, fix AutoComplete inset focus background color (#2218)
Co-authored-by: Eric Bailey <ericwbailey@users.noreply.github.com> Co-authored-by: Actions Auto Build <actions@github.com>
1 parent 8e5f622 commit 6205337

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.changeset/brown-grapes-swim.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@primer/css": patch
3+
---
4+
5+
- Adding readonly styles
6+
- Fixing focus background color for inset field

docs/src/stories/rails-form-framework/TextInput.stories.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ export default {
146146
table: {
147147
category: 'Input'
148148
}
149+
},
150+
readOnly: {
151+
description: 'readonly styles',
152+
control: {type: 'boolean'},
153+
table: {
154+
category: 'Input'
155+
}
149156
}
150157
}
151158
}
@@ -173,7 +180,8 @@ export const InputTemplate = ({
173180
caption,
174181
validation,
175182
trailingActionDivider,
176-
validationStatus
183+
validationStatus,
184+
readOnly
177185
}) => (
178186
<>
179187
<div className={clsx('FormControl', fullWidth && 'FormControl--fullWidth')}>
@@ -212,6 +220,7 @@ export const InputTemplate = ({
212220
placeholder={placeholder}
213221
id="input-id"
214222
type="text"
223+
readonly={readOnly ? 'true' : undefined}
215224
className={clsx(
216225
'FormControl-input',
217226
size && `${size}`,
@@ -253,6 +262,7 @@ export const InputTemplate = ({
253262
id="input-id"
254263
type="text"
255264
disabled={disabled ? 'true' : undefined}
265+
readonly={readOnly ? 'true' : undefined}
256266
className={clsx(
257267
'FormControl-input',
258268
size && `${size}`,
@@ -307,5 +317,6 @@ Playground.args = {
307317
visuallyHidden: false,
308318
validation: '',
309319
trailingActionDivider: false,
310-
validationStatus: 0
320+
validationStatus: 0,
321+
readOnly: false
311322
}

src/forms/FormControl.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
}
134134
}
135135

136+
&[readonly] {
137+
background-color: var(--color-input-disabled-bg);
138+
}
139+
136140
::placeholder {
137141
color: var(--color-fg-subtle);
138142
opacity: 1;
@@ -161,6 +165,11 @@
161165

162166
&.FormControl-inset {
163167
background-color: var(--color-canvas-inset);
168+
169+
&:focus-visible,
170+
&:focus {
171+
background-color: var(--color-canvas-default);
172+
}
164173
}
165174

166175
&.FormControl-monospace {

0 commit comments

Comments
 (0)