Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extension): add midnight pre-launch settings banner LW-10398 #1156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ USE_FOOR_TOPUP=false
USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT=false
USE_MULTI_WALLET=true
USE_SHARED_WALLET=false
USE_MIDNIGHT_PRELAUNCH_EVENT=false

# In App URLs
CATALYST_GOOGLE_PLAY_URL=https://play.google.com/store/apps/details?id=io.iohk.vitvoting
Expand Down
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ USE_MULTI_DELEGATION_STAKING_GRID_VIEW=true
USE_MULTI_DELEGATION_STAKING_FILTERS=false
USE_ROS_STAKING_COLUMN=false
USE_FOOR_TOPUP=false
USE_MIDNIGHT_PRELAUNCH_EVENT=false

# In App URLs
CATALYST_GOOGLE_PLAY_URL=https://play.google.com/store/apps/details?id=io.iohk.vitvoting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { PageTitle } from '@components/Layout';
import { useTranslation } from 'react-i18next';
import { Layout, SectionLayout } from '@src/views/browser-view/components/Layout';
import { SettingsRemoveWallet } from './SettingsRemoveWallet';
import { MidnightPreLaunchSettingsBanner } from '@lace/core';
import { Box } from '@lace/ui';
import MidnightPreLaunchBannerImage from '../../../../../../../../packages/core/src/ui/assets/images/midnight-launch-event-sidebar-banner.png';

