File modules/template_engine/components/html/component_group/GroupComponent.class.php

Last commit: Sun Dec 8 20:56:47 2024 +0100	Jan Dankert	New: Users are now able to store bookmarks.
1 <?php 2 3 namespace template_engine\components\html\component_group; 4 5 use template_engine\components\html\Component; 6 use template_engine\element\CMSElement; 7 use template_engine\element\HtmlElement; 8 use template_engine\element\Value; 9 use template_engine\element\ValueExpression; 10 11 /** 12 * A group. 13 */ 14 class GroupComponent extends Component 15 { 16 17 public $open = true; 18 public $show = true; 19 public $collapsible = true; 20 public $title; 21 public $description; 22 public $icon; 23 24 public function createElement() 25 { 26 $group = (new HtmlElement('section'))->addStyleClass('group'); 27 28 if ( $this->collapsible ) 29 $group->addStyleClass('collapsible'); 30 31 $headline = (new HtmlElement('h2')) 32 ->addStyleClass('collapsible-title') 33 ->addStyleClass('group-title') 34 ->addStyleClass('collapsible-act-switch') 35 ->asChildOf( $group ); 36 37 if ( $this->open || !$this->collapsible ) 38 $group->addStyleClass(['collapsible--is-open','collapsible--is-visible']); 39 40 if ( $this->show ) 41 $group->addStyleClass('collapsible--show' ); 42 43 if ( $this->title ) 44 { 45 46 if ( $this->collapsible ) { 47 48 $arrowRight = (new HtmlElement('i'))->addStyleClass(['image-icon','image-icon--node-closed','collapsible--on-closed']); 49 $headline->addChild($arrowRight ); 50 51 $arrowDown = (new HtmlElement('i'))->addStyleClass(['image-icon','image-icon--node-open','collapsible--on-open']); 52 $headline->addChild($arrowDown ); 53 } 54 55 if ( $this->icon ) { 56 57 $image = new CMSElement('i'); 58 $image->addStyleClass(['image-icon','image-icon--'.$this->icon]); 59 $headline->addChild( $image ); 60 } 61 else { 62 63 $image = new CMSElement('i'); 64 $image->addStyleClass(['image-icon','image-icon--empty']); 65 $headline->addChild( $image ); 66 } 67 68 (new HtmlElement('span'))->content( $this->title )->asChildOf($headline); 69 } 70 71 if ( $this->description ) 72 (new HtmlElement('p')) 73 ->addStyleClass(['group-description','collapsible-value']) 74 ->content( $this->description ) 75 ->asChildOf($group); 76 77 $value = (new HtmlElement('div')) 78 ->addStyleClass(['collapsible-value','group-value']) 79 ->asChildOf($group); 80 81 $this->adoptiveElement = $value; 82 83 return $group; 84 } 85 86 }
Download modules/template_engine/components/html/component_group/GroupComponent.class.php
History Sun, 8 Dec 2024 20:56:47 +0100 Jan Dankert New: Users are now able to store bookmarks. Sun, 18 Apr 2021 01:21:33 +0200 Jan Dankert Fix: Correct CSS3 syntax for transitions on multiple properties; New: Using a transition for open/close collapsibles. Thu, 25 Feb 2021 01:22:10 +0100 Jan Dankert New: Edit all page elements in 1 view. Mon, 9 Nov 2020 22:24:27 +0100 Jan Dankert New: Setting the CSS class of tables. Wed, 21 Oct 2020 00:26:06 +0200 Jan Dankert Using fieldsets in all templates (replacing the old '') Sun, 18 Oct 2020 01:30:49 +0200 Jan Dankert New component "fieldset" for better form layout. Wed, 14 Oct 2020 22:36:29 +0200 Jan Dankert Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader. Wed, 14 Oct 2020 22:20:22 +0200 Jan Dankert Refactoring: Renamed component folders, because 'if' is no valid namespace fragment.