Skip to content

Commit 4ef944c

Browse files
authored
feat(select): scroll buttons (#7649)
* feat: select scroll buttons * docs: scroll buttons story added
1 parent 4c7a741 commit 4ef944c

File tree

6 files changed

+25
-46
lines changed

6 files changed

+25
-46
lines changed

apps/site/next.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const nextConfig = {
8484
'@radix-ui/react-accessible-icon',
8585
'@radix-ui/react-dropdown-menu',
8686
'@radix-ui/react-label',
87-
'@radix-ui/react-scroll-area',
8887
'@radix-ui/react-select',
8988
'@radix-ui/react-slot',
9089
'@radix-ui/react-tabs',

package-lock.json

-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ui-components/Common/Select/index.module.css

+8
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,11 @@
151151
rounded;
152152
}
153153
}
154+
155+
.scrollIcon {
156+
@apply mx-auto
157+
my-1
158+
size-4
159+
text-neutral-700
160+
dark:text-neutral-200;
161+
}

packages/ui-components/Common/Select/index.stories.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export const WithoutLabel: Story = {
2121
},
2222
};
2323

24+
export const WithScrollButtons: Story = {
25+
args: {
26+
values: Array.from({ length: 100 }, (_, i) => `Item ${i}`),
27+
defaultValue: 'Item 50',
28+
},
29+
};
30+
2431
export const DropdownLabel: Story = {
2532
args: {
2633
values: [

packages/ui-components/Common/Select/index.tsx

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

3-
import { ChevronDownIcon } from '@heroicons/react/24/outline';
4-
import * as ScrollPrimitive from '@radix-ui/react-scroll-area';
3+
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
54
import * as SelectPrimitive from '@radix-ui/react-select';
65
import classNames from 'classnames';
76
import { useEffect, useId, useMemo, useState } from 'react';
@@ -168,16 +167,15 @@ const Select = <T extends string>({
168167
[styles.inline]: inline,
169168
})}
170169
>
171-
<ScrollPrimitive.Root type="auto">
172-
<SelectPrimitive.Viewport>
173-
<ScrollPrimitive.Viewport>
174-
{memoizedMappedValues}
175-
</ScrollPrimitive.Viewport>
176-
</SelectPrimitive.Viewport>
177-
<ScrollPrimitive.Scrollbar orientation="vertical">
178-
<ScrollPrimitive.Thumb />
179-
</ScrollPrimitive.Scrollbar>
180-
</ScrollPrimitive.Root>
170+
<SelectPrimitive.ScrollUpButton>
171+
<ChevronUpIcon className={styles.scrollIcon} />
172+
</SelectPrimitive.ScrollUpButton>
173+
<SelectPrimitive.Viewport>
174+
{memoizedMappedValues}
175+
</SelectPrimitive.Viewport>
176+
<SelectPrimitive.ScrollDownButton>
177+
<ChevronDownIcon className={styles.scrollIcon} />
178+
</SelectPrimitive.ScrollDownButton>
181179
</SelectPrimitive.Content>
182180
</SelectPrimitive.Portal>
183181
</SelectPrimitive.Root>

packages/ui-components/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"@radix-ui/react-dialog": "^1.1.7",
2222
"@radix-ui/react-dropdown-menu": "~2.1.6",
2323
"@radix-ui/react-label": "~2.1.2",
24-
"@radix-ui/react-scroll-area": "~1.2.3",
2524
"@radix-ui/react-select": "~2.1.6",
2625
"@radix-ui/react-tabs": "~1.1.3",
2726
"@radix-ui/react-toast": "~1.2.6",

0 commit comments

Comments
 (0)