Skip to content

Commit

Permalink
Add doc ButtonToggle::class. (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 27, 2024
1 parent fbbc025 commit 335d44c
Show file tree
Hide file tree
Showing 7 changed files with 544 additions and 83 deletions.
31 changes: 14 additions & 17 deletions docs/tag/A.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ $anchor->dataAttributes(['bs-toggle' => 'modal', 'bs-target' => '#exampleModal',

Explore additional methods for setting various attributes such as `autofocus`, `hidden`, `download`, etc.

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/A/AttributeTest.php) for comprehensive
examples.

## Prefix and Suffix

Use `prefix` and `suffix` methods to add text before and after the `anchor` tag, respectively.
Expand All @@ -77,9 +74,6 @@ $html = $anchor->content('Home')->prefix('Go to: ')->render();
$html = $anchor->content('Home')->suffix(' | Welcome')->render();
```

Examples of `prefix` and `suffix` usage can be found in the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/A/CustomMethodTest.php)
for comprehensive examples.

## Template

The `template` method allows you to customize the `HTML` output of the a element.
Expand All @@ -97,11 +91,11 @@ The following template tags are available:
$a->template('<span>{tag}</span>');
```

Examples of `template` usage can be found in the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/A/CustomMethodTest.php)
for comprehensive examples.

## Attributes

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/A/AttributeTest.php) for comprehensive
examples.

The following methods are available for setting attributes:

| Method | Description |
Expand Down Expand Up @@ -140,20 +134,23 @@ The following methods are available for setting attributes:

## Custom methods

Refer to the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/A/CustomMethodTest.php) for
comprehensive examples.

The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `prefix()` | Add text before the `a` element. |
| `prefixContainer()` | Add a `container` before the `a` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container`. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container`. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container`. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container` element. |
| `render()` | Generates the `HTML` output. |
| `suffix()` | Add text after the `a` element. |
| `suffixContainer()` | Add a `container` after the `a` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container`. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container`. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container`. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `template()` | Set the `template` for the `a` element. |
| `widget()` | Instantiates the `A::class`. |
8 changes: 4 additions & 4 deletions docs/tag/Body.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ $body->dataAttributes(['analytics' => 'trackClick']);

Explore additional methods for setting various attributes such as `lang`, `name`, `style`, `title`, etc.

## Attributes

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/Body/AttributeTest.php) for comprehensive
examples.

## Attributes

The following methods are available for setting attributes:

| Method | Description |
Expand All @@ -106,8 +106,8 @@ The following methods are available for setting attributes:

## Custom methods

Refer to the [Custom Methods Tests](https://github.com/php-forge/html/blob/main/tests/Body/CustomMethodTest.php) for comprehensive
examples.
Refer to the [Custom Methods Tests](https://github.com/php-forge/html/blob/main/tests/Body/CustomMethodTest.php) for
comprehensive examples.

The following methods are available for customizing the `HTML` output:

Expand Down
39 changes: 18 additions & 21 deletions docs/tag/Button.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ $button->dataAttributes(['bs-toggle' => 'modal', 'bs-target' => '#exampleModal',

Explore additional methods for setting various `attributes` such as `ariaControls`, `tabIndex`, `role`, etc.

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/Button/AttributeTest.php) for comprehensive
examples.

## Container

Use the `container()` method to add a `container` around the `button` tag.
Expand All @@ -87,9 +84,6 @@ $button = $button->content('Home')->prefix('Go to: ')->render();
$button = $button->content('Home')->suffix(' | Welcome')->render();
```

Examples of `prefix` and `suffix` usage can be found in the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/Button/CustomMethodTest.php)
for comprehensive examples.

## Submit and reset

Use the `submit` and `reset` methods to set the `type` attribute to `submit` and `reset`, respectively.
Expand Down Expand Up @@ -118,14 +112,14 @@ The following template tags are available:

```php
// Example: Using a custom template
$a->template('<span>{tag}</span>');
$button->template('<span>{tag}</span>');
```

Examples of `template` usage can be found in the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/Button/CustomMethodTest.php)
for comprehensive examples.

## Attributes

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/Button/AttributeTest.php) for comprehensive
examples.

The following methods are available for setting attributes:

| Method | Description |
Expand All @@ -152,27 +146,30 @@ The following methods are available for setting attributes:

## Custom methods

