From 31fcd01e3a1bf78cbffd54e95cb149260354aa10 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Fri, 1 Dec 2023 09:06:53 -0500 Subject: [PATCH] Merge pull request #16039 from overleaf/jdt-notification-class-prop Adding classname to notifications and overlay css utility GitOrigin-RevId: 068672352efe2c93ca830d1dae0209cd02688226 --- .../js/shared/components/notification.tsx | 5 +- .../frontend/stories/notification.stories.tsx | 66 +++++++++++++++++++ .../frontend/stylesheets/core/utilities.less | 6 ++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/shared/components/notification.tsx b/services/web/frontend/js/shared/components/notification.tsx index 7f9bb612a9..cf36dfc8f0 100644 --- a/services/web/frontend/js/shared/components/notification.tsx +++ b/services/web/frontend/js/shared/components/notification.tsx @@ -8,6 +8,7 @@ type NotificationType = 'info' | 'success' | 'warning' | 'error' type NotificationProps = { action?: React.ReactElement ariaLive?: 'polite' | 'off' | 'assertive' + className?: string content: React.ReactElement | string customIcon?: React.ReactElement isDismissible?: boolean @@ -42,6 +43,7 @@ function NotificationIcon({ function Notification({ action, ariaLive, + className = '', content, customIcon, isActionBelowContent, @@ -57,7 +59,8 @@ function Notification({ const notificationClassName = classNames( 'notification', `notification-type-${type}`, - isActionBelowContent ? 'notification-cta-below-content' : '' + isActionBelowContent ? 'notification-cta-below-content' : '', + className ) const handleDismiss = () => { diff --git a/services/web/frontend/stories/notification.stories.tsx b/services/web/frontend/stories/notification.stories.tsx index cf486fcfaa..321e7e3e33 100644 --- a/services/web/frontend/stories/notification.stories.tsx +++ b/services/web/frontend/stories/notification.stories.tsx @@ -247,6 +247,72 @@ export const CustomIcon = (args: Args) => { ) } +export const MultipleButtons = (args: Args) => { + return ( + Lorem ipsum

} + action={ + <> + + + + } + type="info" + isActionBelowContent + isDismissible + /> + ) +} + +export const OverlayedWithCustomClass = (args: Args) => { + return ( + <> + + This can be any HTML passed to the component. For example, + paragraphs, headers, code samples,{' '} + links, etc are all supported. +

+ } + className="ol-overlay" + action={ + <> + + + + } + type="info" + isActionBelowContent + isDismissible + /> +
+

we need filler content, so here are some jokes

+
    +
  • Did you hear about the circus fire? It was in tents!
  • +
  • How do you catch a squirrel? Climb a tree and act like a nut!
  • +
  • + Did you hear about the guy who invented Lifesavers? They say he made + a mint! +
  • +
  • + Why couldn't the bicycle stand up by itself? It was two tired. +
  • +
  • + did one hat say to the other?" "Stay here! I'm going on ahead. +
  • +
  • + Why did Billy get fired from the banana factory? He kept throwing + away the bent ones. +
  • +
+
+ + ) +} + export const SuccessFlow = (args: Args) => { console.log('.....render') fetchMock.post( diff --git a/services/web/frontend/stylesheets/core/utilities.less b/services/web/frontend/stylesheets/core/utilities.less index 117f65036d..245ece443d 100755 --- a/services/web/frontend/stylesheets/core/utilities.less +++ b/services/web/frontend/stylesheets/core/utilities.less @@ -74,3 +74,9 @@ text-overflow: ellipsis; white-space: nowrap; } + +// Positioning +.ol-overlay { + position: absolute; + z-index: 1; +}