Sha256: 28c63575e059662df6d2a420143952815aea0b56e57115aa85da990d51324efc

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

// eslint-disable-next-line no-unused-vars
function SearchDropdownResults(props) {
  const resultCls = 'o-search-dropdown-result';
  const resultMoreCls = 'o-search-dropdown-result o-search-dropdown-result--more';

  if (props.resources.length === 0) {
    if (props.isSearching) {
      return <div className={resultCls}>Searching...</div>;
    } else if (props.search_term && props.search_term.length > 0) {
      return <div className={resultCls}>Nothing found.</div>;
    }
    return <div className={resultCls}>Enter terms to start searching.</div>;
  }

  const results = props.resources.map((resource, idx) => {
    const key = `${resource.curriculum_id}_${resource.id}`;
    return <SearchDropdownResult
      key={key}
      resource={resource}
      selected={props.selected === idx} />;
  });

  const showMore = (
    <a className={resultMoreCls}
      href={Routes.lcms_engine_search_path({ search_term: props.search_term })}>
      Show more results...
    </a>
  );

  return (
    <div>
      {results}
      {showMore}
    </div>
  );
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lcms-engine-0.1.4 app/assets/javascripts/lcms/engine/components/search-dropdown/SearchDropdownResults.js.jsx
lcms-engine-0.1.3 app/assets/javascripts/lcms/engine/components/search-dropdown/SearchDropdownResults.js.jsx
lcms-engine-0.2.0 app/assets/javascripts/lcms/engine/components/search-dropdown/SearchDropdownResults.js.jsx
lcms-engine-0.1.2 app/assets/javascripts/lcms/engine/components/search-dropdown/SearchDropdownResults.js.jsx
lcms-engine-0.1.0 app/assets/javascripts/lcms/engine/components/search-dropdown/SearchDropdownResults.js.jsx