ILIAS  release_8 Revision v8.23
show_popover_with_vertical_scrollbars.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
8 {
9  global $DIC;
10  $factory = $DIC->ui()->factory();
11  $renderer = $DIC->ui()->renderer();
12 
13  // Note: A list should be rendered with the listing popover, e.g. $factory->popover()->listing()
14  // However, at the moment there is no component present representing such list items, so this example
15  // also uses a standard popover.
16 
17  $series = [
18  'Breaking Bad',
19  'Big Bang Theory',
20  'Dexter',
21  'Better Call Saul',
22  'Narcos',
23  'Ray Donovan',
24  'Simpsons',
25  'South Park',
26  'Fargo',
27  'Bloodline',
28  'The Walking Dead',
29  'New Girl',
30  'Sons of Anarchy',
31  'How I Met Your Mother',
32  ];
33  $list = $renderer->render($factory->listing()->unordered($series));
34  // Note: The Popover does not restrict the height. It is the responsibility of the content component
35  // to define the max height and to display vertical scrollbars, if necessary.
36  // At the moment, the renderer of a component is not aware of the context it is rendering the component,
37  // e.g. inside a Popover.
38  // The inline code below simulates this behaviour. Here we want to reduce the
39  // height of the list to 200px and display vertical scrollbars, if needed.
40  $content = "<div style='max-height: 200px; overflow-y: auto; padding-right: 10px;'>{$list}</div>";
41 
42  $popover = $factory->popover()->standard($factory->legacy($content))->withTitle('Series');
43  $button = $factory->button()->standard('Show me some Series', '#')
44  ->withOnClick($popover->getShowSignal());
45 
46  return $renderer->render([$popover, $button]);
47 }
global $DIC
Definition: feed.php:28
$factory
Definition: metadata.php:75