Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/linters/.codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
ignore-words-list = CanBe
skip = */tests/*,tests/**,*/composer.lock,*/composer.json
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ permissions:

jobs:
phpunit:
uses: yii2-framework/actions/.github/workflows/phpunit.yml@main
uses: yii2-framework/actions/.github/workflows/phpunit.yml@v1
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
php-version: '["8.3","8.4","8.5"]'
2 changes: 1 addition & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ permissions:

jobs:
composer-require-checker:
uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@main
uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@v1
4 changes: 3 additions & 1 deletion .github/workflows/ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ permissions:

jobs:
easy-coding-standard:
uses: yii2-framework/actions/.github/workflows/ecs.yml@main
uses: yii2-framework/actions/.github/workflows/ecs.yml@v1
with:
php-version: '["8.3"]'
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ permissions:

jobs:
phpstan:
uses: yii2-framework/actions/.github/workflows/phpstan.yml@main
uses: yii2-framework/actions/.github/workflows/phpstan.yml@v1
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preset: psr12
risky: true

version: 8.1
version: 8.3

finder:
exclude:
Expand Down
136 changes: 46 additions & 90 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,79 @@
# ChangeLog
# Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

## 0.6.0 Under development

- Enh #32: Add `HasBlocking` trait and `blocking()` method to manage `blocking` attribute for HTML elements (@terabytesoftw)
- Enh #33: Add `HasMedia` trait and `media()` method to manage `media` attribute for HTML elements (@terabytesoftw)
- Enh #34: Add `HasType` trait and `type()` method to manage `type` attribute for HTML elements (@terabytesoftw)
- Enh #35: Add `HasNonce` trait and `nonce()` method to manage `nonce` attribute for HTML elements (@terabytesoftw)
- Bug #36: Clarify documentation for various HTML attributes to specify value types for better understanding (@terabytesoftw)
- Enh #37: Add `HasIntegrity` trait and `integrity()` method to manage `integrity` attribute for HTML elements (@terabytesoftw)
- Enh #38: Add `HasReferrerpolicy` trait and `referrerpolicy()` method to manage `referrerpolicy` attribute for HTML elements (@terabytesoftw)
- Enh #39: Add `HasSrc` trait and `src()` method to manage `src` attribute for HTML elements (@terabytesoftw)
- Bug #40: Enhance documentation for HTML attributes (@terabytesoftw)
- Enh #41: Add `HasTarget` trait and `target()` method to manage `target` attribute for HTML elements (@terabytesoftw)
- Enh #42: Add `HasAs` trait and `as()` method to manage `as` attribute for HTML elements (@terabytesoftw)
- Bug #43: Update copyright year to `2026` in multiple files (@terabytesoftw)
- Enh #44: Add `HasDisabled` trait and `disabled()` method to manage `disabled` attribute for HTML elements (@terabytesoftw)
- Enh #45: Add `HasHreflang` trait and `hreflang()` method to manage `hreflang` attribute for HTML elements (@terabytesoftw)
- Enh #46: Add `HasImagesizes` trait and `imagesizes()` method to manage `imagesizes` attribute for HTML elements (@terabytesoftw)
- Enh #47: Add `HasImagesrcset` trait and `imagesrcset()` method to manage `imagesrcset` attribute for HTML elements (@terabytesoftw)
- Enh #48: Add `HasSizes` trait and `sizes()` method to manage `sizes` attribute for HTML elements (@terabytesoftw)
- Enh #49: Add `HasCharset` trait and `charset()` method to manage `charset` attribute for HTML elements (@terabytesoftw)
- Enh #50: Add `HasContent` trait and `content()` method to manage `content` attribute for HTML elements (@terabytesoftw)
- Enh #51: Add `HasHttpEquiv` trait and `httpEquiv()` method to manage `http-equiv` attribute for HTML elements (@terabytesoftw)
- Enh #52: Add `HasName` trait and `name()` method to manage `name` attribute for HTML elements (@terabytesoftw)
- Bug #53: Update documentation for various HTML attributes and their usage in elements (@terabytesoftw)
- Enh #54: Add `HasDownload` trait and `download()` method to manage `download` attribute for HTML elements (@terabytesoftw)
- Enh #55: Add `HasPing` trait and `ping()` method to manage `ping` attribute for HTML elements (@terabytesoftw)
- Enh #56: Add `HasLoading` trait and `loading()` method to manage `loading` attribute for HTML elements (@terabytesoftw)
- Enh #57: Add `HasSrcset` trait and `srcset()` method to manage `srcset` attribute for HTML elements (@terabytesoftw)
- Enh #58: Add `HasUsemap` trait and `usemap()` method to manage `usemap` attribute for HTML elements (@terabytesoftw)
- Enh #59: Add `HasValue` trait and `value()` method to manage `value` attribute for HTML elements (@terabytesoftw)
- Enh #60: Add `HasForm` trait and `form()` method to manage `form` attribute for HTML elements (@terabytesoftw)
- Enh #61: Add `Type` enum for common `type` attribute values (@terabytesoftw)
- Enh #62: Add `HasMax`, `HasMin` traits and `max()`, `min()` methods to manage `max` and `min` attributes for HTML elements (@terabytesoftw)
- Enh #63: Add `HasReadonly`, `HasStep` traits and `readonly()`, `step()` methods to manage `readonly` and `step` attributes for HTML elements (@terabytesoftw)
- Enh #64: Add `HasMaxlength`, `HasMinlength` traits and `maxlength()`, `minlength()` methods to manage `maxlength` and `minlength` attributes for HTML elements (@terabytesoftw)
- Enh #65: Add `HasRequired` trait and `required()` method to manage `required` attribute for HTML elements (@terabytesoftw)
- Bug #66: Enhance HTML attribute element handling with Stringable and UnitEnum support (@terabytesoftw)
- Enh #67: Add `HasAccept`, `HasAutocomplete` traits and `accept()`, `autocomplete()` methods to manage `accept` and `autocomplete` attributes for HTML elements (@terabytesoftw)
- Enh #68: Add `HasChecked`, `HasDirname` traits and `checked()`, `dirname()` methods to manage `checked` and `dirname` attributes for HTML elements (@terabytesoftw)
- Enh #69: Add `HasList`, `HasMultiple` traits and `list()`, `multiple()` methods to manage `list` and `multiple` attributes for HTML elements (@terabytesoftw)
- Enh #70: Add `HasPattern`, `HasPlaceholder`, `HasSize` traits and `pattern()`, `placeholder()`, `size()` methods to manage `pattern`, `placeholder`, and `size` attributes for HTML elements (@terabytesoftw)
- Bug #71: Move HTML attribute traits to `Form` namespace and update related imports accordingly (@terabytesoftw)
- Bug #72: Update documentation for HTML attribute elements in `Element` namespace (@terabytesoftw)
- Bug #73: Standardize PHPDoc headers across src directory files (@terabytesoftw)
- Bug #74: Remove directory `tests\Stub` and move `tests\Support\Provider` to `tests\Provider` in tests (@terabytesoftw)
- Bug #75: Standardize PHPDoc headers for test classes (@terabytesoftw)
- Bug #76: Move `HasDisabled` trait to `UIAwesome\Html\Attribute` namespace and update related imports accordingly (@terabytesoftw)
- Enh #77: Add `Autocomplete` enum and update `AutocompleteProvider` to add test data (@terabytesoftw)
- Enh #78: Add `HasPopover`, `HasPopoverTarget`, `HasPopoverTargetAction` traits and `popover()`, `popoverTarget()`, `popoverTargetAction()` methods to manage popover attributes for HTML elements (@terabytesoftw)
- Enh #79: Add `HasInputmode` trait and `inputmode()` method to manage `inputmode` attribute for HTML elements (@terabytesoftw)
- Bug #80: Update `value()` method in `HasValue` trait to accept boolean values and adjust related tests and data provider (@terabytesoftw)
- Bug #81: Migrate mixin attribute setters and tests to the simplified API (@terabytesoftw)
- Bug #82: Update `ui-awesome/html-helper` requirement to use stable version constraint `^0.7` in `composer.json` (@terabytesoftw)
- Enh #83: Enhance `HasAria`, `HasData`, and `HasEvents` traits to support prefix attributes `aria-`, `data-`, and `on` (@terabytesoftw)
- Bug #84: Refactor attribute documentation in traits (@terabytesoftw)
- Bug #85: Bug `#85`: Rename boolean attribute traits from `Has*` prefix to improve naming clarity (@terabytesoftw)
- Enh #86: Add `HasAutocapitalize` and `HasAutocorrect` traits and `autocapitalize()`, `autocorrect()` methods to manage `autocapitalize` and `autocorrect` attributes for HTML elements (@terabytesoftw)
- Bug #87: Update test method names for clarity by removing redundant `Value` suffix (@terabytesoftw)
- Enh #88: Add `CanBeSelected`, `HasLabel` traits and `selected()`, `label()` methods to manage `selected` and `label` attributes for HTML elements (@terabytesoftw)
- Enh #89: Add `HasFor` trait and `for()` method to manage `for` attribute for HTML elements (@terabytesoftw)
- feat: add common attribute traits for blocking, media, type, nonce, integrity, referrer policy, source, target, link preload, metadata, form, and selectable attributes.
- feat: add enum values for autocomplete, type, and shared attribute allow-lists.
- feat: add prefixed `aria-*`, `data-*`, and `on*` attribute support.
- feat: add autocapitalize, autocorrect, selected, label, and for attribute APIs.
- fix: support `Stringable`, `UnitEnum`, and boolean values consistently in attribute setters.
- refactor: migrate attribute setters and tests to the simplified `addAttribute()` API.
- refactor: remove element, form, media, and interactive element-specific traits now owned by `ui-awesome/html`.
- refactor: move element-specific enum cases from `Attribute` to `ElementAttribute`.
- refactor: rename boolean attribute traits from `Has*` to `CanBe*` for clearer API names.
- refactor: rename image size traits to `HasImageSizes` and `HasImageSrcSet`.
- docs: standardize attribute PHPDoc and clarify value types across traits and enums.
- test: standardize test PHPDoc, provider organization, exception names, and attribute assertions.
- chore: update `ui-awesome/html-helper` to the stable `^0.7` constraint.
- refactor: align attributes, docs, tests, and release tooling with the current package scope.

