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

fix: Updated trial upgrade banner to be closer to the design #80

Merged
merged 2 commits into from
Jan 16, 2025
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
14 changes: 11 additions & 3 deletions src/components/Sidebar/Sidebar.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@use '../../utils/variables';
@use '../../utils/variables' as var;

.sidebar {
box-shadow: 0 0 1rem 0 #00000026,0 0 .625rem 0 #00000026;
top: 0;
right: 0;
bottom: 0;
z-index: 9999;
background-color: white;
background-color: var.$white;
width: 100%;
max-width: 25rem;

Expand Down Expand Up @@ -44,6 +44,14 @@

.trial-header {
font-size: 0.9em;
background-color: #F49974;
background-color: var.$brand-100;
font-size: 0.875rem;
line-height: 1.5rem;
padding: 0.5rem 0.75rem;
color: var.$black;

a {
text-decoration: underline;
}
}
}
40 changes: 19 additions & 21 deletions src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ const Sidebar = ({
</a>
);

const getDaysRemainingMessage = () => { // eslint-disable-line consistent-return
if (auditTrialDaysRemaining > 1) {
const intlRelativeTime = new Intl.RelativeTimeFormat({ style: 'long' });
return (
<div data-testid="days-remaining-message">
Your trial ends {intlRelativeTime.format(auditTrialDaysRemaining, 'day')}. {getUpgradeLink()} for full access to Xpert.
</div>
);
} if (auditTrialDaysRemaining === 1) {
return (
<div data-testid="trial-ends-today-message">
Your trial ends today! {getUpgradeLink()} for full access to Xpert.
</div>
);
}
const getDaysRemainingMessage = () => {
if (!upgradeable || auditTrialDaysRemaining < 1) { return null; }

return (
<div className="trial-header" data-testid="get-days-remaining-message">
{auditTrialDaysRemaining === 1 ? (
<div data-testid="trial-ends-today-message">
Your trial ends today! {getUpgradeLink()} for full access to Xpert.
</div>
) : (
<div data-testid="days-remaining-message">
{auditTrialDaysRemaining} days remaining. {getUpgradeLink()} for full access to Xpert.
</div>
)}
</div>
);
};

const getSidebar = () => (
Expand All @@ -90,12 +91,9 @@ const Sidebar = ({
<div className="sidebar-header" data-testid="sidebar-xpert-header">
<XpertLogo />
</div>
{upgradeable
&& (
<div className="p-3 trial-header" data-testid="get-days-remaining-message">
{getDaysRemainingMessage()}
</div>
)}

{getDaysRemainingMessage()}

<ChatBox messageList={messageList} />
{
apiError
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('<Sidebar />', () => {
render(undefined, { disclosureAcknowledged: true });
expect(screen.queryByTestId('sidebar-xpert')).toBeInTheDocument();
expect(screen.queryByTestId('get-days-remaining-message')).toBeInTheDocument();
expect(screen.queryByTestId('trial-ends-today')).not.toBeInTheDocument();
expect(screen.queryByTestId('trial-ends-today-message')).toBeInTheDocument();
});

it('should call track event on click', () => {
Expand All @@ -141,9 +141,9 @@ describe('<Sidebar />', () => {
});
render(undefined, { disclosureAcknowledged: true });
expect(screen.queryByTestId('sidebar-xpert')).toBeInTheDocument();
expect(screen.queryByTestId('get-days-remaining-message')).toBeInTheDocument();
expect(screen.queryByTestId('get-days-remaining-message')).not.toBeInTheDocument();
varshamenon4 marked this conversation as resolved.
Show resolved Hide resolved
expect(screen.queryByTestId('days-remaining-message')).not.toBeInTheDocument();
expect(screen.queryByTestId('trial-ends-today')).not.toBeInTheDocument();
expect(screen.queryByTestId('trial-ends-today-message')).not.toBeInTheDocument();
});
});

Expand Down
5 changes: 5 additions & 0 deletions src/utils/_variables.scss
varshamenon4 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ $accent-yellow: #f0cc00;
$gray-200: #cccccc !default;
$gray-300: #adadad !default;
$gray-400: #8f8f8f !default;

$brand-100: #F49974;

$black: #000;
$white: #fff;
Loading