Skip to content

Commit

Permalink
Enhace Breadcrumbs, update docs (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 21, 2021
1 parent 1c0da6a commit 61d1a61
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 248 deletions.
18 changes: 10 additions & 8 deletions .scrutinizer.yml
Expand Up @@ -6,27 +6,29 @@ filter:
- "src/*"

build:
image: default-bionic

environment:
php:
version: 8.0.11
ini:
xdebug.mode: coverage

nodes:
analysis:
environment:
php: 7.4.12

tests:
override:
- php-scrutinizer-run

tests-and-coverage:
environment:
php: 7.4.12

phpunit:
dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: "./vendor/bin/phpunit --coverage-clover ./coverage.xml"
- command: ./vendor/bin/phpunit --coverage-clover ./coverage.xml
on_node: 1
coverage:
file: coverage.xml
Expand Down
36 changes: 26 additions & 10 deletions docs/breadcrumbs.md
Expand Up @@ -28,28 +28,28 @@ $this->setJsFiles($assetManager->getJsFiles());
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>

<?= Breadcrumbs::widget()
->attributes(['class' => 'is-centered'])
->homeItem([
'label' => 'Index',
'url' => '/index',
'icon' => 'fas fa-home',
'iconOptions' => ['class' => 'icon']
'iconAttributes' => ['class' => 'icon']
])
->items([
[
'label' => 'About',
'url' => '/about',
'icon' => 'fas fa-thumbs-up',
'iconOptions' => ['class' => 'icon']
'iconAttributes' => ['class' => 'icon']
]
])
->options(['class' => 'is-centered'])
->render() ?>
```

The code above generates the following HTML:

```html
<nav id="w1-breadcrumbs" class="breadcrumb is-centered" aria-label="breadcrumbs">
<nav id="w71391357285001-breadcrumbs" class="is-centered breadcrumb" aria-label="breadcrumbs">
<ul>
<li><span class="icon"><i class="fas fa-home"></i></span><a href="/index">Index</a></li>
<li><span class="icon"><i class="fas fa-thumbs-up"></i></span><a href="/about">About</a></li>
Expand All @@ -59,12 +59,28 @@ The code above generates the following HTML:

Method | Description | Default
-------|-------------|---------
`id(string $value)` | Widget ID. | `''`
`activeItemTemplate(string $value)`| Template used to render each active item in the breadcrumbs. | `<li class=\"is-active\"><a aria-current=\"page\">{icon}{label}</li>\n`
`aria-label` | Defines a string value that labels the current element. | `breadcrumbs`
`attributes(array $value)` | HTML attributes for the widget container nav tag. | `[]`
`autoIdPrefix(string $value)` | Prefix to the automatically generated widget ID. | `w`
`withoutEncodeLabels()` | Disable encoding for labels. | `false`
`encode()` | Enable/Disable encoding for labels. | `false`
`homeItem(?array $value)` | The first item in the breadcrumbs (called home link). | `['label' => 'Home', 'url' => '/']`
`itemTemplate(string $value)` | Template used to render each inactive item in the breadcrumbs. | `<li>{icon}{link}</li>\n`
`activeItemTemplate(string $value)`| Template used to render each active item in the breadcrumbs. | `<li class=\"is-active\"><a aria-current=\"page\">{icon}{label}</li>\n`
`id(string $value)` | Widget ID. | `''`
`items(array $value)` | List of items to appear in the breadcrumbs. | `[]`
`itemsOptions(array $value)` | HTML attributes for the items widget. | `[]`
`options(array $value)` | HTML attributes for the widget container nav tag. | `[]`
`itemsAttributes(array $value)` | HTML attributes for the items widget. | `[]`
`itemTemplate(string $value)` | Template used to render each inactive item in the breadcrumbs. | `<li>{icon}{link}</li>\n`

Items structure is an array of the following structure:

```php
[
[
'label' => 'Home',
'url' => '/',
'template' => '<li><a href="{url}">{icon}{label}</a></li>',
'encode' => true,
'icon' => 'fas fa-home',
'iconAttributes' => ['class' => 'icon']
],
]
```

0 comments on commit 61d1a61

Please sign in to comment.