## 0.5.2 January 29, 2026

- Enh #28: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
- Bug #29: Add section for automated refactoring using `Rector` in testing documentation (@terabytesoftw)
- Bug #30: Update examples in `testing.md` for running Composer script with arguments and update `.styleci.yml` accordingly (@terabytesoftw)
- Bug #31: Remove redundant ignore rule in `actionlint.yml` configuration and update Rector command in `composer.json` to remove unnecessary `src` argument (@terabytesoftw)
- chore: add `php-forge/coding-standard` to development dependencies for code quality checks.
- docs: add automated refactoring guidance with Rector to the testing documentation.
- docs: update testing examples for running Composer scripts with arguments and align `.styleci.yml`.
- chore: remove the redundant `actionlint` ignore rule and simplify the Rector Composer script.

## 0.5.1 January 20, 2026

- Enh #27: Add `php-forge/support` as a development dependency and update related test classes (@terabytesoftw)
- chore: add `php-forge/support` as a development dependency and update related tests.

## 0.5.0 January 19, 2026

- Enh #14: Add `HasHref` trait and `href()` method to manage `href` attribute for HTML elements (@terabytesoftw)
- Enh #15: Add `HasCrossorigin` trait and `crossorigin()` method to manage `crossorigin` attribute for HTML elements (@terabytesoftw)
- Enh #16: Use package `ui-awesome/html-mixin` for mixin traits and update related imports accordingly (@terabytesoftw)
- Enh #17: Add development guide and sync metadata instructions and update testing documentation (@terabytesoftw)
- Enh #18: Move attribute traits from `ui-awesome/html-core` package and update related imports accordingly (@terabytesoftw)
- Bug #19: Update alert content in SVGs to reflect accurate descriptions for MDN standards compliance and specific & lightweight features (@terabytesoftw)
- Enh #20: Add `HasDecoding` trait and `decoding()` method to manage `decoding` attribute for HTML elements (@terabytesoftw)
- Enh #21: Add `HasFetchpriority` trait and `fetchpriority()` method to manage `fetchpriority` attribute for HTML elements (@terabytesoftw)
- Bug #22: Update documentation for `Crossorigin` and `ElementAttribute` enums to clarify attribute representation and compliance with MDN standards (@terabytesoftw)
- Bug #23: Update attribute retrieval in tests to use `getAttribute()` method for consistency (@terabytesoftw)
- Bug #24: Update documentation traits and enums for clarity and consistency (@terabytesoftw)
- Bug #25: Update documentation tests classes for clarity and consistency (@terabytesoftw)
- Bug #26: Improve `testing.md` for clarity and consistency in Composer script usage (@terabytesoftw)
- feat: add href, crossorigin, decoding, fetchpriority, and other element attribute traits.
- feat: add attribute traits moved from `ui-awesome/html-core`.
- feat: add `HasForm` and shared form-related attribute APIs.
- docs: add development guide, sync metadata instructions, and improved testing documentation.
- docs: refresh SVG feature descriptions for MDN alignment.
- docs: clarify `Crossorigin` and `ElementAttribute` enum documentation.
- docs: standardize trait, enum, and test documentation.
- fix: use `getAttribute()` consistently in tests.
- chore: update `ui-awesome/html-helper` to `0.2`.

