Skip to content

Commit

Permalink
(temp work to move)
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Dec 25, 2024
1 parent 07cbb0b commit 470c5da
Show file tree
Hide file tree
Showing 19 changed files with 1,306 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Html/Attributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class Attributes
{
public static function create(): self
{
}

}
45 changes: 45 additions & 0 deletions src/Html/README.md
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/

19 changes: 19 additions & 0 deletions src/Html/data/README.md
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>

```
666 changes: 666 additions & 0 deletions src/Html/data/aria-1.rdf

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/Html/src/Aria/Attribute.php
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
{
}
}
11 changes: 11 additions & 0 deletions src/Html/src/Aria/AttributeType.php
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';

}

127 changes: 127 additions & 0 deletions src/Html/src/Aria/Attributes.php
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',
];
}
11 changes: 11 additions & 0 deletions src/Html/src/Aria/Conformance.php
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
{

}
18 changes: 18 additions & 0 deletions src/Html/src/Aria/Mapping/AAM.php
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
127 changes: 127 additions & 0 deletions src/Html/src/Aria/Role.php
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',
];
}
Loading

0 comments on commit 470c5da

Please sign in to comment.