|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\Integration; |
| 4 | + |
| 5 | +use SimonHamp\TheOg\BorderPosition; |
| 6 | +use SimonHamp\TheOg\Layout\AbstractLayout; |
| 7 | +use SimonHamp\TheOg\Layout\PictureBox; |
| 8 | +use SimonHamp\TheOg\Layout\Position; |
| 9 | +use SimonHamp\TheOg\Layout\TextBox; |
| 10 | + |
| 11 | +class ShiftLayout extends AbstractLayout |
| 12 | +{ |
| 13 | + protected BorderPosition $borderPosition = BorderPosition::None; |
| 14 | + |
| 15 | + protected int $borderWidth = 0; |
| 16 | + |
| 17 | + protected int $height = 640; |
| 18 | + |
| 19 | + protected int $padding = 10; |
| 20 | + |
| 21 | + protected int $width = 1280; |
| 22 | + |
| 23 | + protected string $category; |
| 24 | + |
| 25 | + protected int $readTime; |
| 26 | + |
| 27 | + public function features(): void |
| 28 | + { |
| 29 | + $this->addFeature((new PictureBox) |
| 30 | + ->path(__DIR__.'/../resources/very-wide.png') |
| 31 | + ->box(2297, 49) |
| 32 | + ->position( |
| 33 | + x: 0, |
| 34 | + y: 0, |
| 35 | + ) |
| 36 | + ); |
| 37 | + |
| 38 | + $this->addFeature((new TextBox) |
| 39 | + ->name('category') |
| 40 | + ->text($this->category()) |
| 41 | + ->color($this->config->theme->getUrlColor()) |
| 42 | + ->font($this->config->theme->getUrlFont()) |
| 43 | + ->size(28) |
| 44 | + ->box(300, 45) |
| 45 | + ->position( |
| 46 | + x: 0, |
| 47 | + y: 60, |
| 48 | + ) |
| 49 | + ); |
| 50 | + |
| 51 | + $this->addFeature((new TextBox) |
| 52 | + ->name('title') |
| 53 | + ->text($this->title()) |
| 54 | + ->color($this->config->theme->getTitleColor()) |
| 55 | + ->font($this->config->theme->getTitleFont()) |
| 56 | + ->size(60) |
| 57 | + ->box($this->mountArea()->box->width(), 400) |
| 58 | + ->position( |
| 59 | + x: 0, |
| 60 | + y: 20, |
| 61 | + relativeTo: fn () => $this->getFeature('category')->anchor(Position::BottomLeft) |
| 62 | + ) |
| 63 | + ); |
| 64 | + |
| 65 | + if ($readTime = $this->readTime()) { |
| 66 | + $this->addFeature((new TextBox) |
| 67 | + ->name('read-time') |
| 68 | + ->text($readTime.' minute read') |
| 69 | + ->color($this->config->theme->getCallToActionColor()) |
| 70 | + ->font($this->config->theme->getCallToActionFont()) |
| 71 | + ->size(20) |
| 72 | + ->box(300, 45) |
| 73 | + ->position( |
| 74 | + x: 0, |
| 75 | + y: 20, |
| 76 | + relativeTo: fn () => $this->getFeature('title')->anchor(Position::BottomLeft) |
| 77 | + ) |
| 78 | + ); |
| 79 | + } |
| 80 | + |
| 81 | + $this->addFeature((new TextBox) |
| 82 | + ->name('url') |
| 83 | + ->text($this->url()) |
| 84 | + ->color($this->config->theme->getUrlColor()) |
| 85 | + ->font($this->config->theme->getUrlFont()) |
| 86 | + ->size(28) |
| 87 | + ->box($this->mountArea()->box->width(), 45) |
| 88 | + ->position( |
| 89 | + x: 0, |
| 90 | + y: 0, |
| 91 | + relativeTo: fn () => $this->mountArea()->anchor(Position::BottomLeft), |
| 92 | + anchor: Position::BottomLeft |
| 93 | + ) |
| 94 | + ); |
| 95 | + |
| 96 | + $this->addFeature((new PictureBox) |
| 97 | + ->path($this->watermark()->path()) |
| 98 | + ->box(100, 100) |
| 99 | + ->position( |
| 100 | + x: 0, |
| 101 | + y: 0, |
| 102 | + relativeTo: fn () => $this->mountArea()->anchor(Position::BottomRight), |
| 103 | + anchor: Position::BottomRight |
| 104 | + ) |
| 105 | + ); |
| 106 | + } |
| 107 | + |
| 108 | + public function category(): string |
| 109 | + { |
| 110 | + return $this->category; |
| 111 | + } |
| 112 | + |
| 113 | + public function readTime(): ?int |
| 114 | + { |
| 115 | + return $this->readTime ?? null; |
| 116 | + } |
| 117 | + |
| 118 | + public function setCategory(string $category): static |
| 119 | + { |
| 120 | + $this->category = $category; |
| 121 | + |
| 122 | + return $this; |
| 123 | + } |
| 124 | + |
| 125 | + public function setReadTime(int $readTime): static |
| 126 | + { |
| 127 | + $this->readTime = $readTime; |
| 128 | + |
| 129 | + return $this; |
| 130 | + } |
| 131 | +} |
0 commit comments