forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class Attributes | ||
{ | ||
public static function create(): self | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
|
||
# HTML, SVG, accessibility, and more | ||
|
||
|
||
## Html Accessibility API Mappings 1.0 (2024) | ||
|
||
* https://w3c.github.io/html-aam/#abstract | ||
|
||
## Core Accessibility API Mappings 1.2 (19 December 2024) | ||
|
||
* https://www.w3.org/TR/core-aam-1.2/ | ||
|
||
## Accessible Rich Internet Applications (WAI-ARIA) 1.2 (2023) | ||
|
||
* https://www.w3.org/TR/wai-aria-1.2/# | ||
|
||
## Accessible Name and Description Computation 1.2 (2024) | ||
|
||
* https://www.w3.org/TR/accname-1.2/#abstract | ||
|
||
|
||
Docs | ||
* WCAG 2 Overview for Web Content Accessibility Guidelines https://www.w3.org/WAI/intro/wcag (in English) | ||
* Authoring Tool Accessibility Guidelines (ATAG) Overview https://www.w3.org/WAI/intro/atag (in English) | ||
* User Agent Accessibility Guidelines (UAAG) Overview https://www.w3.org/WAI/intro/uaag (in English) | ||
* WAI-ARIA Overview for Accessible Rich Internet Applications https://www.w3.org/WAI/intro/aria (in English) | ||
|
||
|
||
Web Content Accessibility Guidelines (WCAG) https://www.w3.org/TR/WCAG/ | ||
Authoring Tool Accessibility Guidelines (ATAG) https://www.w3.org/TR/ATAG/ | ||
User Agent Accessibility Guidelines (UAAG) https://www.w3.org/TR/UAAG/ | ||
Accessible Rich Internet Applications (WAI-ARIA) https://www.w3.org/TR/wai-aria/ | ||
|
||
|
||
Web Content Accessibility Guidelines (WCAG) 2.2 https://www.w3.org/TR/WCAG22/ | ||
Accessible Rich Internet Applications (WAI-ARIA) 1.2 https://www.w3.org/TR/wai-aria-1.2/ | ||
Authoring Tool Accessibility Guidelines (ATAG) 2.0 https://www.w3.org/TR/ATAG20/ | ||
User Agent Accessibility Guidelines (UAAG) 2.0 https://www.w3.org/TR/UAAG20/ | ||
|
||
|
||
Understanding WCAG https://www.w3.org/WAI/WCAG22/Understanding/ | ||
Techniques for WCAG https://www.w3.org/WAI/WCAG22/Techniques/ | ||
ARIA Authoring Practices Guide (APG) https://www.w3.org/WAI/ARIA/apg/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
|
||
## Schema metadata | ||
|
||
* https://www.w3.org/WAI/ARIA/schemata/aria-1.rdf | ||
|
||
```xml | ||
|
||
<owl:Class rdf:ID="radio"> | ||
<rdfs:subClassOf rdf:resource="#input"/> | ||
<rdfs:seeAlso rdf:resource="https://www.w3.org/TR/html5/forms.html#radio-button-state-(type=radio)"/> | ||
<role:supportedState rdf:resource="http://www.w3.org/2005/07/aaa#aria-posinset"/> | ||
<role:supportedState rdf:resource="http://www.w3.org/2005/07/aaa#aria-setsize"/> | ||
<role:requiredState rdf:resource="http://www.w3.org/2005/07/aaa#aria-checked"/> | ||
<role:nameFrom>contents</role:nameFrom> | ||
<role:nameFrom>author</role:nameFrom> | ||
</owl:Class> | ||
|
||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\Html\Attribute; | ||
|
||
class Attribute | ||
{ | ||
public function __construct( | ||
public readonly string $attribute, | ||
public readonly string $value, | ||
public readonly string $type, | ||
) { | ||
} | ||
|
||
public function apply(string $tag): bool | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\Html\Attribute\Aria; | ||
|
||
enum AttributeType: string { | ||
|
||
case State = 'state'; | ||
case Property = 'property'; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\Html\Attribute; | ||
|
||
class Attributes | ||
{ | ||
public static function isState(string $attribute): bool { | ||
return in_array(self::trimPrefix($attribute), self::STATES, true); | ||
} | ||
|
||
public static function isProperty(string $attribute): bool { | ||
return in_array(self::trimPrefix($attribute), self::PROPERTIES, true); | ||
} | ||
|
||
public static function trimPrefix(string $attribute): string { | ||
return str_starts_with($attribute, 'aria-') ? substr($attribute, 5) : $attribute; | ||
} | ||
|
||
public static function withPrefix(string $attribute): string { | ||
return str_starts_with($attribute, 'aria-') ? $attribute : 'aria-' . $attribute; | ||
} | ||
|
||
private const array STATES = [ | ||
'busy' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span', 'button', 'input', 'select', 'textarea'], | ||
], | ||
'checked' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input'], | ||
], | ||
'current' => [ | ||
'default' => 'page', // Possible values: 'page', 'step', 'location', 'date', 'time', 'true' | ||
'type' => 'token list', | ||
'elements' => ['a', 'button', 'div', 'span', 'li', 'menuitem', 'option'], | ||
], | ||
'disabled' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button', 'input', 'select', 'textarea', 'a', 'div', 'span'], | ||
], | ||
'expanded' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button', 'div', 'span', 'li', 'menuitem', 'option', 'a'], | ||
], | ||
'grabbed' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span'], | ||
], | ||
'modal' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span'], | ||
], | ||
'multiline' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'textarea'], | ||
], | ||
'multiselectable' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['listbox', 'grid', 'treegrid'], | ||
], | ||
'pressed' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button'], | ||
], | ||
'readonly' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'textarea'], | ||
], | ||
'required' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'select', 'textarea'], | ||
], | ||
'selected' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['option', 'li', 'menuitem'], | ||
], | ||
]; | ||
|
||
private const array PROPERTIES = [ | ||
'activedescendant', | ||
'atomic', | ||
'autocomplete', | ||
'colcount', | ||
'colindex', | ||
'colspan', | ||
'controls', | ||
'describedby', | ||
'details', | ||
'dropeffect', | ||
'errormessage', | ||
'flowto', | ||
'haspopup', | ||
'hidden', | ||
'invalid', | ||
'keyshortcuts', | ||
'label', | ||
'labelledby', | ||
'level', | ||
'live', | ||
'orientation', | ||
'owns', | ||
'placeholder', | ||
'posinset', | ||
'roledescription', | ||
'rowcount', | ||
'rowindex', | ||
'rowspan', | ||
'setsize', | ||
'sort', | ||
'valuemax', | ||
'valuemin', | ||
'valuenow', | ||
'valuetext', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\Html\Aria; | ||
|
||
/** | ||
* https://www.w3.org/TR/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html | ||
*/ | ||
class Conformance | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
// 11 December 2024 | ||
|
||
// https://w3c.github.io/html-aam/ | ||
|
||
|
||
// Description computation | ||
// https://www.w3.org/TR/accname-1.2/#mapping_additional_nd_description | ||
|
||
|
||
// Text equivalent computation | ||
// 4.3 Text Equivalent Computation | ||
// https://www.w3.org/TR/accname-1.2/#mapping_additional_nd_te | ||
|
||
|
||
// Accesible name computation per element | ||
// https://w3c.github.io/html-aam/#accname-computation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\Html\Aria; | ||
|
||
class Role | ||
{ | ||
public static function isState(string $attribute): bool { | ||
return in_array(self::trimPrefix($attribute), self::STATES, true); | ||
} | ||
|
||
public static function isProperty(string $attribute): bool { | ||
return in_array(self::trimPrefix($attribute), self::PROPERTIES, true); | ||
} | ||
|
||
public static function trimPrefix(string $attribute): string { | ||
return str_starts_with($attribute, 'aria-') ? substr($attribute, 5) : $attribute; | ||
} | ||
|
||
public static function withPrefix(string $attribute): string { | ||
return str_starts_with($attribute, 'aria-') ? $attribute : 'aria-' . $attribute; | ||
} | ||
|
||
private const array STATES = [ | ||
'busy' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span', 'button', 'input', 'select', 'textarea'], | ||
], | ||
'checked' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input'], | ||
], | ||
'current' => [ | ||
'default' => 'page', // Possible values: 'page', 'step', 'location', 'date', 'time', 'true' | ||
'type' => 'token list', | ||
'elements' => ['a', 'button', 'div', 'span', 'li', 'menuitem', 'option'], | ||
], | ||
'disabled' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button', 'input', 'select', 'textarea', 'a', 'div', 'span'], | ||
], | ||
'expanded' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button', 'div', 'span', 'li', 'menuitem', 'option', 'a'], | ||
], | ||
'grabbed' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span'], | ||
], | ||
'modal' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['div', 'span'], | ||
], | ||
'multiline' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'textarea'], | ||
], | ||
'multiselectable' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['listbox', 'grid', 'treegrid'], | ||
], | ||
'pressed' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['button'], | ||
], | ||
'readonly' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'textarea'], | ||
], | ||
'required' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['input', 'select', 'textarea'], | ||
], | ||
'selected' => [ | ||
'default' => false, | ||
'type' => 'boolean', | ||
'elements' => ['option', 'li', 'menuitem'], | ||
], | ||
]; | ||
|
||
private const array PROPERTIES = [ | ||
'activedescendant', | ||
'atomic', | ||
'autocomplete', | ||
'colcount', | ||
'colindex', | ||
'colspan', | ||
'controls', | ||
'describedby', | ||
'details', | ||
'dropeffect', | ||
'errormessage', | ||
'flowto', | ||
'haspopup', | ||
'hidden', | ||
'invalid', | ||
'keyshortcuts', | ||
'label', | ||
'labelledby', | ||
'level', | ||
'live', | ||
'orientation', | ||
'owns', | ||
'placeholder', | ||
'posinset', | ||
'roledescription', | ||
'rowcount', | ||
'rowindex', | ||
'rowspan', | ||
'setsize', | ||
'sort', | ||
'valuemax', | ||
'valuemin', | ||
'valuenow', | ||
'valuetext', | ||
]; | ||
} |
Oops, something went wrong.