-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Checkbox/Radio): replace isLabelBeforeButton with labelPosition=…
…"start" (#587) * feat(Checkbox/Radio): replace isLabelBeforeButton with labelPosition="start" * feat(Checkbox/Radio): add rule to Beta rules before React PR is merged
- Loading branch information
1 parent
8e83ed5
commit 500ed7f
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...oxRadioReplaceIsLabelBeforeButton/checkbox-radio-replace-isLabelBeforeButton.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### checkbox-radio-replace-isLabelBeforeButton [(#10016)](https://github.com/patternfly/patternfly-react/pull/10016) | ||
|
||
The `isLabelBeforeButton` prop in Checkbox and Radio has been replaced with `labelPosition="start"` | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
29 changes: 29 additions & 0 deletions
29
...heckboxRadioReplaceIsLabelBeforeButton/checkbox-radio-replace-isLabelBeforeButton.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./checkbox-radio-replace-isLabelBeforeButton"; | ||
|
||
ruleTester.run("checkbox-radio-replace-isLabelBeforeButton", rule, { | ||
valid: [ | ||
{ | ||
code: `<Checkbox isLabelBeforeButton />`, | ||
}, | ||
{ | ||
code: `import { Checkbox } from '@patternfly/react-core'; <Checkbox someOtherProp />`, | ||
}, | ||
{ | ||
code: `<Radio isLabelBeforeButton />`, | ||
}, | ||
{ | ||
code: `import { Radio } from '@patternfly/react-core'; <Radio someOtherProp />`, | ||
}, | ||
], | ||
invalid: ["Checkbox", "Radio"].map((component) => ({ | ||
code: `import { ${component} } from '@patternfly/react-core'; <${component} isLabelBeforeButton />`, | ||
output: `import { ${component} } from '@patternfly/react-core'; <${component} labelPosition="start" />`, | ||
errors: [ | ||
{ | ||
message: `isLabelBeforeButton prop for ${component} has been replaced with labelPosition="start"`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
})), | ||
}); |
17 changes: 17 additions & 0 deletions
17
.../v6/checkboxRadioReplaceIsLabelBeforeButton/checkbox-radio-replace-isLabelBeforeButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { renameProps } from "../../helpers"; | ||
|
||
const renames = { | ||
isLabelBeforeButton: { | ||
newName: 'labelPosition="start"', | ||
replace: true, | ||
}, | ||
}; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10016 | ||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps({ | ||
Checkbox: renames, | ||
Radio: renames, | ||
}), | ||
}; |
8 changes: 8 additions & 0 deletions
8
.../checkboxRadioReplaceIsLabelBeforeButton/checkboxRadioReplaceIsLabelBeforeButtonInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Checkbox, Radio } from "@patternfly/react-core"; | ||
|
||
export const CheckboxReplaceIsLabelBeforeButtonInput = () => ( | ||
<Checkbox isLabelBeforeButton /> | ||
); | ||
export const RadioReplaceIsLabelBeforeButtonInput = () => ( | ||
<Radio isLabelBeforeButton /> | ||
); |
8 changes: 8 additions & 0 deletions
8
...checkboxRadioReplaceIsLabelBeforeButton/checkboxRadioReplaceIsLabelBeforeButtonOutput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Checkbox, Radio } from "@patternfly/react-core"; | ||
|
||
export const CheckboxReplaceIsLabelBeforeButtonInput = () => ( | ||
<Checkbox labelPosition="start" /> | ||
); | ||
export const RadioReplaceIsLabelBeforeButtonInput = () => ( | ||
<Radio labelPosition="start" /> | ||
); |