Skip to content

Commit

Permalink
Move witgets classes to layout directory. (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 20, 2024
1 parent 8cc7a94 commit 72d1d5e
Show file tree
Hide file tree
Showing 45 changed files with 178 additions and 145 deletions.
31 changes: 21 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,40 @@ The repository can generate basic `HTML` tags, allowing you to create `HTML` ele
The following tags are currently supported:

- [a](/docs/tag/A.md)
- [body](/docs/tag/Body.md)
- [button](/docs/tag/Button.md)
- [button toggle](/docs/tag/ButtonToggle.md)
- [div](/docs/tag/Div.md)
- [footer](/docs/tag/Footer.md)
- [form](/docs/tag/Form.md)
- [h](/docs/tag/H.md)
- [head](/docs/tag/Head.md)
- [header](/docs/tag/Header.md)
- [html](/docs/tag/Html.md)
- [i](/docs/tag/I.md)
- [img](/docs/tag/Img.md)
- [li](/docs/tag/Li.md)
- [meta](/docs/tag/Meta.md)
- [nav](/docs/tag/Nav.md)
- [ol](/docs/tag/Ol.md)
- [p](/docs/tag/P.md)
- [section](/docs/tag/Section.md)
- [span](/docs/tag/Span.md)
- [svg](/docs/tag/Svg.md)
- [title](/docs/tag/Title.md)
- [ul](/docs/tag/Ul.md)

## Layout

In web design, the `Layout` section typically refers to a collection of files or components that define the overall
structure and arrangement of a web page. This includes elements such as headers, footers, navigation bars, sidebars, and
other structural components that help organize and present content on the page. The 'Layout' section is essential for
creating consistent and visually appealing designs across the entire website, as it establishes the framework
within which individual pages are constructed.

The repository provides a set of classes for creating layouts, including:

- [body](/docs/layout/Body.md)
- [footer](/docs/layout/Footer.md)
- [head](/docs/layout/Head.md)
- [header](/docs/layout/Header.md)
- [html](/docs/layout/Html.md)
- [main](/docs/layout/Main.md)
- [meta](/docs/layout/Meta.md)
- [nav](/docs/layout/Nav.md)
- [section](/docs/layout/Section.md)
- [title](/docs/layout/Title.md)

## Forms

The repository also provides a set of classes for creating forms, including:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions src/Attribute/Custom/HasContentAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Attribute\Custom;

use PHPForge\Html\Helper\Encode;

/**
* Is used by widgets that implement the content attribute.
*/
trait HasContentAttribute
{
/**
* Sets the content attributes.
*
* @param string $value The content value.
*
* @return static A new instance of the current class with the specified content value.
*/
public function content(string $value): static
{
$new = clone $this;
$new->attributes['content'] = Encode::content($value);

return $new;
}
}
4 changes: 1 addition & 3 deletions src/Attribute/Tag/HasHttpEquiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ trait HasHttpEquiv
* Set the name of the HTTP header to define.
*
* @param string $value The name of the HTTP header to define.
* @param string $content The value of the HTTP header to define.
*
* @return static A new instance of the current class with the specified http-equiv value.
*
* @link https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv
*/
public function httpEquiv(string $value, string $content): static
public function httpEquiv(string $value): static
{
$new = clone $this;
$new->attributes['http-equiv'] = Encode::value($value);
$new->attributes['content'] = Encode::content($content);

return $new;
}
Expand Down
53 changes: 0 additions & 53 deletions src/Base/AbstractMeta.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Helper/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ final class Attributes
'id',
'name',
'type',
'http-equiv',
'value',
'href',
'src',
Expand Down
6 changes: 4 additions & 2 deletions src/Body.php → src/Layout/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<body>` `HTML` element represents the content of an HTML document.
* There can be only one `<body>` element in a document.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-body-element
*/
final class Body extends Base\AbstractBlockElement
final class Body extends AbstractBlockElement
{
protected string $tagName = 'body';
}
6 changes: 4 additions & 2 deletions src/Footer.php → src/Layout/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* Represents a footer for its nearest ancestor sectioning content or sectioning root element.
* A footer typically contains information about the author of the section, copyright data or links to related documents.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-footer-element
*/
final class Footer extends Base\AbstractBlockElement
final class Footer extends AbstractBlockElement
{
protected string $tagName = 'footer';
}
6 changes: 4 additions & 2 deletions src/Head.php → src/Layout/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<head>` HTML element contains machine-readable information (metadata) about the document, like its title,
* scripts, and style sheets.
*
* @link https://html.spec.whatwg.org/multipage/semantics.html#the-head-element
*/
final class Head extends Base\AbstractBlockElement
final class Head extends AbstractBlockElement
{
protected string $tagName = 'head';
}
6 changes: 4 additions & 2 deletions src/Header.php → src/Layout/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<header>` HTML element represents introductory content, typically a group of introductory or navigational aids.
* It may contain some heading elements but also a logo, a search form, an author name, and other elements.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-header-element
*/
final class Header extends Base\AbstractBlockElement
final class Header extends AbstractBlockElement
{
protected string $tagName = 'header';
}
6 changes: 4 additions & 2 deletions src/Html.php → src/Layout/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<html>` HTML element represents the root (top-level element) of an HTML document, so it is also referred to as
* the root element. All other elements must be descendants of this element.
*
* @link https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
*/
final class Html extends Base\AbstractBlockElement
final class Html extends AbstractBlockElement
{
protected string $tagName = 'html';
}
44 changes: 44 additions & 0 deletions src/Layout/Meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Layout;

use PHPForge\Html\Attribute\Custom\HasAttributes;
use PHPForge\Html\Attribute\Custom\HasContentAttribute;
use PHPForge\Html\Attribute\Input\HasName;
use PHPForge\Html\Attribute\Tag\{HasCharset, HasHttpEquiv};
use PHPForge\Html\Attribute\{HasClass, HasId, HasLang, HasStyle};
use PHPForge\Html\Tag;
use PHPForge\Widget\Element;

/**
* The `<meta>` HTML element represents metadata that cannot be represented by other HTML meta-related elements,
* like `<base>`, `<link>`, `<script>`, `<style>`, or `<title>`.
*
* @link https://html.spec.whatwg.org/multipage/semantics.html#the-meta-element
*/
final class Meta extends Element
{
use HasAttributes;
use HasCharset;
use HasClass;
use HasContentAttribute;
use HasHttpEquiv;
use HasId;
use HasLang;
use HasName;
use HasStyle;

private array $attributes = [];

/**
* Generate the HTML representation of the element.
*
* @return string The HTML representation of the element.
*/
protected function run(): string
{
return Tag::widget()->attributes($this->attributes)->id($this->id)->tagName('meta')->render();
}
}
6 changes: 4 additions & 2 deletions src/Nav.php → src/Layout/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<nav>` HTML element represents a section of a page whose purpose is to provide navigation links, either within
Expand All @@ -11,7 +13,7 @@
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-nav-element
*/
final class Nav extends Base\AbstractBlockElement
final class Nav extends AbstractBlockElement
{
protected string $tagName = 'nav';
}
6 changes: 4 additions & 2 deletions src/Section.php → src/Layout/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<section>` HTML element represents a generic standalone section of a document, which doesn't have a more
* specific semantic element to represent it. Sections should always have a heading, with very few exceptions.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-section-element
*/
final class Section extends Base\AbstractBlockElement
final class Section extends AbstractBlockElement
{
protected string $tagName = 'section';
}
6 changes: 4 additions & 2 deletions src/Title.php → src/Layout/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

namespace PHPForge\Html;
namespace PHPForge\Html\Layout;

use PHPForge\Html\Base\AbstractBlockElement;

/**
* The `<title>` HTML element defines the document's title shown in a browser's title bar or a page's tab.
* It only contains text; tags within the element are ignored.
*
* @link https://html.spec.whatwg.org/multipage/semantics.html#the-title-element
*/
final class Title extends Base\AbstractBlockElement
final class Title extends AbstractBlockElement
{
protected string $tagName = 'title';
}
13 changes: 0 additions & 13 deletions src/Meta.php

This file was deleted.

0 comments on commit 72d1d5e

Please sign in to comment.