Refer to the [Custom Method Test](https://github.com/php-forge/html/blob/main/tests/Button/CustomMethodTest.php) for
comprehensive examples.

The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `container()` | Add a `container` around the `button` element. |
| `containerAttributes()` | Set `attributes` for the `container`. |
| `containerClass()` | Set the `class` attribute for the `container`. |
| `containerTag()` | Set the `tag` for the `container`. |
| `container()` | Set enabled or disabled for the `container` element. |
| `containerAttributes()` | Set `attributes` for the `container` element. |
| `containerClass()` | Set the `class` attribute for the `container` element. |
| `containerTag()` | Set the `tag` for the `container` element. |
| `prefix()` | Add text before the `button` element. |
| `prefixContainer()` | Add a `container` before the `button` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container`. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container`. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container`. |
| `render()` | Generates the `HTML` output. |
| `reset()` | Set the `type` attribute to `reset`. |
| `submit()` | Set the `type` attribute to `submit`. |
| `suffix()` | Add text after the `button` element. |
| `suffixContainer()` | Add a `container` after the `button` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container`. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container`. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container`. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `tagName()` | Set the `tag` for the `button` element. |
| | Allowed values: `a`, `button`. |
| `template()` | Set the `template` for the `button` element. |
Expand Down
147 changes: 147 additions & 0 deletions docs/tag/ButtonToggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# ButtonToggle

The `<button>` toggle is a custom tag representing a toggle button.

## Basic Usage

Instantiate the `buttonToggle` class using `ButtonToggle::widget()`.

```php
$buttonToggle = ButtonToggle::widget();
```

## Setting Attributes

Use the provided methods to set specific `attribute` for the `buttonToggle` element.

```php
// Example: Setting the title attribute
$buttonToggle->title('Click me');
```

Or, use the `attributes` method to set multiple `attributes` at once.

```php
$buttonToggle->attributes(['title' => 'Click me', 'class' => 'btn btn-primary']);
```

## Adding Content

If you want to include content within the `buttonToggle` tag, use the `content` method.

```php
$buttonToggle->content('Click me');
```

## Rendering

Generate the `HTML` output using the `render` method.

```php
$html = $buttonToggle->render();
```

Or, use the magic `__toString` method.

```php
$html = (string) $button;
```

## Common Use Cases

Below are examples of common use cases:

```php
// Example: Adding multiple attributes
$buttonToggle->class('external')->content('Click me')->title('Click me');

// Example: Using data attributes
$buttonToggle->dataAttributes(['bs-toggle' => 'modal', 'bs-target' => '#exampleModal', 'analytics' => 'trackClick']);
```

Explore additional methods for setting various `attributes` such as `ariaControls`, `tabIndex`, `role`, etc.

## Template

The `template` method allows you to customize the `HTML` output of the `button` element.

The following template tags are available:

| Tag | Description |
| ---------- | ----------------------- |
| `{toggle}` | The `button` element. |
| `{icon}` | The `icon` element. |
| `{content}`| The `content` element. |

```php
// Example: Using a custom template
$buttonToggle->template('<span>{toggle}</span>');
```

## Toggle examples:

- [Bootstrap5](https://github.com/php-forge/html/blob/main/tests/ButtonToggle/BootstrapTest.php)
- [Flowbite](https://github.com/php-forge/html/blob/main/tests/ButtonToggle/FlowbiteTest.php)

## Attributes

Refer to the [Attribute Tests](https://github.com/php-forge/html/blob/main/tests/ButtonToggle/AttributeTest.php) for
comprehensive examples.

The following methods are available for setting attributes:

| Method | Description |
| --------------------- | -------------------------------------------------------------------------------------------- |
| `ariaControls()` | Set the `aria-controls` attribute. |
| `ariaDescribedby()` | Set the `aria-describedby` attribute. |
| `ariaExpanded()` | Set the `aria-expanded` attribute. |
| `ariaLabel()` | Set the `aria-label` attribute. |
| `attributes()` | Set multiple `attributes` at once. |
| `class()` | Set the `class` attribute. |
| `content()` | Set the `content` within the `button` element. |
| `dataAttributes()` | Set multiple `data-attributes` at once. |
| `dataBsAutoClose()` | Set the `data-bs-auto-close` attribute. |
| `dataBsDismiss()` | Set the `data-bs-dismiss` attribute. |
| `dataBsTarget()` | Set the `data-bs-target` attribute. |
| `dataBsToggle()` | Set the `data-bs-toggle` attribute. |
| `dataCollapseToggle()`| Set the `data-collapse-toggle` attribute. |
| `dataDismissTarget()` | Set the `data-dismiss-target` attribute. |
| `dataDrawerTarget()` | Set the `data-drawer-target` attribute. |
| `dataDropdownToggle()`| Set the `data-dropdown-toggle` attribute. |
| `dataToggle()` | Set the `data-toggle` attribute. |
| `id()` | Set the `id` attribute. |
| `name()` | Set the `name` attribute. |
| `role()` | Set the `role` attribute. |
| `style()` | Set the `style` attribute. |
| `tabindex()` | Set the `tabindex` attribute. |
| `title()` | Set the `title` attribute. |

## Custom methods

Refer to the [Custom Methods Tests](https://github.com/php-forge/html/blob/main/tests/Body/CustomMethodTest.php) for
comprehensive examples.

The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `icon()` | Set enable or disable the `icon` element. |
| `iconAttributes()` | Set multiple `attributes` for the `icon` element. |
| `iconClass()` | Set the `class` attribute for the `icon` element. |
| `iconContainer` | Set Enable or disable the `icon-container` tag. |
| `iconContainerAttributes()` | Set multiple `attributes` for the `icon-container` tag. |
| `iconContainerClass()` | Set the `class` attribute for the `icon-container` tag. |
| `iconContainerTag()` | Set the `tag` for the `icon-container` tag. |
| `iconContent()` | Set the `content` for the `icon` element. |
| `iconFilePath()` | Set the `file path` for the `icon` element. |
| `iconTag()` | Set the `tag` for the `icon` element. |
| `template()` | Set the `template` for the `button-toggle` element. |
| `toggle()` | Set enable or disable the `toggle`. |
| `toggleAttributes()` | Set multiple `attributes` for the `toggle` element. |
| `toggleClass()` | Set the `class` attribute for the `toggle` element. |
| `toggleContent()` | Set the `content` for the `toggle` element. |
| `toggleDataAttributes()` | Set multiple `data-attributes` for the `toggle` element. |
| `toggleId()` | Set the `id` attribute for the `toggle` element. |
| `togglePrefix()` | Set the `prefix` for the `toggle` element. |
| `toggleSuffix()` | Set the `suffix` for the `toggle` element. |
| `toggleTag()` | Set the `tag` for the `toggle` element. |

0 comments on commit 335d44c

Please sign in to comment.