titaned-frontend-library 1.0.21 → 1.0.22

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.
@@ -191,5 +191,6 @@ export interface ThemeResponse {
191
191
  export interface AnnouncementBannerProps {
192
192
  announcementType: string;
193
193
  data?: string;
194
+ backgroundColor?: string;
194
195
  }
195
196
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titaned-frontend-library",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "A comprehensive React TypeScript component library for TitanEd applications",
5
5
  "author": "TitanEd Team",
6
6
  "private": false,
@@ -4,12 +4,26 @@
4
4
  align-items: center;
5
5
  justify-content: left;
6
6
  position: relative;
7
- background-color: var(--bg-body);
8
7
  color: var(--text-primary);
9
8
  padding: 6px 20px;
10
9
  line-height: 1.2;
11
10
  word-break: break-word;
12
11
  flex-wrap: wrap;
12
+ transform-origin: top;
13
+
14
+ transform: scaleY(0);
15
+ opacity: 0;
16
+ transition: transform 0.8s ease, opacity 0.8s ease;
17
+
18
+ &.showBanner {
19
+ transform: scaleY(1);
20
+ opacity: 1;
21
+ }
22
+
23
+ &.hideBanner {
24
+ transform: scaleY(0);
25
+ opacity: 0;
26
+ }
13
27
 
14
28
 
15
29
  .announcement-content {
@@ -17,7 +31,7 @@
17
31
  text-align: left;
18
32
 
19
33
  h1, h2, h3, h4, h5, h6, p, span, strong, em, i, b {
20
- margin: 0.25em 0;
34
+ margin: 0;
21
35
  color: var(--text-primary);
22
36
  }
23
37
 
@@ -67,36 +81,6 @@
67
81
  height: 18px;
68
82
  width: 18px;
69
83
  }
70
-
71
- &.showBanner {
72
- animation: expandBanner 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
73
- }
74
-
75
- &.hideBanner {
76
- animation: collapseBanner 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
77
- }
78
- }
79
-
80
- @keyframes expandBanner {
81
- from {
82
- max-height: 0;
83
- opacity: 0;
84
- }
85
- to {
86
- max-height: 100%;
87
- opacity: 1;
88
- }
89
- }
90
-
91
- @keyframes collapseBanner {
92
- from {
93
- max-height: 100%;
94
- opacity: 1;
95
- }
96
- to {
97
- max-height: 0;
98
- opacity: 0;
99
- }
100
84
  }
101
85
 
102
86
  @media only screen and (max-width: 650px) {
@@ -7,6 +7,7 @@ import './AnnouncementBanner.scss';
7
7
  const AnnouncementBanner: React.FC<AnnouncementBannerProps> = ({
8
8
  announcementType,
9
9
  data,
10
+ backgroundColor,
10
11
  }) => {
11
12
  const [isVisible, setIsVisible] = useState<boolean>(() => {
12
13
  const lastClosed = localStorage.getItem(announcementType);
@@ -18,17 +19,23 @@ const AnnouncementBanner: React.FC<AnnouncementBannerProps> = ({
18
19
  return true;
19
20
  });
20
21
 
21
- const [isAnimating, setIsAnimating] = useState<boolean>(false);
22
+
23
+ const [animationClass, setAnimationClass] = useState<string>('showBanner');
22
24
 
23
25
  const handleClose = () => {
24
- setIsAnimating(true);
26
+ setAnimationClass('hideBanner');
25
27
  setTimeout(() => {
26
28
  setIsVisible(false);
27
- setIsAnimating(false);
28
29
  localStorage.setItem(announcementType, Date.now().toString());
29
- }, 1000);
30
+ }, 800);
30
31
  };
31
32
 
33
+ useEffect(() => {
34
+ if (isVisible) {
35
+ setAnimationClass('showBanner');
36
+ }
37
+ }, [isVisible]);
38
+
32
39
  useEffect(() => {
33
40
  const checkBannerReset = () => {
34
41
  const lastClosed = localStorage.getItem(announcementType);
@@ -46,17 +53,11 @@ const AnnouncementBanner: React.FC<AnnouncementBannerProps> = ({
46
53
  return () => clearInterval(interval);
47
54
  }, [announcementType]);
48
55
 
49
- if (!data || data.trim() === '' || (!isVisible && !isAnimating)) {
50
- return null;
51
- }
56
+
57
+ if (!data || data.trim() === '' || !isVisible) return null;
52
58
 
53
59
  return (
54
- <div
55
- className={`announcement-banner ${
56
- isAnimating ? 'hideBanner' : 'showBanner'
57
- }`}
58
- style={{ display: !isVisible && !isAnimating ? 'none' : 'flex' }}
59
- >
60
+ <div className={`announcement-banner ${animationClass}`} style={{ backgroundColor: backgroundColor || 'var(--bg-body)' }}>
60
61
  <div
61
62
  className="announcement-content"
62
63
  dangerouslySetInnerHTML={{ __html: data }}
@@ -185,4 +185,5 @@ export interface ThemeResponse {
185
185
  export interface AnnouncementBannerProps {
186
186
  announcementType: string;
187
187
  data?: string;
188
+ backgroundColor?: string;
188
189
  }