Skip to content

Commit a0f3442

Browse files
feat(ui) Add banner on v1 home page to warn of v2 UI deprecation (#14131)
1 parent 8d3d01f commit a0f3442

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Icon } from '@components';
2+
import React from 'react';
3+
import { Link } from 'react-router-dom';
4+
5+
import PageBanner from '@app/sharedV2/PageBanner';
6+
import { useIsThemeV2Toggleable } from '@app/useIsThemeV2';
7+
import { PageRoutes } from '@conf/Global';
8+
9+
export default function DeprecationBanner() {
10+
const [isThemeV2Toggleable] = useIsThemeV2Toggleable();
11+
12+
const linkContent = (
13+
<span>
14+
{String.fromCodePoint(128064)}&nbsp; DataHub has a new look! Preview it now under{' '}
15+
<Link to={`${PageRoutes.SETTINGS}/preferences`}>Appearance &gt; Try New User Experience</Link> before the
16+
current UI goes away with v1.3.0.
17+
</span>
18+
);
19+
const staticContent = (
20+
<>
21+
{String.fromCodePoint(128064)}&nbsp; DataHub has a new look! Contact your Admin to unlock the new interface
22+
before the current UI goes away with v1.3.0.
23+
</>
24+
);
25+
26+
const content = isThemeV2Toggleable ? linkContent : staticContent;
27+
28+
return (
29+
<PageBanner
30+
localStorageKey="v1UIDeprecationAnnouncement"
31+
icon={<Icon icon="ExclamationMark" color="red" weight="fill" source="phosphor" />}
32+
content={content}
33+
/>
34+
);
35+
}

datahub-web-react/src/app/home/HomePage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useEffect } from 'react';
22

33
import analytics, { EventType } from '@app/analytics';
4+
import DeprecationBanner from '@app/home/DeprecationBanner';
45
import { HomePageBody } from '@app/home/HomePageBody';
56
import { HomePageHeader } from '@app/home/HomePageHeader';
67
import { OnboardingTour } from '@app/onboarding/OnboardingTour';
@@ -29,6 +30,7 @@ export const HomePage = () => {
2930
HOME_PAGE_SEARCH_BAR_ID,
3031
]}
3132
/>
33+
<DeprecationBanner />
3234
<HomePageHeader />
3335
<HomePageBody />
3436
</>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Button, colors } from '@components';
2+
import React, { useState } from 'react';
3+
import styled from 'styled-components';
4+
5+
import { FontColorOptions } from '@components/theme/config';
6+
7+
const BannerWrapper = styled.div<{ $backgroundColor: string }>`
8+
padding: 16px;
9+
font-size: 14px;
10+
font-weight: 500;
11+
display: flex;
12+
justify-content: space-between;
13+
align-items: center;
14+
background-color: ${({ $backgroundColor }) => $backgroundColor};
15+
`;
16+
17+
const IconTextWrapper = styled.div`
18+
display: flex;
19+
gap: 16px;
20+
align-items: center;
21+
`;
22+
23+
const StyledButton = styled(Button)`
24+
padding: 0;
25+
`;
26+
27+
interface Props {
28+
content: React.ReactNode;
29+
localStorageKey: string;
30+
icon?: React.ReactNode;
31+
backgroundColor?: string;
32+
exitColor?: FontColorOptions;
33+
}
34+
35+
export default function PageBanner({
36+
content,
37+
localStorageKey,
38+
icon,
39+
backgroundColor = colors.red[0],
40+
exitColor = 'red',
41+
}: Props) {
42+
const [isBannerHidden, setIsBannerHidden] = useState(!!localStorage.getItem(localStorageKey));
43+
44+
function handleClose() {
45+
localStorage.setItem(localStorageKey, 'true');
46+
setIsBannerHidden(true);
47+
}
48+
49+
if (isBannerHidden) return null;
50+
51+
return (
52+
<BannerWrapper $backgroundColor={backgroundColor}>
53+
<IconTextWrapper>
54+
{icon}
55+
{content}
56+
</IconTextWrapper>
57+
<StyledButton
58+
icon={{ icon: 'X', color: exitColor, source: 'phosphor', size: '2xl' }}
59+
variant="link"
60+
onClick={handleClose}
61+
/>
62+
</BannerWrapper>
63+
);
64+
}

0 commit comments

Comments
 (0)