77 type ScopeType ,
88 type SimpleScopeTypeType ,
99} from "@cursorless/common" ;
10- import React from "react" ;
10+ import React , { useEffect , useState } from "react" ;
1111
1212export function MissingLanguageScopes ( ) : React . JSX . Element [ ] {
1313 return Object . keys ( languageScopeSupport )
@@ -35,7 +35,13 @@ function Language({
3535
3636 return (
3737 < >
38- < h3 > { languageId } </ h3 >
38+ < h3 >
39+ { languageId }
40+
41+ < small className = "ml-2 text-sm" >
42+ < a href = { `../../user/languages/${ languageId } ` } > link</ a >
43+ </ small >
44+ </ h3 >
3945 { renderFacets ( "Unsupported" , unsupportedFacets ) }
4046 { renderFacets ( "Unspecified" , unspecifiedFacets ) }
4147 </ >
@@ -46,27 +52,49 @@ function renderFacets(
4652 title : string ,
4753 facets : ScopeSupportFacet [ ] ,
4854) : React . JSX . Element | null {
49- const scopes = Array . from (
50- new Set (
51- facets . map ( ( f ) =>
52- serializeScopeType ( scopeSupportFacetInfos [ f ] . scopeType ) ,
55+ const [ open , setOpen ] = useState ( false ) ;
56+ const [ scopes , setScopes ] = useState < string [ ] > ( [ ] ) ;
57+
58+ useEffect ( ( ) => {
59+ const scopes = Array . from (
60+ new Set (
61+ facets . map ( ( f ) =>
62+ serializeScopeType ( scopeSupportFacetInfos [ f ] . scopeType ) ,
63+ ) ,
5364 ) ,
54- ) ,
55- ) . sort ( ) ;
65+ ) . sort ( ) ;
66+ setScopes ( scopes ) ;
67+ setOpen ( scopes . length < 4 ) ;
68+ } , [ ] ) ;
5669
5770 if ( scopes . length === 0 ) {
5871 return null ;
5972 }
6073
74+ const renderBody = ( ) => {
75+ if ( ! open ) {
76+ return null ;
77+ }
78+
79+ return (
80+ < div className = "card__body" >
81+ < ul >
82+ { scopes . map ( ( scope ) => {
83+ return < li key = { scope } > { scope } </ li > ;
84+ } ) }
85+ </ ul >
86+ </ div >
87+ ) ;
88+ } ;
89+
6190 return (
62- < >
63- { title } ({ scopes . length } )
64- < ul >
65- { scopes . map ( ( scope ) => {
66- return < li key = { scope } > { scope } </ li > ;
67- } ) }
68- </ ul >
69- </ >
91+ < div className = { "card" + ( open ? " open" : "" ) } >
92+ < div className = "card__header pointer" onClick = { ( ) => setOpen ( ! open ) } >
93+ { title } ({ scopes . length } )
94+ </ div >
95+
96+ { renderBody ( ) }
97+ </ div >
7098 ) ;
7199}
72100
0 commit comments