fix: displan badge based on workspace plan (#15489)
This commit is contained in:
parent
71a57275ab
commit
b730f243dc
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
.premium-badge {
|
.premium-badge {
|
||||||
@apply inline-flex justify-center items-center rounded-full border box-border border-[rgba(255,255,255,0.8)] text-white
|
@apply inline-flex justify-center items-center rounded-md border box-border border-white/95 text-white
|
||||||
}
|
}
|
||||||
|
|
||||||
/* m is for the regular button */
|
/* m is for the regular button */
|
||||||
|
@ -62,7 +62,7 @@ const PremiumBadge: React.FC<PremiumBadgeProps> = ({
|
|||||||
<Highlight
|
<Highlight
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'absolute top-0 opacity-50 hover:opacity-80',
|
'absolute top-0 opacity-50 hover:opacity-80',
|
||||||
size === 's' ? 'h-4.5 w-12' : 'h-6 w-12',
|
size === 's' ? 'h-[18px] w-12' : 'h-6 w-12',
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
right: '50%',
|
right: '50%',
|
||||||
|
@ -7,6 +7,8 @@ import cn from '@/utils/classnames'
|
|||||||
import { switchWorkspace } from '@/service/common'
|
import { switchWorkspace } from '@/service/common'
|
||||||
import { useWorkspacesContext } from '@/context/workspace-context'
|
import { useWorkspacesContext } from '@/context/workspace-context'
|
||||||
import { ToastContext } from '@/app/components/base/toast'
|
import { ToastContext } from '@/app/components/base/toast'
|
||||||
|
import PlanBadge from '../../plan-badge'
|
||||||
|
import type { Plan } from '@/app/components/billing/type'
|
||||||
|
|
||||||
const WorkplaceSelector = () => {
|
const WorkplaceSelector = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -69,6 +71,7 @@ const WorkplaceSelector = () => {
|
|||||||
<div className='flex py-1 pl-3 pr-2 items-center gap-2 self-stretch hover:bg-state-base-hover rounded-lg' key={workspace.id} onClick={() => handleSwitchWorkspace(workspace.id)}>
|
<div className='flex py-1 pl-3 pr-2 items-center gap-2 self-stretch hover:bg-state-base-hover rounded-lg' key={workspace.id} onClick={() => handleSwitchWorkspace(workspace.id)}>
|
||||||
<div className='flex items-center justify-center w-6 h-6 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600'>{workspace.name[0].toLocaleUpperCase()}</div>
|
<div className='flex items-center justify-center w-6 h-6 bg-[#EFF4FF] rounded-md text-xs font-medium text-primary-600'>{workspace.name[0].toLocaleUpperCase()}</div>
|
||||||
<div className='line-clamp-1 grow overflow-hidden text-text-secondary text-ellipsis system-md-regular cursor-pointer'>{workspace.name}</div>
|
<div className='line-clamp-1 grow overflow-hidden text-text-secondary text-ellipsis system-md-regular cursor-pointer'>{workspace.name}</div>
|
||||||
|
<PlanBadge size='s' plan={workspace.plan as Plan} />
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,7 @@ const PlanBadge: FC<PlanBadgeProps> = ({ plan, allowHover, size = 'm', sandboxAs
|
|||||||
|
|
||||||
if (!isFetchedPlan) return null
|
if (!isFetchedPlan) return null
|
||||||
if (plan === Plan.sandbox && sandboxAsUpgrade) {
|
if (plan === Plan.sandbox && sandboxAsUpgrade) {
|
||||||
return <div className='select-none'>
|
return <PremiumBadge className='select-none' color='blue' allowHover={allowHover} onClick={onClick}>
|
||||||
<PremiumBadge color='blue' allowHover={allowHover} onClick={onClick}>
|
|
||||||
<SparklesSoft className='flex items-center py-[1px] pl-[3px] w-3.5 h-3.5 text-components-premium-badge-indigo-text-stop-0' />
|
<SparklesSoft className='flex items-center py-[1px] pl-[3px] w-3.5 h-3.5 text-components-premium-badge-indigo-text-stop-0' />
|
||||||
<div className='system-xs-medium'>
|
<div className='system-xs-medium'>
|
||||||
<span className='p-1'>
|
<span className='p-1'>
|
||||||
@ -29,40 +28,33 @@ const PlanBadge: FC<PlanBadgeProps> = ({ plan, allowHover, size = 'm', sandboxAs
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</PremiumBadge>
|
</PremiumBadge>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
if (plan === Plan.sandbox) {
|
if (plan === Plan.sandbox) {
|
||||||
return <div className='select-none'>
|
return <PremiumBadge className='select-none' size={size} color='gray' allowHover={allowHover} onClick={onClick}>
|
||||||
<PremiumBadge size={size} color='gray' allowHover={allowHover} onClick={onClick}>
|
|
||||||
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
||||||
<span className='p-1'>
|
<span className='p-1'>
|
||||||
{plan}
|
{plan}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</PremiumBadge>
|
</PremiumBadge>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
if (plan === Plan.professional) {
|
if (plan === Plan.professional) {
|
||||||
return <div className='select-none'>
|
return <PremiumBadge className='select-none' size={size} color='blue' allowHover={allowHover} onClick={onClick}>
|
||||||
<PremiumBadge size={size} color='blue' allowHover={allowHover} onClick={onClick}>
|
|
||||||
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
||||||
<span className='p-1'>
|
<span className='p-1'>
|
||||||
pro
|
pro
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</PremiumBadge>
|
</PremiumBadge>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
if (plan === Plan.team) {
|
if (plan === Plan.team) {
|
||||||
return <div className='select-none'>
|
return <PremiumBadge className='select-none' size={size} color='indigo' allowHover={allowHover} onClick={onClick}>
|
||||||
<PremiumBadge size={size} color='indigo' allowHover={allowHover} onClick={onClick}>
|
|
||||||
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
<div className={classNames(size === 's' ? 'system-2xs-medium-uppercase' : 'system-xs-medium-uppercase')}>
|
||||||
<span className='p-1'>
|
<span className='p-1'>
|
||||||
{plan}
|
{plan}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</PremiumBadge>
|
</PremiumBadge>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user