Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

53 rader
1.9 KiB

  1. import './search.scss';
  2. import '../../components/artwork/artwork.scss';
  3. import $ from 'jquery';
  4. import {createElement} from "../../_global/scripts/helpers";
  5. import {searchData} from "./SearchData";
  6. import {createArtwork} from "../../components/artwork/ArtworkComponent";
  7. import {createSearchInput} from "../../atoms/search-input/SearchInputComponent";
  8. import {createSearchButton} from "../../atoms/search-button/SearchButtonComponent";
  9. import IHKSearchTypeahead from "./search-typeahead";
  10. export const createSearch =
  11. ({
  12. artworkStyle = 'artwork',
  13. headline1 = 'Willkommen bei Ihrer IHK.',
  14. headline2 = 'Wie können wir Ihnen helfen?',
  15. placeholder = 'Tippe "Taxischein" für Autocomplete',
  16. api = 'services/search/{SEARCHTERM}.json',
  17. tiles = searchData,
  18. }) => {
  19. const section = createElement('section', ['search'], null);
  20. const artwork = createArtwork({type: artworkStyle});
  21. section.appendChild(artwork);
  22. section.dataset.type = artworkStyle;
  23. const container = createElement('div', ['container', 'small'], null, section);
  24. const row = createElement('div', ['row'], null, container);
  25. const col = createElement('div', ['col'], null, row);
  26. createElement('h1', ['like-h2'], headline1 + '<br>' + headline2, col);
  27. const form = createElement('form', [], null, col);
  28. const label = createElement('label', ['visually-hidden'], 'IHK durchsuchen', form);
  29. label.for = 'search-term';
  30. form.appendChild(createSearchInput({api: api, placeholder: placeholder}));
  31. form.appendChild(createSearchButton({}));
  32. form.action = '#';
  33. const tilesContainer = createElement('div', ['tiles'], null, col);
  34. tiles.map((tile) => {
  35. const div = createElement('div', ['tile'], null, tilesContainer);
  36. const a = createElement('a', [], tile.title, div);
  37. a.href = tile.link;
  38. })
  39. if (api) {
  40. new IHKSearchTypeahead($(form).find('input.typeahead'));
  41. }
  42. return section;
  43. }