## 0.4.0 December 27, 2025

- Dep #13: Update `ui-awesome/html-helper` version constraint to `^0.6` in `composer.json` (@terabytesoftw)
- chore: update `ui-awesome/html-helper` constraint to `^0.6`.

## 0.3.0 December 26, 2025

- Bug #10: Refactor codebase to improve performance and maintainability (@terabytesoftw)
- Bug #11: Improve test suite documentation for HTML attributes with detailed descriptions and coverage (@terabytesoftw)
- Bug #12: Add `StyleCI` badge to `README.md` for code style checks (@terabytesoftw)
- refactor: improve codebase performance and maintainability.
- docs: improve HTML attribute test suite documentation.
- docs: add the StyleCI badge to `README.md`.

## 0.2.0 March 30, 2024

- Enh #9: Update `ui-awesome/html-helper` to `0.2` (@terabytesoftw)
- chore: update `ui-awesome/html-helper` to `0.2`.

## 0.1.3 March 16, 2024

- Bug #8: Fix all `data` attributes for accept `true` value when `id` attribute is used (@terabytesoftw)
- fix: allow `data-*` attributes to accept `true` values when the `id` attribute is used.

## 0.1.2 March 14, 2024

- Bug #3: Change visibility property `attributes` to `public` in tests (@terabytesoftw)
- Enh #4: Add `HasAriaCurrent` trait and `ariaCurrent()` method (@terabytesoftw)
- Bug #5: Remove dead code in `HasAriaCurrent` trait (@terabytesoftw)
- Bug #6: Change branch alias to `1.0-dev` in `composer.json` (@terabytesoftw)
- Bug #7: Remove redundant abstract method in `data` classes (@terabytesoftw)
- feat: add `HasAriaCurrent` trait and `ariaCurrent()` method.
- fix: change test attribute visibility to public.
- fix: remove dead code from `HasAriaCurrent`.
- fix: change the branch alias to `1.0-dev` in `composer.json`.
- fix: remove redundant abstract methods from data classes.

