ndla-audio-search
A simple library for selecting NDLA audio files.
Installation
$ npm install ndla-audio-search
Usage
Styling
@import '~ndla-audio-search/scss/audio-search';
@import '../path/to/node_modules/ndla-audio-search/scss/audio-search';
Get audio with the audio selector
To use the AudioSearch
component, some functions for handling search and fetching audios are needed. In addition, some translations are needed.
import AudioSearch from '@ndla/audio-search';
const searchAudios = queryObject => {
};
const fetchAudio = id => {
};
const onError = err => {
};
const audioSelect = audio => {
};
const translations = {
searchPlaceholder: ,
searchButtonTitle: ,
useAudio: ,
noResults: ,
};
<AudioSearch
translations={translations}
fetchAudio={fetchAudio}
searchAudios={searchAudios}
onAudioSelect={audioSelect}
onError={onError}
queryObject={defaultQueryObject}
/>
A queryObject
must look like this:
{
query: ,
page: ,
pageSize: ,
locale: ,
}