Skip to content

Commit ab078a5

Browse files
authored
Fieldset disable (#2077)
* feat: style .form-control as disabled when parent fieldset is disabled * docs: add the changeset * refactor(fieldset[disable]): use scss parent + nested selector instead of mixin
1 parent f59639f commit ab078a5

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

.changeset/neat-wasps-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": patch
3+
---
4+
5+
Make .form-control elements render as disabled when a parent fieldset is disabled
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react'
2+
3+
export default {
4+
title: 'Components/Forms/Fieldset',
5+
decorators: [
6+
Story => (
7+
<form>
8+
<Story/>
9+
</form>
10+
)
11+
],
12+
argTypes: {
13+
disabled: {
14+
description: 'disabled fieldset',
15+
control: {type: 'boolean'},
16+
table: {
17+
category: 'Interactive'
18+
}
19+
}
20+
}
21+
}
22+
23+
const FieldsetTemplate = ({disabled}) => (
24+
<fieldset disabled={disabled}>
25+
<label htmlFor="email">Email</label>
26+
<input className="form-control" id="email" placeholder="email"/>
27+
28+
<label htmlFor="username">Username</label>
29+
<input className="form-control" id="username" placeholder="username"/>
30+
</fieldset>
31+
)
32+
33+
export const Playground = FieldsetTemplate.bind({})
34+
Playground.args = {
35+
disabled: false
36+
}

src/forms/form-control.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ label {
5757
}
5858
}
5959

60-
&[disabled] {
60+
&[disabled],
61+
fieldset[disabled] & {
6162
color: var(--color-primer-fg-disabled);
6263
background-color: var(--color-input-disabled-bg);
6364
border-color: var(--color-border-default);

0 commit comments

Comments
 (0)