## 0.1.1 March 7, 2024

- Bug #2: Add bool typehint to `dataBsToggle()` method and add default value to `true` in `dataBsTarget()`, `dataBstoggle()`, `dataDismissTarget()`, `dataDrawerTarget()`, `dataDrawerTarget()`,`dataDropdownToggle()` and `dataToggle()` (@terabytesoftw)
- fix: add boolean typing and default values to data attribute helper methods.

## 0.1.0 March 5, 2024

- Initial release
- feat: initial `ui-awesome/html-attribute` package structure.
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<!-- markdownlint-disable MD041 -->
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_dark.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_light.png">
<img src="https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_dark.png" alt="UI Awesome" width="150px">
<img src="https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome.png" alt="UI Awesome" width="25%">
</picture>
<h1 align="center">Html attribute</h1>
<h1 align="center">Html Attribute</h1>
<br>
</p>
<!-- markdownlint-enable MD041 -->
Expand Down Expand Up @@ -37,12 +35,12 @@
### Installation

```bash
composer require ui-awesome/html-attribute:^0.3
composer require ui-awesome/html-attribute:^0.6
```

### Quick start

Below are concise examples showing common attribute tasks.
Compose reusable attribute APIs by combining the package traits with the immutable attribute mixin.

```php
<?php
Expand All @@ -51,25 +49,45 @@ declare(strict_types=1);

namespace App;

use UIAwesome\Html\Attribute\Media\{HasAlt, HasSrc};
use UIAwesome\Html\Attribute\Global\{HasClass, HasData, HasId};
use UIAwesome\Html\Attribute\HasRel;
use UIAwesome\Html\Attribute\Values\Rel;
use UIAwesome\Html\Helper\Attributes;
use UIAwesome\Html\Mixin\HasAttributes;

final class ImageComponent
final class LinkAttributes
{
use HasAlt;
use HasSrc;
use HasAttributes;
use HasClass;
use HasData;
use HasId;
use HasRel;

public function render(): string
{
return Attributes::render($this->getAttributes());
}
}

$attributes = (new LinkAttributes())
->id('documentation')
->class('nav-link')
->class('is-active')
->rel(Rel::NOOPENER)
->addDataAttribute('tracking', 'docs');

echo '<a' . $attributes->render() . ' href="/docs">Documentation</a>';
```

### Documentation

For detailed configuration options and advanced usage see:

- 🧪 [Testing Guide](docs/testing.md)
- 🛠️ [Development Guide](docs/development.md)

## Package information

[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php)
[![PHP](https://img.shields.io/badge/%3E%3D8.3-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.3/en.php)
[![Latest Stable Version](https://img.shields.io/packagist/v/ui-awesome/html-attribute.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/ui-awesome/html-attribute)
[![Total Downloads](https://img.shields.io/packagist/dt/ui-awesome/html-attribute.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/ui-awesome/html-attribute)

Expand Down
Loading
Loading