export interface SettingsLayoutProps {
defaultPassphraseVisible?: boolean;
Expand All @@ -16,9 +19,20 @@ export const SettingsLayout = ({
}: SettingsLayoutProps): React.ReactElement => {
const { t } = useTranslation();

const sidePanelContent = (
<div>
{process.env.USE_MIDNIGHT_PRELAUNCH_EVENT === 'true' ? (
<Box mb="$32">
<MidnightPreLaunchSettingsBanner bannerImageUrl={MidnightPreLaunchBannerImage} />
</Box>
) : undefined}
<SettingsAbout data-testid="about-container" />
</div>
);

return (
<Layout>
<SectionLayout sidePanelContent={<SettingsAbout data-testid="about-container" />}>
<SectionLayout sidePanelContent={sidePanelContent}>
<PageTitle data-testid="settings-page-title">{t('browserView.settings.heading')}</PageTitle>
<SettingsWallet />
{process.env.USE_MULTI_CURRENCY === 'true' && <SettingsPreferences />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ export const SettingsWalletBase = <AdditionalDrawers extends string>({
<Title level={5} className={styles.heading5} data-testid="wallet-settings-heading">
{t('browserView.settings.wallet.title')}
</Title>
{process.env.USE_MIDNIGHT_PRELAUNCH_EVENT === 'true' ? (
<SettingsLink
description={t('browserView.settings.wallet.midnight.prelaunch.description')}
data-testid="settings-wallet-midnight-prelaunch-link"
>
{t('browserView.settings.wallet.midnight.prelaunch.title')}
</SettingsLink>
) : undefined}
{popupView && (
<>
<AboutDrawer visible={activeDrawer === SettingsDrawer.about} onClose={closeDrawer} popupView={popupView} />
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ export * from '@ui/components/SharedWallet';
export * from '@ui/components/Account';
export * from '@ui/components/WalletSetupRevamp';
export * from '@ui/components/ListEmptyState';
export * from '@ui/components/MidnightPreLaunchSettingsBanner';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.card {
background-image: var(--midnight-pre-launch-banner-image);
background-size: cover;
background-position: center right;
padding: 30px 20px 30px 20px;
}

.heading {
color: white;
font-size: 18px;
line-height: 24px;
margin-bottom: 10px;
font-weight: 700;
}

.description {
color: #A9A9A9;
font-size: 16px;
line-height: 24px;
font-weight: 500;
margin-bottom: 30px;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that i tried to use @lace/ui typography here instead of defining it all in CSS which turned out to be more trouble than good as this text is not standard (e.g: it looks the same in both themes) and i ran into override issues when trying to change the color via css then.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import type { Meta } from '@storybook/react';
import { action } from '@storybook/addon-actions';

import { Box } from '@lace/ui';

import { MidnightPreLaunchSettingsBanner } from './index';
import MidnightPreLaunchBannerImage from '../../assets/images/midnight-launch-event-sidebar-banner.png';

export default {
title: 'Midnight/MidnightPreLaunchSettingsBanner'
} as Meta<typeof MidnightPreLaunchSettingsBanner>;

export const Overview = (): JSX.Element => (
<>
<Box w="$312">
<MidnightPreLaunchSettingsBanner
bannerImageUrl={MidnightPreLaunchBannerImage}
onCtaButtonClick={action('onCtaButtonClick')}
/>
</Box>
<Box w="$342">
<MidnightPreLaunchSettingsBanner
bannerImageUrl={MidnightPreLaunchBannerImage}
onCtaButtonClick={action('onCtaButtonClick')}
/>
</Box>
<Box w="$420">
<MidnightPreLaunchSettingsBanner
bannerImageUrl={MidnightPreLaunchBannerImage}
onCtaButtonClick={action('onCtaButtonClick')}
/>
</Box>
</>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { Button, Card } from '@lace/ui';
import { useTranslation } from 'react-i18next';
import styles from './MidnightPreLaunchSettingsBanner.module.scss';

export const MidnightPreLaunchSettingsBanner = ({
bannerImageUrl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about bannerImageUrl prop. In my opinion this prop would have more sense if this banner was generic one.

When I look at place where it is used I see this weird looking import import MidnightPreLaunchBannerImage from '../../../../../../../../packages/core/src/ui/assets/images/midnight-launch-event-sidebar-banner.png';

I would recommend removing this prop, or making this component generic like <SettingsBanner /> and place image in apps/browser-extension-wallet directory. The same for storybook.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more I like the idea of making this component generic one, especially that it's implementation is in core package. If we would like to keep this name MidnightPreLaunchSettingsBanner to me it would make more sense to have it in apps/browser-extension-wallet as this is not something generic and there is probably 0% chance we would like to reuse it somewhere else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pczeglik-iohk I had to introduce the prop because the image must be used as CSS background (so that the rounded corners of the banner are correctly respected) AND unfortunately our core package doesn't correctly bundle css images (the path is simply retained and then wrong when component is imported in the extension) - I can move the image to the extension package but then what should be shown in the core storybook (it also acts as an example)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @DominikGuzei I think the issue is on the way we have of working and exporting images from core which should be addressed. But I think the way it was set up it's consistent with how other components currently do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pczeglik-iohk sure, i can turn this into a generic component BUT it doesn't really make sense since the design is quite special in that it looks the same in light/dark theme (font colors). I'm not sure if it's the best case for a generic component tbh.

onCtaButtonClick
}: {
bannerImageUrl: string;
onCtaButtonClick?: () => void;
}): React.ReactElement => {
const { t } = useTranslation();
return (
<Card.Outlined
className={styles.card}
style={{ '--midnight-pre-launch-banner-image': `url(${bannerImageUrl})` } as React.CSSProperties}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the only way I found to provide a background image via CSS variable to the component (since it didn't work to include the background-image in the compiled core component)

>
<div className={styles.heading}>{t('core.MidnightPreLaunchSettingsBanner.heading')}</div>
<div className={styles.description}>{t('core.MidnightPreLaunchSettingsBanner.description')}</div>
<Button.CallToAction
label={t('core.MidnightPreLaunchSettingsBanner.ctaButtonLabel')}
onClick={onCtaButtonClick}
w="$fill"
/>
</Card.Outlined>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MidnightPreLaunchSettingsBanner } from './MidnightPreLaunchSettingsBanner';
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@
"browserView.settings.wallet.general.showPubKeyAction": "Show public key",
"browserView.settings.wallet.general.showPubKeyDescription": "This lets you import your wallet to other browsers and devices, or to restore it at a later date",
"browserView.settings.wallet.general.title": "Your keys",
"browserView.settings.wallet.midnight.prelaunch.description": "Check how to claim and FAQ",
"browserView.settings.wallet.midnight.prelaunch.title": "Midnight Pre-Launch Event",
"browserView.settings.wallet.network.description": "Switch from mainnet to testnet",
"browserView.settings.wallet.network.drawerDescription": "Select the network you would like your wallet to operate on.",
"browserView.settings.wallet.network.networkSwitched": "Switched network",
Expand Down
3 changes: 3 additions & 0 deletions packages/translation/src/lib/translations/core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@
"core.infoWallet.addressCopied": "Address copied",
"core.infoWallet.copy": "Copy",
"core.infoWallet.handleCopied": "Handle copied",
"core.MidnightPreLaunchSettingsBanner.heading": "Midnight Pre-Launch Event",
"core.MidnightPreLaunchSettingsBanner.description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna",
"core.MidnightPreLaunchSettingsBanner.ctaButtonLabel": "More details",
"core.Mint.title": "Confirm transaction",
"core.mnemonicVideoPopupContent.closeButton": "Got it",
"core.mnemonicVideoPopupContent.description": "Learn about what is a recovery phrase, and how to keep it safe from the video below.",
Expand Down