-
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(ToolbarGroup): rename button-group variant option (#759)
* feat(ToolbarGroup): rename button-group variant option * refactor: rename rule
- Loading branch information
1 parent
f950da7
commit 9482ccf
Showing
7 changed files
with
154 additions
and
124 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
...upUpdatedIconButtonGroupVariant/toolbarGroup-updated-iconButtonGroup-variant.md
This file was deleted.
Oops, something went wrong.
88 changes: 0 additions & 88 deletions
88
...arGroupUpdatedIconButtonGroupVariant/toolbarGroup-updated-iconButtonGroup-variant.test.ts
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...es/v6/toolbarGroupUpdatedIconButtonGroupVariant/toolbarGroup-updated-variant.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,22 @@ | ||
### toolbarGroup-updated-variant [(#10674)](https://github.com/patternfly/patternfly-react/pull/10674) | ||
|
||
The `variant` prop of ToolbarGroup and ToolbarToggleGroup had these options renamed: | ||
|
||
| Old variant option | New variant option | | ||
| ------------------- | -------------------- | | ||
| `button-group` | `action-group` | | ||
| `icon-button-group` | `action-group-plain` | | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
108 changes: 108 additions & 0 deletions
108
...c/rules/v6/toolbarGroupUpdatedIconButtonGroupVariant/toolbarGroup-updated-variant.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,108 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./toolbarGroup-updated-variant"; | ||
import { | ||
ValidTests, | ||
InvalidTests, | ||
createInvalidTest, | ||
createValidTest, | ||
} from "../../helpers/testHelpers"; | ||
const applicableComponents = ["ToolbarGroup", "ToolbarToggleGroup"]; | ||
const renames = { | ||
"button-group": "action-group", | ||
"icon-button-group": "action-group-plain", | ||
}; | ||
const oldVariantNames = Object.keys(renames) as ( | ||
| "button-group" | ||
| "icon-button-group" | ||
)[]; | ||
|
||
const validTests: ValidTests = []; | ||
const invalidTests: InvalidTests = []; | ||
for (const component of applicableComponents) { | ||
for (const oldName of oldVariantNames) { | ||
const newName = renames[oldName]; | ||
|
||
validTests.push(createValidTest(`<ToolbarGroup variant="${oldName}" />`)); | ||
validTests.push( | ||
createValidTest( | ||
`import { ToolbarGroup } from '@patternfly/react-core'; <ToolbarGroup variant={ToolbarGroupVariant["${oldName}"]} />` | ||
) | ||
); | ||
|
||
const message = `The \`${oldName}\` variant of ${component} has been renamed to \`${newName}\`.`; | ||
const errorObject = { | ||
message, | ||
type: "JSXOpeningElement", | ||
}; | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component} } from '@patternfly/react-core'; <${component} variant="${oldName}" />`, | ||
`import { ${component} } from '@patternfly/react-core'; <${component} variant="${newName}" />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component} as CustomThing } from '@patternfly/react-core'; <CustomThing variant="${oldName}" />`, | ||
`import { ${component} as CustomThing } from '@patternfly/react-core'; <CustomThing variant="${newName}" />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core'; <${component} variant={ToolbarGroupVariant["${oldName}"]} />`, | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core'; <${component} variant={ToolbarGroupVariant["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core'; | ||
const variant = ToolbarGroupVariant["${oldName}"]; <${component} variant={variant} />`, | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core'; | ||
const variant = ToolbarGroupVariant["${newName}"]; <${component} variant={variant} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant as CustomThing } from '@patternfly/react-core'; <${component} variant={CustomThing["${oldName}"]} />`, | ||
`import { ${component}, ToolbarGroupVariant as CustomThing } from '@patternfly/react-core'; <${component} variant={CustomThing["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component} as CustomGroup, ToolbarGroupVariant as CustomThing } from '@patternfly/react-core'; <CustomGroup variant={CustomThing["${oldName}"]} />`, | ||
`import { ${component} as CustomGroup, ToolbarGroupVariant as CustomThing } from '@patternfly/react-core'; <CustomGroup variant={CustomThing["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${oldName}"]} />`, | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${oldName}"]} />`, | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
invalidTests.push( | ||
createInvalidTest( | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${oldName}"]} />`, | ||
`import { ${component}, ToolbarGroupVariant } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; <${component} variant={ToolbarGroupVariant["${newName}"]} />`, | ||
[errorObject] | ||
) | ||
); | ||
} | ||
} | ||
|
||
ruleTester.run("toolbarGroup-updated-iconButtonGroup-variant", rule, { | ||
valid: validTests, | ||
invalid: invalidTests, | ||
}); |
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
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
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