@evenicanpm/ui 2.4.2 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @evenicanpm/ui
2
2
 
3
+ ## 2.5.1
4
+
5
+ ## 2.5.0
6
+
3
7
  ## 2.4.2
4
8
 
5
9
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evenicanpm/ui",
3
- "version": "2.4.2",
3
+ "version": "2.5.1",
4
4
  "description": "Common and re-usable UI elements for e4 products.",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -0,0 +1,78 @@
1
+ import React from "react";
2
+
3
+ export interface AnnouncementBannerProps {
4
+ enabled: boolean;
5
+ text?: string;
6
+ backgroundColor?: string;
7
+ textColor?: string;
8
+ link?: string;
9
+ linkText?: string;
10
+ dismissible?: boolean;
11
+ }
12
+
13
+ export const AnnouncementBanner: React.FC<AnnouncementBannerProps> = ({
14
+ enabled,
15
+ text,
16
+ backgroundColor = "#f5f5f5",
17
+ textColor = "#222",
18
+ link,
19
+ linkText,
20
+ dismissible = false,
21
+ }) => {
22
+ const [dismissed, setDismissed] = React.useState(false);
23
+
24
+ if (!enabled || dismissed || !text) return null;
25
+
26
+ return (
27
+ <div
28
+ style={{
29
+ background: backgroundColor,
30
+ color: textColor,
31
+ padding: "0.75rem 1.5rem",
32
+ display: "flex",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ position: "relative",
36
+ fontSize: "1rem",
37
+ fontWeight: 500,
38
+ }}
39
+ data-testid="announcement-banner"
40
+ >
41
+ <span>{text}</span>
42
+ {link && linkText && (
43
+ <a
44
+ href={link}
45
+ style={{
46
+ color: textColor,
47
+ marginLeft: "1rem",
48
+ textDecoration: "underline",
49
+ fontWeight: 600,
50
+ }}
51
+ >
52
+ {linkText}
53
+ </a>
54
+ )}
55
+ {dismissible && (
56
+ <button
57
+ type="button"
58
+ aria-label="Dismiss announcement"
59
+ onClick={() => setDismissed(true)}
60
+ style={{
61
+ background: "none",
62
+ border: "none",
63
+ color: textColor,
64
+ marginLeft: "1.5rem",
65
+ fontSize: "1.25rem",
66
+ cursor: "pointer",
67
+ position: "absolute",
68
+ right: 16,
69
+ top: "50%",
70
+ transform: "translateY(-50%)",
71
+ }}
72
+ >
73
+ ×
74
+ </button>
75
+ )}
76
+ </div>
77
+ );
78
+ };
@@ -0,0 +1,2 @@
1
+ export type { AnnouncementBannerProps } from "./announcement-banner";
2
+ export { AnnouncementBanner } from "./announcement-banner";
@@ -1,3 +1,4 @@
1
+ export * from "./announcement-banner";
1
2
  export * from "./button";
2
3
  export * from "./flex-box";
3
4
  export * from "./footer";