11import { AccessibleContent } from "@instructure/ui-a11y-content" ;
22import { Alert } from "@instructure/ui-alerts" ;
3- import { Badge } from "@instructure/ui-badge" ;
43import { IconLaunchLine } from "@instructure/ui-icons" ;
54import { Select } from "@instructure/ui-select" ;
65import { Tag } from "@instructure/ui-tag" ;
76import { Text } from "@instructure/ui-text" ;
7+ import { View } from "@instructure/ui-view" ;
88import React , {
99 type FocusEvent ,
1010 type KeyboardEvent ,
@@ -16,7 +16,6 @@ import Features, {
1616 type FeatureInterface ,
1717 type FeaturesType ,
1818} from "../assets/Features" ;
19- import Stages from "../assets/Stages" ;
2019import type { SignupFormMultiSelectProps } from "./SignupForm" ;
2120
2221const FeatureSelect : React . FC < SignupFormMultiSelectProps > = ( {
@@ -126,43 +125,33 @@ const FeatureSelect: React.FC<SignupFormMultiSelectProps> = ({
126125 . find ( ( o ) => o ?. id === id ) ;
127126 } ;
128127
129- const stageColorMap = Stages . reduce < Record < string , string > > ( ( acc , stage ) => {
130- acc [ stage . name ] = stage . color ;
131- return acc ;
132- } , { } ) ;
133-
134- const renderGroupLabel = ( key : string , count : number ) => {
135- const color = stageColorMap [ key ] ;
128+ const renderGroupLabel = ( key : string ) => {
129+ const group = filteredOptions [ key ] ;
130+ const BrandIcon = group ?. [ 0 ] ?. colorIcon ;
136131 return (
137- < Text >
138- < Badge
139- count = { count }
140- margin = "0 x-small xxx-small 0"
141- standalone
142- themeOverride = { { colorPrimary : color } }
143- />
144- { key }
145- </ Text >
132+ < >
133+ { BrandIcon && < BrandIcon /> }
134+ < View margin = "0 0 0 small" >
135+ < Text > { key } </ Text >
136+ </ View >
137+ </ >
146138 ) ;
147139 } ;
148140
149141 const renderGroup = ( ) : React . ReactNode => {
150142 return Object . keys ( filteredOptions )
151143 . filter ( ( key ) => filteredOptions [ key ] && filteredOptions [ key ] . length > 0 )
152144 . map ( ( key ) => (
153- < Select . Group
154- key = { key }
155- renderLabel = { renderGroupLabel ( key , filteredOptions [ key ] . length ) }
156- >
157- { filteredOptions [ key ] . map ( ( option ) => (
145+ < Select . Group key = { key } renderLabel = { renderGroupLabel ( key ) } >
146+ { filteredOptions [ key ] . map ( ( option : FeatureInterface ) => (
158147 < Select . Option
159148 id = { option . id }
160149 isHighlighted = { option . id === highlightedOptionId }
161150 key = { option . id }
162- renderBeforeLabel = { option . icon ? < option . icon /> : null }
151+ // renderBeforeLabel={option.icon ? <option.icon /> : null}
163152 value = { option . label }
164153 >
165- { option . label }
154+ < View margin = "0 0 0 medium" > { option . label } </ View >
166155 </ Select . Option >
167156 ) ) }
168157 </ Select . Group >
@@ -197,6 +186,13 @@ const FeatureSelect: React.FC<SignupFormMultiSelectProps> = ({
197186 ( id : string , index : number ) : React . JSX . Element | null => {
198187 const option = getOptionById ( id ) ;
199188 if ( ! option ) return null ;
189+ const groupKey = Object . keys ( filteredOptions ) . find ( ( key ) =>
190+ filteredOptions [ key ] . some ( ( opt : FeatureInterface ) => opt . id === id ) ,
191+ ) ;
192+ const BrandIcon =
193+ groupKey && filteredOptions [ groupKey ] [ 0 ] ?. colorIcon
194+ ? filteredOptions [ groupKey ] [ 0 ] . colorIcon
195+ : null ;
200196 return (
201197 < Tag
202198 dismissible
@@ -207,7 +203,7 @@ const FeatureSelect: React.FC<SignupFormMultiSelectProps> = ({
207203 onClick = { ( e : React . MouseEvent ) => dismissTag ( e , id ) }
208204 text = {
209205 < AccessibleContent alt = { `Remove ${ option . label } ` } >
210- { option . icon && < option . icon /> } { option . label }
206+ { BrandIcon && < BrandIcon /> } { option . label }
211207 </ AccessibleContent >
212208 }
213209 />
0 commit comments