@@ -11,6 +11,36 @@ import Notification from '../../../components/Notification';
1111
1212export default ({ children , pageContext }) => <TabsLayout pageContext = { pageContext } >{ children } </TabsLayout >;
1313
14+ export const handleSearch = (searchValue ) => {
15+ if (searchValue === ' error' ) {
16+ return Promise .reject (new Error (' Simulated error' ));
17+ }
18+
19+ // Simple mock options for demo purposes
20+ const mockOptions = [
21+ ' Hakutulos 1' ,
22+ ' Hakutulos 2' ,
23+ ' Hakutulos 3' ,
24+ ' Sosiaali- ja terveyspalvelut' ,
25+ ' Kasvatus ja koulutus' ,
26+ ' Asuminen ja ympäristö' ,
27+ ' Kulttuuri ja vapaa-aika' ,
28+ ' Liikenne ja kartat' ,
29+ ' Työ ja yritystoiminta' ,
30+ ' Päätöksenteko ja hallinto'
31+ ].filter ((label ) => label .toUpperCase ().indexOf (searchValue .toUpperCase ()) >= 0 )
32+ .map ((label ) => ({ value: label , label }));
33+
34+ return Promise .resolve ({
35+ groups: [
36+ {
37+ label: ' Hakuehdotukset' ,
38+ options: mockOptions ,
39+ },
40+ ],
41+ });
42+ };
43+
1444## Usage
1545
1646### Example
@@ -333,9 +363,19 @@ The Header.Search component is to be used for whole site wide search. Currently
333363 menuButtonAriaLabel = " Menu"
334364 onMenuClick = { (e ) => e .stopPropagation ()}
335365 >
336- <Header.ActionBarItem label = " Haku" icon = { <IconSearch />} id = " action-bar-search" >
337- <Header.Search label = " Hae palvelusta" onChange = { () => {}} onSubmit = { () => {}} />
338- </Header.ActionBarItem >
366+ <Header.Search
367+ texts = { {
368+ heading: ` Hae palvelusta: Helsingin kaupunki ` ,
369+ label: ' Mitä etsit?' ,
370+ buttonLabel: ' Hae' ,
371+ closeLabel: ' Sulje' ,
372+ placeholder: ' Anna teksti hakua varten' ,
373+ assistive: ' Avustava teksti' ,
374+ }}
375+ onChange = { () => {}}
376+ onSubmit = { () => {}}
377+ onSearch = { handleSearch }
378+ />
339379 </Header.ActionBar >
340380 </Header >
341381</PlaygroundPreview >
@@ -344,10 +384,6 @@ The Header.Search component is to be used for whole site wide search. Currently
344384
345385##### ActionBarItem and ActionBarButton
346386
347- <Notification label = " A work in progress!" className = " siteNotification" >
348- The Header.ActionBarItem and Header.ActionBarButton components are subject to change.
349- </Notification >
350-
351387The Header.ActionBarItem is a generic component for displaying icon buttons on the action bar accompanied with dropdowns.
352388Header.ActionBarButton is a generic button component for displaying buttons without dropdowns.
353389
0 commit comments