Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andy-aa/html
Lightweight and easy to use set of classes for building user interfaces
https://github.com/andy-aa/html
Last synced: 2 days ago
JSON representation
Lightweight and easy to use set of classes for building user interfaces
- Host: GitHub
- URL: https://github.com/andy-aa/html
- Owner: andy-aa
- License: mit
- Created: 2020-07-11T09:00:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-21T09:41:27.000Z (almost 4 years ago)
- Last Synced: 2024-06-02T21:36:41.669Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 177 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.com/andy-aa/html.svg?branch=master)](https://travis-ci.com/andy-aa/html)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Packagist](https://img.shields.io/packagist/vpre/texlab/html.svg?style=flat-square)](https://packagist.org/packages/texlab/html)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat-square)](https://phpstan.org/)
[![Psalm](https://img.shields.io/badge/Psalm-Level%20Max-brightgreen.svg?style=flat-square)](https://psalm.dev/)
[![Coverage Status](https://img.shields.io/coveralls/github/andy-aa/html/master.svg?style=flat-square)](https://coveralls.io/github/andy-aa/html?branch=master)
# Html
- [What is it?](#what-is-it)
- [Install](#install-via-composer)
- [Usage example](#usage-example)
- [HTML table](#html-table)
- [Pagination](#pagination)## What is it?
Lightweight and easy to use set of classes for building user interfaces.
## Install via composerInstallation via composer
```
composer require texlab/html
```
Example **composer.json** file
```
{
"require": {
"texlab/html": "^0.19"
}
}
```## Usage examples
Usage examples can be found in the [examples](examples/) folder.
You can run the examples from the library folder using the console command:```
php -S localhost:8000 -t examples/
```
### HTML tablePHP code:
```php
1, 'name' => 'Peter', 'Director'],
['id' => 3, 'name' => 'Viktor', 'Manager'],
['id' => 7, 'name' => 'Mark', 'Worker']
];$headers = ['id' => '№', 'name' => 'Name', 'Description'];
$table
->setClass("table")
->setData($data)
->addHeaders($headers)
->loopByRow(function (&$row) {
$row['edit'] = "✏";
$row['del'] = "❌";
});?>
Document= $table->html() ?>
```
Result:
![image](https://user-images.githubusercontent.com/46691193/92361408-03d37700-f0f7-11ea-92a4-4450c30ba3d5.png)
### Pagination
PHP code:
```php
setClass("pagination")
->setUrlPrefix("?type=table&action=show")
->setPrevious('Previous')
->setFirst('First')
->setLast('Last')
->setNext('Next')
->setPageCount(8)
->setCurrentPage(3);
?>
Document
.pagination a {
color: green;
text-decoration: none;
}.pagination .current {
color: red;
}
= $pagination->html() ?>
```
Result:
![image](https://user-images.githubusercontent.com/46691193/93690150-aae3e580-fadd-11ea-944b-faa3b40195f8.png)