import React from 'react'; import { storiesOf } from '@storybook/react'; import { VoiceSearch, SearchBox } from '../packages/react-instantsearch-dom'; import { WrapWithHits } from './util'; import type { InnerComponentProps } from '../packages/react-instantsearch-dom/src/components/VoiceSearch'; const stories = storiesOf('VoiceSearch', module); stories .add('default', () => (

To see this button disabled, test it on unsupported browsers like Safari, Firefox, etc.

)) .add('without status', () => ( null} /> )) .add('with a SearchBox', () => ( )) .add('with a custom button text', () => (
(isListening ? '⏹' : '🎙')} />
)) .add('with full status', () => { const Status = ({ status, errorCode, isListening, transcript, isSpeechFinal, isBrowserSupported, }: InnerComponentProps) => { return (

status: {status}

errorCode: {errorCode}

isListening: {isListening ? 'true' : 'false'}

transcript: {transcript}

isSpeechFinal: {isSpeechFinal ? 'true' : 'false'}

isBrowserSupported: {isBrowserSupported ? 'true' : 'false'}

); }; return ( ); }) .add('search as you speak', () => { const Status = ({ status, errorCode, isListening, transcript, isSpeechFinal, isBrowserSupported, }: InnerComponentProps) => { return (

status: {status}

errorCode: {errorCode}

isListening: {isListening ? 'true' : 'false'}

transcript: {transcript}

isSpeechFinal: {isSpeechFinal ? 'true' : 'false'}

isBrowserSupported: {isBrowserSupported ? 'true' : 'false'}

); }; return ( ); }) .add('example of dynamic UI working with SearchBox', () => { const Status = ({ isListening, transcript }: InnerComponentProps) => { return (
{transcript}
); }; return (
); }) .add('with additional paramaters', () => ( {}} /> )) .add('with additional paramaters & language', () => ( {}} /> )) .add('with additional paramaters & user set & language', () => ( ({ analyticsTags: ['voice'] })} /> ));