-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename the NotificationBanner component into NotificationCard (#979)
* Rename NotificationBanner into NotificationCard * Add codemod for NotificationBanner rename * Add changeset * Update changeset
- Loading branch information
Robin Métral
authored
Jun 15, 2021
1 parent
1a1a364
commit 3cfefac
Showing
13 changed files
with
106 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sumup/circuit-ui': major | ||
--- | ||
|
||
Renamed the NotificationBanner component to NotificationCard. This frees up the NotificationBanner namespace for a new component that we will introduce in `v3.x`. |
9 changes: 9 additions & 0 deletions
9
packages/circuit-ui/cli/migrate/__testfixtures__/component-names-v3.input.js
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,9 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { NotificationBanner } from '@sumup/circuit-ui'; | ||
|
||
const BaseNotificationBanner = () => <NotificationBanner />; | ||
|
||
const RedNotificationBanner = styled(NotificationBanner)` | ||
color: red; | ||
`; |
9 changes: 9 additions & 0 deletions
9
packages/circuit-ui/cli/migrate/__testfixtures__/component-names-v3.output.js
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,9 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { NotificationCard } from '@sumup/circuit-ui'; | ||
|
||
const BaseNotificationBanner = () => <NotificationCard />; | ||
|
||
const RedNotificationBanner = styled(NotificationCard)` | ||
color: red; | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright 2021, SumUp Ltd. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Transform, JSCodeshift, Collection } from 'jscodeshift'; | ||
|
||
import { findImportsByPath } from './utils'; | ||
|
||
function transformFactory( | ||
j: JSCodeshift, | ||
root: Collection, | ||
componentNames: string[], | ||
): void { | ||
const [oldComponentName, newComponentName] = componentNames; | ||
const imports = findImportsByPath(j, root, '@sumup/circuit-ui'); | ||
|
||
const componentImport = imports.find((i) => i.name === oldComponentName); | ||
|
||
if (!componentImport) { | ||
return; | ||
} | ||
|
||
root | ||
.find(j.Identifier) | ||
.filter((nodePath) => nodePath.node.name === oldComponentName) | ||
.replaceWith(j.identifier(newComponentName)); | ||
} | ||
|
||
const transform: Transform = (file, api) => { | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
|
||
[['NotificationBanner', 'NotificationCard']].forEach((componentNames) => { | ||
transformFactory(j, root, componentNames); | ||
}); | ||
|
||
return root.toSource(); | ||
}; | ||
|
||
export default transform; |
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
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
2 changes: 1 addition & 1 deletion
2
...pshots__/NotificationBanner.spec.tsx.snap → ...napshots__/NotificationCard.spec.tsx.snap
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