Compile timeout- Adding the paywall component (#23606)

* adding the upgrade prompt component

* adding the container queries for cards

* removing comment

* styles:lint:fix

* adding ? for checking

GitOrigin-RevId: 63250f73fa543b510423835633de04eff69c47c5
This commit is contained in:
Davinder Singh
2025-02-17 09:04:40 +00:00
committed by Copybot
parent 05045ee9f7
commit cd7b1bf649
3 changed files with 33 additions and 8 deletions
@@ -1,6 +1,7 @@
import getMeta from '@/utils/meta' import getMeta from '@/utils/meta'
import { useMemo } from 'react' import { useMemo, useState } from 'react'
import TimeoutMessageAfterPaywallDismissal from './timeout-message-after-paywall-dismissal' import TimeoutMessageAfterPaywallDismissal from './timeout-message-after-paywall-dismissal'
import { UpgradePrompt } from '@/shared/components/upgrade-prompt'
const studentRoles = [ const studentRoles = [
'High-school student', 'High-school student',
@@ -9,18 +10,34 @@ const studentRoles = [
'Doctoral student (e.g. PhD, MD, EngD)', 'Doctoral student (e.g. PhD, MD, EngD)',
] ]
// We can display TimeoutMessageAfterPaywallDismissal after the user has dismissed the paywall. That logic can be implemented in this file or somewhere else?
function TimeoutUpgradePaywallPrompt() { function TimeoutUpgradePaywallPrompt() {
const odcRole = getMeta('ol-odcRole') const odcRole = getMeta('ol-odcRole')
const planPrices = getMeta('ol-paywallPlans') const planPrices = getMeta('ol-paywallPlans')
const isStudent = useMemo(() => studentRoles.includes(odcRole), [odcRole]) const isStudent = useMemo(() => studentRoles.includes(odcRole), [odcRole])
const [isPaywallDismissed, setIsPaywallDismissed] = useState<boolean>(false)
function onClose() {
setIsPaywallDismissed(true)
}
return ( return (
<div> <div>
<p>Current user is {!isStudent && 'not'} a student.</p> {!isPaywallDismissed ? (
<p>Student plan: {planPrices.student} per month</p> <UpgradePrompt
<p>Standard plan: {planPrices.collaborator} per month</p> title="Unlock more compile time"
<TimeoutMessageAfterPaywallDismissal /> summary="Your project took too long to compile and timed out."
onClose={onClose}
planPricing={{
student: planPrices?.student,
standard: planPrices?.collaborator,
}}
itmCampaign="storybook"
isStudent={isStudent}
/>
) : (
<TimeoutMessageAfterPaywallDismissal />
)}
</div> </div>
) )
} }
@@ -76,7 +76,7 @@ export function UpgradePrompt({
<p className="upgrade-prompt-summary">{summary}</p> <p className="upgrade-prompt-summary">{summary}</p>
</OLRow> </OLRow>
<OLRow className="g-3"> <OLRow className="g-3">
<OLCol md={6}> <OLCol md={6} className="upgrade-prompt-card-container">
<div className="g-0 upgrade-prompt-card upgrade-prompt-card-premium"> <div className="g-0 upgrade-prompt-card upgrade-prompt-card-premium">
<OLRow className="justify-content-between"> <OLRow className="justify-content-between">
<OLCol> <OLCol>
@@ -117,7 +117,7 @@ export function UpgradePrompt({
</OLRow> </OLRow>
</div> </div>
</OLCol> </OLCol>
<OLCol md={6}> <OLCol md={6} className="upgrade-prompt-card-container">
<div className="g-0 upgrade-prompt-card upgrade-prompt-card-free"> <div className="g-0 upgrade-prompt-card upgrade-prompt-card-free">
<OLRow> <OLRow>
<h3>{t('free')}</h3> <h3>{t('free')}</h3>
@@ -2,6 +2,14 @@
border-radius: var(--border-radius-base); border-radius: var(--border-radius-base);
box-shadow: 0 4px 6px 0 #1e25301f; box-shadow: 0 4px 6px 0 #1e25301f;
padding: var(--spacing-06); padding: var(--spacing-06);
background-color: var(--white);
container: inline-size; // Defines the parent as a container
.upgrade-prompt-card-container {
@container (max-width: 700px) {
width: 100%;
}
}
.row { .row {
margin-left: 0; margin-left: 0;