mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
chore: better list visuals (#29343)
This commit is contained in:
BIN
frontend/__snapshots__/components-sparkline--bar-chart--dark.png
Normal file
BIN
frontend/__snapshots__/components-sparkline--bar-chart--dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 982 B |
Binary file not shown.
|
After Width: | Height: | Size: 982 B |
20
frontend/src/lib/components/Sparkline.stories.tsx
Normal file
20
frontend/src/lib/components/Sparkline.stories.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Meta, StoryFn, StoryObj } from '@storybook/react'
|
||||
|
||||
import { Sparkline } from './Sparkline'
|
||||
|
||||
type Story = StoryObj<typeof Sparkline>
|
||||
const meta: Meta<typeof Sparkline> = {
|
||||
title: 'Components/Sparkline',
|
||||
component: Sparkline,
|
||||
}
|
||||
export default meta
|
||||
|
||||
const Template: StoryFn<typeof Sparkline> = (args) => {
|
||||
return <Sparkline {...args} className="w-full" />
|
||||
}
|
||||
|
||||
export const BarChart: Story = Template.bind({})
|
||||
BarChart.args = {
|
||||
data: [10, 5, 3, 30, 22, 10, 2],
|
||||
labels: ['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'],
|
||||
}
|
||||
@@ -71,6 +71,7 @@ export function Sparkline({
|
||||
borderColor: color,
|
||||
borderWidth: type === 'line' ? 2 : 0,
|
||||
pointRadius: 0,
|
||||
borderRadius: 2,
|
||||
}
|
||||
}),
|
||||
},
|
||||
@@ -116,6 +117,7 @@ export function Sparkline({
|
||||
display: true,
|
||||
tickLength: 0,
|
||||
},
|
||||
border: { display: false },
|
||||
alignToPixels: true,
|
||||
afterFit: (axis) => {
|
||||
// Remove unneccessary padding
|
||||
|
||||
@@ -59,8 +59,8 @@ export function ErrorTrackingScene(): JSX.Element {
|
||||
occurrences: { align: 'center', render: CountColumn },
|
||||
sessions: { align: 'center', render: CountColumn },
|
||||
users: { align: 'center', render: CountColumn },
|
||||
volume: { renderTitle: VolumeColumnHeader, render: VolumeColumn },
|
||||
assignee: { render: AssigneeColumn },
|
||||
volume: { align: 'right', renderTitle: VolumeColumnHeader, render: VolumeColumn },
|
||||
assignee: { align: 'center', render: AssigneeColumn },
|
||||
},
|
||||
showOpenEditorButton: false,
|
||||
insightProps: insightProps,
|
||||
@@ -103,7 +103,11 @@ const VolumeColumn: QueryContextColumnComponent = (props) => {
|
||||
? [record.aggregations.customVolume, sparklineLabels(customSparklineConfig)]
|
||||
: [null, null]
|
||||
|
||||
return data ? <Sparkline className="h-8" data={data} labels={labels} /> : null
|
||||
return data ? (
|
||||
<div className="flex justify-end">
|
||||
<Sparkline className="h-8" data={data} labels={labels} />
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
|
||||
const VolumeColumnHeader: QueryContextColumnTitleComponent = ({ columnName }) => {
|
||||
@@ -160,7 +164,7 @@ const CustomGroupTitleColumn: QueryContextColumnComponent = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
className="flex-1"
|
||||
className="flex-1 pr-12"
|
||||
to={urls.errorTrackingIssue(record.id)}
|
||||
onClick={() => {
|
||||
const issueLogic = errorTrackingIssueSceneLogic({ id: record.id })
|
||||
@@ -176,12 +180,16 @@ const CountColumn = ({ record, columnName }: { record: unknown; columnName: stri
|
||||
const aggregations = (record as ErrorTrackingIssue).aggregations as ErrorTrackingIssueAggregations
|
||||
const count = aggregations[columnName as 'occurrences' | 'sessions' | 'users']
|
||||
|
||||
return columnName === 'sessions' && count === 0 ? (
|
||||
<Tooltip title="No $session_id was set for any event in this issue" delayMs={0}>
|
||||
-
|
||||
</Tooltip>
|
||||
) : (
|
||||
<>{humanFriendlyLargeNumber(count)}</>
|
||||
return (
|
||||
<span className="text-lg font-medium">
|
||||
{columnName === 'sessions' && count === 0 ? (
|
||||
<Tooltip title="No $session_id was set for any event in this issue" delayMs={0}>
|
||||
-
|
||||
</Tooltip>
|
||||
) : (
|
||||
humanFriendlyLargeNumber(count)
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user