Skip to content

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

Fix weird margin issue in barchart (#27948)

Joshen Limfe4f3fc30cff
diff --git a/apps/studio/components/interfaces/Home/ProjectUsage.tsx b/apps/studio/components/interfaces/Home/ProjectUsage.tsx
index 119de7d1fca..ed2efedecb6 100644
--- a/apps/studio/components/interfaces/Home/ProjectUsage.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectUsage.tsx
@@ -1,5 +1,6 @@
import dayjs from 'dayjs'
import sumBy from 'lodash/sumBy'
+import { Archive, ChevronDown, Database, Key, Zap } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
@@ -18,11 +19,6 @@ import {
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuTrigger,
- IconArchive,
- IconChevronDown,
- IconDatabase,
- IconKey,
- IconZap,
Loading,
} from 'ui'
@@ -49,7 +45,7 @@ const ProjectUsage = () => {
const [interval, setInterval] = useState<string>('hourly')
- const { data, error, isLoading } = useProjectLogStatsQuery({ projectRef, interval })
+ const { data, isLoading } = useProjectLogStatsQuery({ projectRef, interval })
const selectedInterval = CHART_INTERVALS.find((i) => i.key === interval) || CHART_INTERVALS[1]
const startDateLocal = dayjs().subtract(
@@ -87,10 +83,10 @@ const ProjectUsage = () => {
return (
<div className="space-y-6">
- <div className="flex flex-row items-center gap-2">
+ <div className="flex flex-row items-center gap-x-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button type="default" iconRight={<IconChevronDown />}>
+ <Button type="default" iconRight={<ChevronDown size={14} />}>
<span>{selectedInterval.label}</span>
</Button>
</DropdownMenuTrigger>
@@ -108,13 +104,13 @@ const ProjectUsage = () => {
Statistics for past {selectedInterval.label}
</span>
</div>
- <div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4 lg:gap-8">
+ <div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4">
<Panel>
<Panel.Content className="space-y-4">
<PanelHeader
icon={
<div className="rounded bg-surface-300 p-1.5 text-foreground-light shadow-sm">
- <IconDatabase strokeWidth={2} size={16} />
+ <Database strokeWidth={2} size={16} />
</div>
}
title="Database"
@@ -140,7 +136,7 @@ const ProjectUsage = () => {
<PanelHeader
icon={
<div className="rounded bg-surface-300 p-1.5 text-foreground-light shadow-sm">
- <IconKey strokeWidth={2} size={16} />
+ <Key strokeWidth={2} size={16} />
</div>
}
title="Auth"
@@ -166,7 +162,7 @@ const ProjectUsage = () => {
<PanelHeader
icon={
<div className="rounded bg-surface-300 p-1.5 text-foreground-light shadow-sm">
- <IconArchive strokeWidth={2} size={16} />
+ <Archive strokeWidth={2} size={16} />
</div>
}
title="Storage"
@@ -192,7 +188,7 @@ const ProjectUsage = () => {
<PanelHeader
icon={
<div className="rounded bg-surface-300 p-1.5 text-foreground-light shadow-sm">
- <IconZap strokeWidth={2} size={16} />
+ <Zap strokeWidth={2} size={16} />
</div>
}
title="Realtime"
diff --git a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
index 7ec786e35ea..16eab01497b 100644
--- a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
@@ -1,4 +1,5 @@
import dayjs from 'dayjs'
+import { AlertCircle } from 'lucide-react'
import { NewProjectPanel } from 'components/interfaces/Home'
import { ProjectUsageLoadingState } from 'components/layouts/ProjectLayout/LoadingState'
@@ -6,7 +7,6 @@ import InformationBox from 'components/ui/InformationBox'
import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query'
import { useProjectLogStatsQuery } from 'data/analytics/project-log-stats-query'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
-import { IconAlertCircle } from 'ui'
import ProjectUsage from './ProjectUsage'
const ProjectUsageSection = () => {
@@ -30,7 +30,7 @@ const ProjectUsageSection = () => {
<InformationBox
hideCollapse
defaultVisibility
- icon={<IconAlertCircle strokeWidth={2} />}
+ icon={<AlertCircle size={18} strokeWidth={2} />}
title="There was an issue loading the usage details of your project"
/>
)
diff --git a/apps/studio/components/ui/Charts/BarChart.tsx b/apps/studio/components/ui/Charts/BarChart.tsx
index 5820707abc9..76c5e95991b 100644
--- a/apps/studio/components/ui/Charts/BarChart.tsx
+++ b/apps/studio/components/ui/Charts/BarChart.tsx
@@ -105,7 +105,7 @@ const BarChart = ({
}
return (
- <div className={['flex flex-col gap-3', className].join(' ')}>
+ <div className={['flex flex-col gap-y-3', className].join(' ')}>
<ChartHeader
title={title}
format={format}
@@ -124,7 +124,7 @@ const BarChart = ({
margin={{
top: 0,
right: 0,
- left: 0,
+ left: -58, // [Joshen] 120724 Not sure why bar charts have a weird left margin suddenly, but this is a temp fix
bottom: 0,
}}
className="overflow-visible"
diff --git a/apps/studio/components/ui/Charts/Charts.utils.tsx b/apps/studio/components/ui/Charts/Charts.utils.tsx
index 23f8d773004..1e8b2b436cd 100644
--- a/apps/studio/components/ui/Charts/Charts.utils.tsx
+++ b/apps/studio/components/ui/Charts/Charts.utils.tsx
@@ -1,9 +1,11 @@
import dayjs from 'dayjs'
-import React, { useMemo } from 'react'
+import utc from 'dayjs/plugin/utc'
+import { FC, PropsWithChildren, useMemo } from 'react'
import { ResponsiveContainer } from 'recharts'
+
import { DateTimeFormats } from './Charts.constants'
import type { CommonChartProps, StackedChartProps } from './Charts.types'
-import utc from 'dayjs/plugin/utc'
+
dayjs.extend(utc)
/**
@@ -81,7 +83,7 @@ export const useChartSize = (
}
) => {
const minHeight = sizeMap[size]
- const Container: React.FC<React.PropsWithChildren> = useMemo(
+ const Container: FC<PropsWithChildren> = useMemo(
() =>
({ children }) => (
<ResponsiveContainer height={minHeight} minHeight={minHeight} width="100%">
diff --git a/apps/studio/components/ui/Charts/NoDataPlaceholder.tsx b/apps/studio/components/ui/Charts/NoDataPlaceholder.tsx
index 24f1a9950e4..f50878890a7 100644
--- a/apps/studio/components/ui/Charts/NoDataPlaceholder.tsx
+++ b/apps/studio/components/ui/Charts/NoDataPlaceholder.tsx
@@ -1,6 +1,8 @@
import { BarChart2 } from 'lucide-react'
-import { useChartSize } from './Charts.utils'
+
+import { cn } from 'ui'
import ChartHeader from './ChartHeader'
+import { useChartSize } from './Charts.utils'
interface NoDataPlaceholderProps {
title?: string
@@ -27,15 +29,15 @@ const NoDataPlaceholder = ({
<ChartHeader title={attribute} format={format} highlightedValue={0} />
)}
<div
- className={
- 'border-control flex flex-grow w-full flex-col items-center justify-center space-y-2 border border-dashed text-center ' +
+ className={cn(
+ 'border-control flex flex-grow w-full flex-col items-center justify-center space-y-2 border border-dashed text-center',
className
- }
+ )}
// extra 20 px for the x ticks
style={{ minHeight: minHeight + 20 }}
>
<BarChart2 size={20} className="text-border-stronger" />
- <div>
+ <div className="px-1">
<p className="text-foreground-light text-xs">{message}</p>
{description && <p className="text-foreground-lighter text-xs">{description}</p>}
</div>