1
- import { useMemo , useState } from "react" ;
2
- import { css } from "@emotion/react" ;
1
+ import { useMemo } from "react" ;
3
2
4
3
import {
5
- ActionButton ,
6
- DropdownMenu ,
7
- DropdownTrigger ,
8
- Item ,
9
- ListBox ,
10
- } from "@arizeai/components" ;
11
-
4
+ Button ,
5
+ Icon ,
6
+ Icons ,
7
+ Menu ,
8
+ MenuItem ,
9
+ MenuTrigger ,
10
+ Popover ,
11
+ } from "@phoenix/components" ;
12
12
import { useInferences , usePointCloudContext } from "@phoenix/contexts" ;
13
13
import { ClusterSort } from "@phoenix/store" ;
14
14
@@ -25,7 +25,6 @@ export function ClusterSortPicker() {
25
25
const hasReferenceInferences = ! ! referenceInferences ;
26
26
const sort = usePointCloudContext ( ( state ) => state . clusterSort ) ;
27
27
const setSort = usePointCloudContext ( ( state ) => state . setClusterSort ) ;
28
- const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
29
28
const items = useMemo < Item [ ] > ( ( ) => {
30
29
const dynamicItems : Item [ ] = [ ] ;
31
30
if ( hasReferenceInferences ) {
@@ -71,70 +70,34 @@ export function ClusterSortPicker() {
71
70
} , [ hasReferenceInferences ] ) ;
72
71
const selectedSortKey = getSortKey ( sort ) ;
73
72
return (
74
- < div
75
- css = { css `
76
- .ac-action-button {
77
- background : none;
78
- border : none;
79
- color : ${ "var(--ac-global-text-color-700)" } ;
80
- font-size : var (--ac-global-font-size-xs );
81
- line-height : var (--ac-global-line-height-xs );
82
- cursor : pointer;
83
- outline : none;
84
- & : hover {
85
- color : var (--ac-global-text-color-900 );
86
- }
87
- }
88
- ` }
89
- >
90
- < DropdownTrigger
91
- placement = "bottom right"
92
- aria-label = "Sort clusters by"
93
- isOpen = { isOpen }
94
- onOpenChange = { ( newIsOpen ) => setIsOpen ( newIsOpen ) }
95
- >
96
- < ActionButton >
97
- Sort
98
- < span
99
- aria-hidden
100
- data-testid = "dropdown-caret"
101
- css = { css `
102
- margin-left : var (--ac-global-dimension-static-size-50 );
103
- border-bottom-color : # 0000 ;
104
- border-left-color : # 0000 ;
105
- border-right-color : # 0000 ;
106
- border-style : solid;
107
- border-width : 3px 3px 0 ;
108
- content : "" ;
109
- display : inline-block;
110
- height : 0 ;
111
- vertical-align : middle;
112
- width : 0 ;
113
- ` }
114
- />
115
- </ ActionButton >
116
- < DropdownMenu >
117
- < ListBox
118
- style = { { width : 200 } }
119
- selectedKeys = { [ selectedSortKey ] }
120
- selectionMode = "single"
121
- items = { items }
122
- onSelectionChange = { ( selection ) => {
123
- if ( selection instanceof Set && selection . size > 0 ) {
124
- const [ sortKey ] = selection . values ( ) ;
125
- const [ column , dir ] = ( sortKey as string ) . split ( ":" ) ;
126
- setSort ( {
127
- column : column as ClusterSort [ "column" ] ,
128
- dir : dir as ClusterSort [ "dir" ] ,
129
- } ) ;
130
- }
131
- setIsOpen ( false ) ;
132
- } }
133
- >
134
- { ( item ) => < Item key = { item . value } > { item . label } </ Item > }
135
- </ ListBox >
136
- </ DropdownMenu >
137
- </ DropdownTrigger >
138
- </ div >
73
+ < MenuTrigger aria-label = "Sort clusters by" >
74
+ < Button trailingVisual = { < Icon svg = { < Icons . ChevronDown /> } /> } size = "S" >
75
+ Sort
76
+ </ Button >
77
+ < Popover >
78
+ < Menu
79
+ style = { { width : 200 } }
80
+ selectedKeys = { [ selectedSortKey ] }
81
+ selectionMode = "single"
82
+ items = { items }
83
+ onSelectionChange = { ( selection ) => {
84
+ if ( selection instanceof Set && selection . size > 0 ) {
85
+ const [ sortKey ] = selection . values ( ) ;
86
+ const [ column , dir ] = ( sortKey as string ) . split ( ":" ) ;
87
+ setSort ( {
88
+ column : column as ClusterSort [ "column" ] ,
89
+ dir : dir as ClusterSort [ "dir" ] ,
90
+ } ) ;
91
+ }
92
+ } }
93
+ >
94
+ { ( item ) => (
95
+ < MenuItem key = { item . value } id = { item . value } textValue = { item . value } >
96
+ { item . label }
97
+ </ MenuItem >
98
+ ) }
99
+ </ Menu >
100
+ </ Popover >
101
+ </ MenuTrigger >
139
102
) ;
140
103
}
0 commit comments