Skip to content

Commit

Permalink
New layout: Avatar
Browse files Browse the repository at this point in the history
A basic layout that puts a picture in a circle and some text underneath
  • Loading branch information
simonhamp committed Jan 15, 2024
1 parent 0aaa0b0 commit e364676
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/Layout/Layouts/Avatar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace SimonHamp\TheOg\Layout\Layouts;

use SimonHamp\TheOg\BorderPosition;
use SimonHamp\TheOg\Layout\AbstractLayout;
use SimonHamp\TheOg\Layout\PictureBox;
use SimonHamp\TheOg\Layout\Position;
use SimonHamp\TheOg\Layout\TextBox;

class Avatar extends AbstractLayout
{
protected BorderPosition $borderPosition = BorderPosition::Left;
protected int $borderWidth = 25;
protected int $height = 630;
protected int $padding = 40;
protected int $width = 1200;

public function features(): void
{
$this->addFeature((new PictureBox())
->path($this->picture())
->circle()
->box(300, 300)
->position(
x: 0,
y: 0,
relativeTo: fn () => $this->mountArea()->anchor(Position::Center)->moveY(-100),
anchor: Position::Center,
)
);

$this->addFeature((new TextBox())
->text($this->title())
->color($this->config->theme->getTitleColor())
->font($this->config->theme->getTitleFont())
->size(56)
->box($this->mountArea()->box->width() / 1.5, 300)
->position(
x: 0,
y: 0,
relativeTo: fn () => $this->mountArea()->anchor(Position::Center)->moveY(100),
anchor: Position::MiddleTop,
)
);
}

public function url(): string
{
return strtoupper(parent::url());
}
}

0 comments on commit e364676

Please sign in to comment.