File tree 10 files changed +91
-152
lines changed
10 files changed +91
-152
lines changed Original file line number Diff line number Diff line change
1
+ import styled from "@emotion/styled" ;
2
+ import { Alert } from "@mui/material" ;
3
+ import { mediaDesktopUp } from "../../../styles/common/mixins/breakpoints" ;
4
+ import { textBodySmall400 } from "../../../styles/common/mixins/fonts" ;
5
+
6
+ export const StyledAlert = styled ( Alert ) `
7
+ justify-content: center;
8
+ padding: 8px 12px;
9
+ text-align: center;
10
+
11
+ .MuiAlert-message {
12
+ ${ textBodySmall400 } ;
13
+ align-self: center;
14
+ flex: 1;
15
+
16
+ .MuiLink-root {
17
+ color: inherit;
18
+ }
19
+ }
20
+
21
+ .MuiAlert-action {
22
+ margin: -8px;
23
+ padding: 0;
24
+ }
25
+
26
+ ${ mediaDesktopUp } {
27
+ padding: 8px 16px;
28
+ }
29
+ ` ;
Original file line number Diff line number Diff line change 1
- import { Alert as MAlert , AlertProps as MAlertProps } from "@mui/material" ;
2
- import React , { forwardRef , ReactNode } from "react" ;
1
+ import { AlertProps } from "@mui/material" ;
2
+ import React , { forwardRef } from "react" ;
3
+ import { BaseComponentProps } from "../../types" ;
4
+ import { StyledAlert } from "./banner.styles" ;
5
+ import { ALERT_PROPS } from "./constants" ;
3
6
4
- export interface BannerProps extends MAlertProps {
5
- children : ReactNode ;
6
- className ?: string ;
7
- }
8
-
9
- export const Banner = forwardRef < HTMLDivElement , BannerProps > ( function Banner (
10
- {
11
- children,
12
- className,
13
- ...props /* Spread props to allow for Mui AlertProps specific prop overrides. */
14
- } : BannerProps ,
7
+ export const Banner = forwardRef <
8
+ HTMLDivElement ,
9
+ AlertProps & BaseComponentProps
10
+ > ( function Alert (
11
+ { ...props } : AlertProps & BaseComponentProps ,
15
12
ref
16
13
) : JSX . Element {
17
- return (
18
- < MAlert className = { className } ref = { ref } { ...props } >
19
- { children }
20
- </ MAlert >
21
- ) ;
14
+ return < StyledAlert { ...ALERT_PROPS } ref = { ref } { ...props } /> ;
22
15
} ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import { AlertProps as MAlertProps } from "@mui/material" ;
2
- import React , { Fragment , ReactNode } from "react" ;
1
+ import { AlertProps , Fade } from "@mui/material" ;
2
+ import React from "react" ;
3
3
import { useSessionTimeout } from "../../../../../hooks/useSessionTimeout" ;
4
- import { Banner } from "./sessionTimeout.styles" ;
5
-
6
- export interface SessionTimeoutProps extends Omit < MAlertProps , "title" > {
7
- className ?: string ;
8
- title ?: ReactNode ;
9
- }
4
+ import { BaseComponentProps , ContentProps } from "../../../../types" ;
5
+ import { Banner } from "../../banner" ;
10
6
11
7
export const SessionTimeout = ( {
8
+ children,
12
9
className,
13
- title = "For your security, you have been logged out due to 15 minutes of inactivity." ,
10
+ content ,
14
11
...props
15
- } : SessionTimeoutProps ) : JSX . Element => {
12
+ } : AlertProps & BaseComponentProps & ContentProps ) : JSX . Element => {
16
13
const { clearSessionTimeout, isSessionTimeout } = useSessionTimeout ( ) ;
17
14
return (
18
- < Fragment >
19
- { isSessionTimeout && (
20
- < Banner className = { className } onClose = { clearSessionTimeout } { ...props } >
21
- { title }
22
- </ Banner >
23
- ) }
24
- </ Fragment >
15
+ < Fade in = { isSessionTimeout } unmountOnExit >
16
+ < Banner className = { className } onClose = { clearSessionTimeout } { ...props } >
17
+ { content || children }
18
+ </ Banner >
19
+ </ Fade >
25
20
) ;
26
21
} ;
Original file line number Diff line number Diff line change 1
- import { AlertProps as MAlertProps } from "@mui/material" ;
2
- import React , { Fragment , ReactNode } from "react" ;
1
+ import { AlertProps , Fade } from "@mui/material" ;
2
+ import React from "react" ;
3
3
import { useSystemStatus } from "../../../../../hooks/useSystemStatus" ;
4
- import { BannerPrimary } from "../BannerPrimary/bannerPrimary" ;
5
-
6
- export interface SystemIndexingProps extends Omit < MAlertProps , "title" > {
7
- children ?: ReactNode ;
8
- className ?: string ;
9
- title ?: ReactNode ;
10
- }
4
+ import { BaseComponentProps , ContentProps } from "../../../../types" ;
5
+ import { Banner } from "../../banner" ;
11
6
12
7
export const SystemIndexing = ( {
13
8
children,
14
9
className,
15
- title = "Data indexing in progress. Downloads and exports are disabled as search results may be incomplete." ,
10
+ content ,
16
11
...props
17
- } : SystemIndexingProps ) : JSX . Element => {
12
+ } : AlertProps & BaseComponentProps & ContentProps ) : JSX . Element => {
18
13
const systemStatus = useSystemStatus ( ) ;
19
14
const { indexing, loading, ok } = systemStatus ;
20
- const showAlert = ! loading && ok && indexing ;
21
15
return (
22
- < Fragment >
23
- { showAlert && (
24
- < BannerPrimary className = { className } { ...props } >
25
- < Fragment >
26
- { title }
27
- { children }
28
- </ Fragment >
29
- </ BannerPrimary >
30
- ) }
31
- </ Fragment >
16
+ < Fade in = { ! loading && ok && indexing } unmountOnExit >
17
+ < Banner className = { className } { ...props } >
18
+ { content || children }
19
+ </ Banner >
20
+ </ Fade >
32
21
) ;
33
22
} ;
Original file line number Diff line number Diff line change 1
- import { AlertProps as MAlertProps } from "@mui/material" ;
2
- import React , { Fragment , ReactNode } from "react" ;
1
+ import { AlertProps , Fade } from "@mui/material" ;
2
+ import React from "react" ;
3
3
import { useSystemStatus } from "../../../../../hooks/useSystemStatus" ;
4
- import { BannerPrimary } from "../BannerPrimary/bannerPrimary" ;
5
-
6
- export interface SystemStatusProps extends Omit < MAlertProps , "title" > {
7
- children ?: ReactNode ;
8
- className ?: string ;
9
- title ?: ReactNode ;
10
- }
4
+ import { BaseComponentProps , ContentProps } from "../../../../types" ;
5
+ import { Banner } from "../../banner" ;
11
6
12
7
export const SystemStatus = ( {
13
8
children,
14
9
className,
15
- title = "One or more of the system components are currently unavailable. Functionality may be degraded." ,
10
+ content ,
16
11
...props
17
- } : SystemStatusProps ) : JSX . Element => {
12
+ } : AlertProps & BaseComponentProps & ContentProps ) : JSX . Element => {
18
13
const systemStatus = useSystemStatus ( ) ;
19
14
const { loading, ok } = systemStatus ;
20
- const showAlert = ! loading && ! ok ;
21
15
return (
22
- < Fragment >
23
- { showAlert && (
24
- < BannerPrimary className = { className } { ...props } >
25
- < Fragment >
26
- { title }
27
- { children }
28
- </ Fragment >
29
- </ BannerPrimary >
30
- ) }
31
- </ Fragment >
16
+ < Fade in = { ! loading && ! ok } unmountOnExit >
17
+ < Banner className = { className } { ...props } >
18
+ { content || children }
19
+ </ Banner >
20
+ </ Fade >
32
21
) ;
33
22
} ;
Original file line number Diff line number Diff line change
1
+ import { AlertProps } from "@mui/material" ;
2
+ import { COLOR , VARIANT } from "../../../styles/common/mui/alert" ;
3
+ import { FlatPaper } from "../Paper/paper.styles" ;
4
+
5
+ export const ALERT_PROPS : Partial < AlertProps > = {
6
+ color : COLOR . PRIMARY ,
7
+ component : FlatPaper ,
8
+ elevation : 0 ,
9
+ icon : false ,
10
+ variant : VARIANT . FILLED ,
11
+ } ;
Original file line number Diff line number Diff line change
1
+ import { ReactNode } from "react" ;
2
+
1
3
export interface BaseComponentProps {
2
4
className ?: string ;
3
5
}
4
6
7
+ export interface ContentProps {
8
+ content ?: ReactNode ;
9
+ }
10
+
5
11
export interface TestIdProps {
6
12
testId ?: string ;
7
13
}
You can’t perform that action at this time.
0 commit comments