mirror of
https://github.com/hanzoai/o11y-components.git
synced 2026-10-30 14:54:15 +00:00
A version written into a manifest is written into every manifest that wants it, which is how eslint came to exist in a hundred and four forms across this estate and how a package came to resolve twice at run time. The catalog moves the number out of the manifest: a manifest names the package, the workspace names the version. Four are held below their latest because the newer release cannot be used, and the reason is recorded rather than the version alone: @noble/hashes 2 renamed every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels 3 points its types condition at the bundle.
182 lines
4.6 KiB
TypeScript
182 lines
4.6 KiB
TypeScript
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectScrollDownButton,
|
|
SelectScrollUpButton,
|
|
SelectTrigger,
|
|
SelectViewport,
|
|
} from '@signozhq/ui';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { useState } from 'react';
|
|
|
|
const meta: Meta = {
|
|
title: 'Primitive Components/Select/SelectScrollButtons',
|
|
parameters: {
|
|
layout: 'fullscreen',
|
|
},
|
|
tags: ['autodocs'],
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj;
|
|
|
|
const manyItems = Array.from({ length: 50 }, (_, i) => ({
|
|
value: `item-${i + 1}`,
|
|
label: `Item ${i + 1}`,
|
|
}));
|
|
|
|
export const WithScrollButtons: Story = {
|
|
render: () => {
|
|
const [value, setValue] = useState('');
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<p
|
|
style={{
|
|
marginBottom: 16,
|
|
fontSize: 14,
|
|
lineHeight: 1.42857,
|
|
color: 'var(--muted-foreground)',
|
|
}}
|
|
>
|
|
ScrollUpButton and ScrollDownButton provide visual affordances for scrolling when the
|
|
content overflows. They appear at the top/bottom of the viewport when there is more
|
|
content to scroll.
|
|
</p>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger placeholder="Select an item..." />
|
|
<SelectContent withViewport={false}>
|
|
<SelectScrollUpButton />
|
|
<SelectViewport style={{ maxHeight: '200px' }}>
|
|
{manyItems.map((item) => (
|
|
<SelectItem key={item.value} value={item.value}>
|
|
{item.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectViewport>
|
|
<SelectScrollDownButton />
|
|
</SelectContent>
|
|
</Select>
|
|
<p
|
|
style={{
|
|
marginTop: 16,
|
|
fontSize: 14,
|
|
lineHeight: 1.42857,
|
|
color: 'var(--muted-foreground)',
|
|
}}
|
|
>
|
|
Selected: {value || 'none'}
|
|
</p>
|
|
</div>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const ScrollUpButtonOnly: Story = {
|
|
render: () => {
|
|
const [value, setValue] = useState('item-50');
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<p
|
|
style={{
|
|
marginBottom: 16,
|
|
fontSize: 14,
|
|
lineHeight: 1.42857,
|
|
color: 'var(--muted-foreground)',
|
|
}}
|
|
>
|
|
SelectScrollUpButton appears when scrolled down and there is content above.
|
|
</p>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger placeholder="Select an item..." />
|
|
<SelectContent withViewport={false}>
|
|
<SelectScrollUpButton />
|
|
<SelectViewport style={{ maxHeight: '200px' }}>
|
|
{manyItems.map((item) => (
|
|
<SelectItem key={item.value} value={item.value}>
|
|
{item.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectViewport>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const ScrollDownButtonOnly: Story = {
|
|
render: () => {
|
|
const [value, setValue] = useState('');
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<p
|
|
style={{
|
|
marginBottom: 16,
|
|
fontSize: 14,
|
|
lineHeight: 1.42857,
|
|
color: 'var(--muted-foreground)',
|
|
}}
|
|
>
|
|
SelectScrollDownButton appears when there is more content below.
|
|
</p>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger placeholder="Select an item..." />
|
|
<SelectContent withViewport={false}>
|
|
<SelectViewport style={{ maxHeight: '200px' }}>
|
|
{manyItems.map((item) => (
|
|
<SelectItem key={item.value} value={item.value}>
|
|
{item.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectViewport>
|
|
<SelectScrollDownButton />
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const CustomScrollButtonContent: Story = {
|
|
render: () => {
|
|
const [value, setValue] = useState('');
|
|
|
|
return (
|
|
<div style={{ padding: 32, width: '100%', maxWidth: 384 }}>
|
|
<p
|
|
style={{
|
|
marginBottom: 16,
|
|
fontSize: 14,
|
|
lineHeight: 1.42857,
|
|
color: 'var(--muted-foreground)',
|
|
}}
|
|
>
|
|
You can provide custom content to the scroll buttons.
|
|
</p>
|
|
<Select value={value} onChange={(v) => setValue(v as string)}>
|
|
<SelectTrigger placeholder="Select an item..." />
|
|
<SelectContent withViewport={false}>
|
|
<SelectScrollUpButton>
|
|
<span style={{ fontSize: 12, lineHeight: 1.33333 }}>Scroll Up</span>
|
|
</SelectScrollUpButton>
|
|
<SelectViewport style={{ maxHeight: '200px' }}>
|
|
{manyItems.map((item) => (
|
|
<SelectItem key={item.value} value={item.value}>
|
|
{item.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectViewport>
|
|
<SelectScrollDownButton>
|
|
<span style={{ fontSize: 12, lineHeight: 1.33333 }}>Scroll Down</span>
|
|
</SelectScrollDownButton>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
},
|
|
};
|