-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* alert banner * cleanup * cleanup * review cleanup * Minor cleanup Co-authored-by: Tim Roes <[email protected]>
- Loading branch information
1 parent
291e91e
commit 3a013a4
Showing
5 changed files
with
76 additions
and
44 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
airbyte-webapp/src/components/base/Banner/AlertBanner.module.scss
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,24 @@ | ||
@use "../../../scss/colors"; | ||
|
||
.alertBannerContainer { | ||
height: 30px; | ||
width: 100%; | ||
text-align: center; | ||
position: fixed; | ||
z-index: 3; | ||
font-size: 12px; | ||
line-height: 30px; | ||
color: colors.$black; | ||
|
||
& a { | ||
color: colors.$black; | ||
} | ||
} | ||
|
||
.beige { | ||
background-color: colors.$beige-100; | ||
} | ||
|
||
.red { | ||
background-color: colors.$red; | ||
} |
47 changes: 12 additions & 35 deletions
47
airbyte-webapp/src/components/base/Banner/AlertBanner.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 |
---|---|---|
@@ -1,41 +1,18 @@ | ||
import classnames from "classnames"; | ||
import React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
import styled from "styled-components"; | ||
|
||
import { Link } from "components/Link"; | ||
|
||
import { CloudRoutes } from "packages/cloud/cloudRoutes"; | ||
import { CreditStatus } from "packages/cloud/lib/domain/cloudWorkspaces/types"; | ||
|
||
const Container = styled.div<{ errorType?: string }>` | ||
height: 30px; | ||
width: 100%; | ||
background: ${({ errorType, theme }) => (errorType === "credits" ? theme.redColor : theme.warningColor)}; | ||
color: ${({ theme }) => theme.blackColor}; | ||
text-align: center; | ||
position: fixed; | ||
z-index: 3; | ||
font-size: 12px; | ||
line-height: 30px; | ||
`; | ||
const CreditsLink = styled(Link)` | ||
color: ${({ theme }) => theme.blackColor}; | ||
`; | ||
import styles from "./AlertBanner.module.scss"; | ||
|
||
interface AlertBannerProps { | ||
alertType: string; | ||
id: CreditStatus | string; | ||
color?: "default" | "warning"; | ||
message: React.ReactNode; | ||
} | ||
|
||
export const AlertBanner: React.FC<AlertBannerProps> = ({ alertType: errorType, id }) => ( | ||
<Container errorType={errorType}> | ||
{errorType === "credits" ? ( | ||
<FormattedMessage | ||
id={id} | ||
values={{ lnk: (content: React.ReactNode) => <CreditsLink to={CloudRoutes.Credits}>{content}</CreditsLink> }} | ||
/> | ||
) : ( | ||
<FormattedMessage id={id} /> | ||
)} | ||
</Container> | ||
); | ||
export const AlertBanner: React.FC<AlertBannerProps> = ({ color, message }) => { | ||
const bannerStyle = classnames(styles.alertBannerContainer, { | ||
[styles.beige]: color === "default" || !color, | ||
[styles.red]: color === "warning", | ||
}); | ||
|
||
return <div className={bannerStyle}>{message}</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
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