Skip to content

Commit

Permalink
Fieldset disable (#2077)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mlynam authored May 27, 2022
1 parent f59639f commit ab078a5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/neat-wasps-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/css": patch
---

Make .form-control elements render as disabled when a parent fieldset is disabled
36 changes: 36 additions & 0 deletions docs/src/stories/components/Forms/Fieldset.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'

export default {
title: 'Components/Forms/Fieldset',
decorators: [
Story => (
<form>
<Story/>
</form>
)
],
argTypes: {
disabled: {
description: 'disabled fieldset',
control: {type: 'boolean'},
table: {
category: 'Interactive'
}
}
}
}

const FieldsetTemplate = ({disabled}) => (
<fieldset disabled={disabled}>
<label htmlFor="email">Email</label>
<input className="form-control" id="email" placeholder="email"/>

<label htmlFor="username">Username</label>
<input className="form-control" id="username" placeholder="username"/>
</fieldset>
)

export const Playground = FieldsetTemplate.bind({})
Playground.args = {
disabled: false
}
3 changes: 2 additions & 1 deletion src/forms/form-control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ label {
}
}

&[disabled] {
&[disabled],
fieldset[disabled] & {
color: var(--color-primer-fg-disabled);
background-color: var(--color-input-disabled-bg);
border-color: var(--color-border-default);
Expand Down

0 comments on commit ab078a5

Please sign in to comment.