-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clerk-js): Replace Error & Info component with a single Alert co…
…mponent
- Loading branch information
1 parent
0692fad
commit 8c34d21
Showing
37 changed files
with
204 additions
and
142 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
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,18 @@ | ||
import { renderJSON } from '@clerk/shared/testUtils'; | ||
import * as React from 'react'; | ||
|
||
import { Alert } from './Alert'; | ||
|
||
describe('alert for info', () => { | ||
it('renders an info alert', () => { | ||
const tree = renderJSON(<Alert type='error'>Foo</Alert>); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('alert for error', () => { | ||
it('renders an error alert', () => { | ||
const tree = renderJSON(<Alert type='info'>Bar</Alert>); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
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,25 @@ | ||
import React from 'react'; | ||
|
||
export type AlertType = 'info' | 'error'; | ||
|
||
export type AlertProps = { | ||
type: AlertType; | ||
children: React.ReactNode; | ||
style?: {}; | ||
} & React.HTMLAttributes<HTMLDivElement>; | ||
|
||
// Renders global alerts across components, will be replaced by notification snackbars. | ||
export function Alert({ type, children, style }: AlertProps): JSX.Element { | ||
if (!children) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<div | ||
className={`cl-${type}`} | ||
style={style} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/clerk-js/src/ui/common/alert/__snapshots__/Alert.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`alert for error renders an error alert 1`] = ` | ||
<div | ||
className="cl-info" | ||
> | ||
Bar | ||
</div> | ||
`; | ||
|
||
exports[`alert for info renders an info alert 1`] = ` | ||
<div | ||
className="cl-error" | ||
> | ||
Foo | ||
</div> | ||
`; |
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 @@ | ||
export * from './Alert'; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
packages/clerk-js/src/ui/common/error/__snapshots__/Error.test.tsx.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.