Skip to content

Commit

Permalink
Add styling for readonly, fix AutoComplete inset focus background c…
Browse files Browse the repository at this point in the history
…olor (#2218)

Co-authored-by: Eric Bailey <ericwbailey@users.noreply.github.com>
Co-authored-by: Actions Auto Build <actions@github.com>
  • Loading branch information
3 people authored Aug 29, 2022
1 parent 8e5f622 commit 6205337
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/brown-grapes-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@primer/css": patch
---

- Adding readonly styles
- Fixing focus background color for inset field
15 changes: 13 additions & 2 deletions docs/src/stories/rails-form-framework/TextInput.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ export default {
table: {
category: 'Input'
}
},
readOnly: {
description: 'readonly styles',
control: {type: 'boolean'},
table: {
category: 'Input'
}
}
}
}
Expand Down Expand Up @@ -173,7 +180,8 @@ export const InputTemplate = ({
caption,
validation,
trailingActionDivider,
validationStatus
validationStatus,
readOnly
}) => (
<>
<div className={clsx('FormControl', fullWidth && 'FormControl--fullWidth')}>
Expand Down Expand Up @@ -212,6 +220,7 @@ export const InputTemplate = ({
placeholder={placeholder}
id="input-id"
type="text"
readonly={readOnly ? 'true' : undefined}
className={clsx(
'FormControl-input',
size && `${size}`,
Expand Down Expand Up @@ -253,6 +262,7 @@ export const InputTemplate = ({
id="input-id"
type="text"
disabled={disabled ? 'true' : undefined}
readonly={readOnly ? 'true' : undefined}
className={clsx(
'FormControl-input',
size && `${size}`,
Expand Down Expand Up @@ -307,5 +317,6 @@ Playground.args = {
visuallyHidden: false,
validation: '',
trailingActionDivider: false,
validationStatus: 0
validationStatus: 0,
readOnly: false
}
9 changes: 9 additions & 0 deletions src/forms/FormControl.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
}
}

&[readonly] {
background-color: var(--color-input-disabled-bg);
}

::placeholder {
color: var(--color-fg-subtle);
opacity: 1;
Expand Down Expand Up @@ -161,6 +165,11 @@

&.FormControl-inset {
background-color: var(--color-canvas-inset);

&:focus-visible,
&:focus {
background-color: var(--color-canvas-default);
}
}

&.FormControl-monospace {
Expand Down

0 comments on commit 6205337

Please sign in to comment.