PHP classes that make creating Bootstrap markup easier and cleaner

dev-main 2023-09-05 06:29 UTC

This package is auto-updated.

Last update: 2024-05-05 08:04:50 UTC


README

Bootstrap is super awesome for quickly building easy-to-use—and easy-on-the-eyes—Web interfaces, but things can quickly become very, very fiddly. We really appreciate the Bootstrap team's consideration of accessibility and semantics, but that necessarily comes with a lot of words and a lot of wiring.

Strappin' is a growing collection of PHP classes, and—crucially—a factory, that makes creating Bootstrap markup quicker and easier. Its power is in joining things up so you can stop worrying about IDs, roles, and aria-this~aria-that.

This library can be easily integrated with templating engines such as Twig.

Example

Strappin' is still being moulded into the right shape—so we aren't ready to fully document everything yet—but here's an example of how you can currently use the library to create a tabbed interface:

use StrappinPhp\Engine\Factory;

echo Factory::create()->createTabbedInterface([
    'panels' => [
        [
            'action' => 'bs:toggle?object=tab&target=tab-pane-optimal-1',
            'label' => 'Tab-Pane 1 Label',
            'content' => 'Tab-pane 1 content.',
        ],
        [
            'action' => 'bs:toggle?object=tab&target=tab-pane-optimal-2',
            'label' => 'Tab-Pane 2 Label',
            'content' => 'Tab-pane 2 content.',
        ],
        [
            'action' => 'https://example.com/',
            'label' => 'External Link',
        ],
    ],
]);

ℹ️ We use a custom URL format to easily express Bootstrap actions

Live Demo

For now:

  • Clone this repo
  • Run composer install at the root of the clone
  • Navigate to <hostname>/<path-to-clone>/tests/functional/index.php