Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

move sticky haeder

Jonathan Summers-Muireb7ae2869fd9
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
index 24a312ae523..e703a7dd3e8 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
@@ -68,18 +68,28 @@ const Usage = () => {
const scrollTo = (id: usageSectionIds) => {
switch (id) {
case 'infra':
- if (infrastructureRef.current)
+ if (infrastructureRef.current) {
infrastructureRef.current.scrollIntoView({ behavior: 'smooth' })
+ setActiveTab('infra')
+ }
break
case 'bandwidth':
- if (bandwidthRef.current) bandwidthRef.current.scrollIntoView({ behavior: 'smooth' })
+ if (bandwidthRef.current) {
+ bandwidthRef.current.scrollIntoView({ behavior: 'smooth' })
+ setActiveTab('bandwidth')
+ }
break
case 'sizeCount':
- if (sizeAndCountsRef.current)
+ if (sizeAndCountsRef.current) {
sizeAndCountsRef.current.scrollIntoView({ behavior: 'smooth' })
+ setActiveTab('sizeCount')
+ }
break
case 'activity':
- if (activityRef.current) activityRef.current.scrollIntoView({ behavior: 'smooth' })
+ if (activityRef.current) {
+ activityRef.current.scrollIntoView({ behavior: 'smooth' })
+ setActiveTab('activity')
+ }
break
}
}
@@ -101,87 +111,93 @@ const Usage = () => {
<div className="">
<div className="1xl:px-28 mx-auto flex flex-col px-5 lg:px-16 2xl:px-32 pt-6 space-y-4">
<h3 className="text-scale-1200 text-xl">Usage</h3>
- <div className="flex items-center justify-between">
- <div className="flex items-center space-x-4">
- <Listbox
- disabled
- size="small"
- id="billingCycle"
- name="billingCycle"
- value={'current'}
- className="!w-[200px]"
- onChange={() => {}}
- >
- <Listbox.Option label="Current billing cycle" value="current">
- Current billing cycle
- </Listbox.Option>
- <Listbox.Option label="Previous billing cycle" value="previous">
- Previous billing cycle
- </Listbox.Option>
- </Listbox>
- {isLoadingSubscription ? (
- <IconLoader className="animate-spin" size={14} />
- ) : subscription !== undefined ? (
- <div className="flex flex-col xl:flex-row xl:gap-3">
- <p className={clsx('text-sm transition', isLoadingSubscription && 'opacity-50')}>
- Project is on {subscription.tier.name}
- </p>
- <p className="text-sm text-scale-1000">
- {billingCycleStart.format('DD MMM YYYY')} -{' '}
- {billingCycleEnd.format('DD MMM YYYY')}
- </p>
- </div>
- ) : null}
- </div>
- <div className="flex items-center space-x-2">
- <Link href={`/project/${selectedProjectRef}/settings/billing/invoices`}>
- <a>
- <Button type="default">View invoices</Button>
- </a>
- </Link>
- <Link href={`/project/${selectedProjectRef}/settings/billing/subscription`}>
- <a>
- <Button type="default">View billing</Button>
- </a>
- </Link>
- </div>
- </div>
</div>
</div>
<div>
<div className="lg:sticky top-0 z-10 overflow-hidden bg-scale-200 border-b">
- <div className="1xl:px-28 mx-auto px-5 lg:px-16 2xl:px-32 flex gap-6">
- {USAGE_CATEGORIES.map((category) => {
- const infraStatus =
- currentDayIoBudget <= 0
- ? USAGE_STATUS.EXCEEDED
- : currentDayIoBudget <= 20
- ? USAGE_STATUS.APPROACHING
- : USAGE_STATUS.NORMAL
- const status =
- category.key === 'infra' ? infraStatus : getUsageStatus(category.attributes, usage)
-
- return (
- <button
- role="tab"
- key={category.key}
- onClick={() => scrollTo(category.key)}
- className={cn(
- 'flex items-center space-x-2 py-3 hover:opacity-100 transition cursor-pointer',
- activeTab === category.key
- ? 'border-b border-scale-1200 text-scale-1200'
- : 'opacity-50'
- )}
+ <div className="1xl:px-28 mx-auto px-5 lg:px-16 2xl:px-32 flex flex-col gap-4">
+ <div className="flex items-center mt-4 justify-between">
+ <div className="flex items-center space-x-4">
+ <Listbox
+ disabled
+ size="small"
+ id="billingCycle"
+ name="billingCycle"
+ value={'current'}
+ className="!w-[200px]"
+ onChange={() => {}}
>
- {!usageBillingEnabled && status === USAGE_STATUS.APPROACHING ? (
- <IconAlertCircle size={15} strokeWidth={2} className="text-amber-900" />
- ) : !usageBillingEnabled && status === USAGE_STATUS.EXCEEDED ? (
- <IconAlertCircle size={15} strokeWidth={2} className="text-red-900" />
- ) : null}
- <p className="text-sm">{category.name}</p>
- </button>
- )
- })}
+ <Listbox.Option label="Current billing cycle" value="current">
+ Current billing cycle
+ </Listbox.Option>
+ <Listbox.Option label="Previous billing cycle" value="previous">
+ Previous billing cycle
+ </Listbox.Option>
+ </Listbox>
+ {isLoadingSubscription ? (
+ <IconLoader className="animate-spin" size={14} />
+ ) : subscription !== undefined ? (
+ <div className="flex flex-col xl:flex-row xl:gap-3">
+ <p
+ className={clsx('text-sm transition', isLoadingSubscription && 'opacity-50')}
+ >
+ Project is on {subscription.tier.name}
+ </p>
+ <p className="text-sm text-scale-1000">
+ {billingCycleStart.format('DD MMM YYYY')} -{' '}
+ {billingCycleEnd.format('DD MMM YYYY')}
+ </p>
+ </div>
+ ) : null}
+ </div>
+ <div className="flex items-center space-x-2">
+ <Link href={`/project/${selectedProjectRef}/settings/billing/invoices`}>
+ <a>
+ <Button type="default">View invoices</Button>
+ </a>
+ </Link>
+ <Link href={`/project/${selectedProjectRef}/settings/billing/subscription`}>
+ <a>
+ <Button type="default">View billing</Button>
+ </a>
+ </Link>
+ </div>
+ </div>
+ <div className="flex gap-6">
+ {USAGE_CATEGORIES.map((category) => {
+ const infraStatus =
+ currentDayIoBudget <= 0
+ ? USAGE_STATUS.EXCEEDED
+ : currentDayIoBudget <= 20
+ ? USAGE_STATUS.APPROACHING
+ : USAGE_STATUS.NORMAL
+ const status =
+ category.key === 'infra'
+ ? infraStatus
+ : getUsageStatus(category.attributes, usage)
+
+ return (
+ <button
+ role="tab"
+ key={category.key}
+ onClick={() => scrollTo(category.key)}
+ className={cn(
+ 'flex items-center space-x-2 py-3 hover:opacity-100 transition cursor-pointer',
+ activeTab === category.key
+ ? 'border-b border-scale-1200 text-scale-1200'
+ : 'opacity-50'
+ )}
+ >
+ {!usageBillingEnabled && status === USAGE_STATUS.APPROACHING ? (
+ <IconAlertCircle size={15} strokeWidth={2} className="text-amber-900" />
+ ) : !usageBillingEnabled && status === USAGE_STATUS.EXCEEDED ? (
+ <IconAlertCircle size={15} strokeWidth={2} className="text-red-900" />
+ ) : null}
+ <p className="text-sm">{category.name}</p>
+ </button>
+ )
+ })}
+ </div>
</div>
</div>
@@ -195,7 +211,7 @@ const Usage = () => {
<InView
as="div"
id="infrastructure"
- onChange={(inView, entry) => (inView || entry) && setActiveTab('infra')}
+ onChange={(inView, entry) => inView && setActiveTab('infra')}
>
<div ref={infrastructureRef}>
<Infrastructure projectRef={selectedProjectRef} />
@@ -204,7 +220,7 @@ const Usage = () => {
<InView
as="div"
id="bandwidth"
- onChange={(inView, entry) => (inView || entry) && setActiveTab('bandwidth')}
+ onChange={(inView, entry) => inView && setActiveTab('bandwidth')}
>
<div ref={bandwidthRef}>
<Bandwidth projectRef={selectedProjectRef} />
@@ -213,7 +229,7 @@ const Usage = () => {
<InView
as="div"
id="size_and_counts"
- onChange={(inView, entry) => (inView || entry) && setActiveTab('sizeCount')}
+ onChange={(inView, entry) => inView && setActiveTab('sizeCount')}
>
<div ref={sizeAndCountsRef}>
<SizeAndCounts projectRef={selectedProjectRef} />
@@ -222,7 +238,7 @@ const Usage = () => {
<InView
as="div"
id="activity"
- onChange={(inView, entry) => (inView || entry) && setActiveTab('activity')}
+ onChange={(inView, entry) => inView && setActiveTab('activity')}
>
<div ref={activityRef}>
<Activity projectRef={selectedProjectRef} />