fix banner position and color

This commit is contained in:
Samira Mokaram
2020-09-21 14:14:19 +02:00
parent c5d4458962
commit a6178e4aff
4 changed files with 49 additions and 6 deletions
@@ -100,3 +100,15 @@ export const WithLink = () => (
</ApiProvider>
</div>
);
export const Fixed = () => (
<div style={containerStyle}>
<ApiProvider apis={apis}>
<DismissableBanner
message="This is a dismissable banner with a fixed position fixed at the bottom of the page"
variant="info"
id="fixed_dismissable"
fixed
/>
</ApiProvider>
</div>
);
@@ -27,12 +27,19 @@ import Close from '@material-ui/icons/Close';
const useStyles = makeStyles((theme: BackstageTheme) => ({
root: {
position: 'relative',
// position: 'relative',
padding: theme.spacing(0),
marginBottom: theme.spacing(6),
marginTop: -theme.spacing(3),
marginBottom: theme.spacing(0),
marginTop: theme.spacing(0),
display: 'flex',
flexFlow: 'row nowrap',
// zIndex: 'unset'
},
// showing on top
topPosition: {
position: 'relative',
marginBottom: theme.spacing(6),
marginTop: -theme.spacing(3),
zIndex: 'unset',
},
icon: {
@@ -45,6 +52,10 @@ const useStyles = makeStyles((theme: BackstageTheme) => ({
message: {
display: 'flex',
alignItems: 'center',
color: theme.palette.banner.textColor,
'& a': {
color: theme.palette.banner.linkColor,
},
},
info: {
backgroundColor: theme.palette.banner.info,
@@ -58,9 +69,15 @@ type Props = {
variant: 'info' | 'error';
message: ReactNode;
id: string;
fixed?: boolean;
};
export const DismissableBanner: FC<Props> = ({ variant, message, id }) => {
export const DismissableBanner: FC<Props> = ({
variant,
message,
id,
fixed = false,
}) => {
const classes = useStyles();
const storageApi = useApi(storageApiRef);
const notificationsStore = storageApi.forBucket('notifications');
@@ -88,9 +105,17 @@ export const DismissableBanner: FC<Props> = ({ variant, message, id }) => {
return (
<Snackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
anchorOrigin={
fixed
? { vertical: 'bottom', horizontal: 'center' }
: { vertical: 'top', horizontal: 'center' }
}
open={!dismissedBanners.has(id)}
classes={{ root: classes.root }}
classes={
fixed
? { root: classes.root }
: { root: classNames(classes.topPosition, classes.root) }
}
>
<SnackbarContent
classes={{
+4
View File
@@ -44,6 +44,8 @@ export const lightTheme = createTheme({
banner: {
info: '#2E77D0',
error: '#E22134',
textColor: '#FFFFFF',
linkColor: '#000000',
},
border: '#E6E6E6',
textContrast: '#000000',
@@ -100,6 +102,8 @@ export const darkTheme = createTheme({
banner: {
info: '#2E77D0',
error: '#E22134',
textColor: '#FFFFFF',
linkColor: '#000000',
},
border: '#E6E6E6',
textContrast: '#FFFFFF',
+2
View File
@@ -64,6 +64,8 @@ type PaletteAdditions = {
banner: {
info: string;
error: string;
textColor: string;
linkColor: string;
};
};