-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit 7712676
Showing
14 changed files
with
591 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,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,38 @@ | ||
name: build | ||
|
||
on: [ push, pull_request ] | ||
|
||
env: | ||
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi --ignore-platform-req=php" | ||
|
||
jobs: | ||
phpunit: | ||
name: PHP ${{ matrix.php }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
php: [ '7.4', '8.0' ] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install dependencies | ||
run: composer update $DEFAULT_COMPOSER_FLAGS | ||
- name: Run unit tests | ||
run: vendor/bin/phpunit --verbose --colors=always | ||
continue-on-error: true # if is fork |
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,29 @@ | ||
# phpstorm project files | ||
.idea | ||
*.iml | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
/vendor | ||
|
||
# composer itself is not needed and related files | ||
composer.phar | ||
composer.lock | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
# phpunit itself is not needed | ||
phpunit.phar | ||
# local phpunit config | ||
/phpunit.xml |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2021 simialbi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,33 @@ | ||
# Hotwire Turbo implementation for yii2-framework | ||
|
||
[![Latest Stable Version](https://poser.pugx.org/simialbi/yii2-widget-turbo/v/stable?format=flat-square)](https://packagist.org/packages/simialbi/yii2-widget-turbo) | ||
[![Total Downloads](https://poser.pugx.org/simialbi/yii2-widget-turbo/downloads?format=flat-square)](https://packagist.org/packages/simialbi/yii2-widget-turbo) | ||
[![License](https://poser.pugx.org/simialbi/yii2-widget-turbo/license?format=flat-square)](https://packagist.org/packages/simialbi/yii2-widget-turbo) | ||
|
||
## Resources | ||
|
||
## Installation | ||
The preferred way to install this extension is through [composer](http://getcomposer.org/download/). | ||
|
||
Either run | ||
|
||
``` | ||
$ php composer.phar require --prefer-dist simialbi/yii2-widget-turbo | ||
``` | ||
|
||
or add | ||
|
||
``` | ||
"simialbi/yii2-widget-turbo": "^1.0.0" | ||
``` | ||
|
||
to the `require` section of your `composer.json`. | ||
|
||
## Usage | ||
|
||
## Example Usage | ||
|
||
|
||
## License | ||
|
||
**yii2-widget-turbo** is released under MIT license. See bundled [LICENSE](LICENSE) for details. |
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,53 @@ | ||
{ | ||
"name": "simialbi/yii2-widget-turbo", | ||
"description": "Yii2 implementation of hotwired turbo", | ||
"keywords": [ | ||
"yii2", | ||
"turbo", | ||
"hotwired" | ||
], | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/simialbi/yii2-widget-turbo/issues", | ||
"source": "https://github.com/simialbi/yii2-widget-turbo" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Simon Karlen", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "stable", | ||
"prefer-stable": true, | ||
"require": { | ||
"php": ">=7.4", | ||
"yiisoft/yii2": "^2.0.0", | ||
"simialbi/yii2-simialbi-base": ">=0.10.2 <1.0 | ^1.0.0", | ||
"npm-asset/hotwired--turbo": "^7.0.0-beta.4" | ||
}, | ||
"require-dev": { | ||
"yiisoft/yii2-coding-standards": "~2.0", | ||
"phpunit/phpunit": "^7.5.20" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"simialbi\\yii2\\turbo\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"yiiunit\\extensions\\turbo\\": "tests" | ||
} | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "https://asset-packagist.org" | ||
} | ||
], | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0.x-dev" | ||
} | ||
} | ||
} |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<phpunit bootstrap="./tests/bootstrap.php" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,91 @@ | ||
<?php | ||
/** | ||
* @package yii2-widget-turbo | ||
* @author Simon Karlen <[email protected]> | ||
*/ | ||
|
||
namespace simialbi\yii2\turbo; | ||
|
||
use yii\base\InvalidConfigException; | ||
use yii\base\Widget; | ||
use yii\helpers\Html; | ||
use yii\helpers\Url; | ||
|
||
/** | ||
* | ||
*/ | ||
class Frame extends Widget | ||
{ | ||
/** | ||
* @var array the HTML attributes for the widget container tag. The following special options are recognized: | ||
* | ||
* - `src`: array|string, the source to be loaded by frame. Will be processed by [[\yii\helpers\Url::to()]] if set. | ||
* | ||
* @see \yii\helpers\Url::to() for details on how src option is being processed. | ||
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. | ||
*/ | ||
public array $options = []; | ||
|
||
/** | ||
* @var bool Whether or not the content should not be loaded until the frame is visible. | ||
*/ | ||
public bool $lazyLoading = false; | ||
|
||
/** | ||
* @var bool Prevents any navigation if true. | ||
*/ | ||
public bool $disabled = false; | ||
|
||
/** | ||
* @var string|null Refers to another [[Frame]] element by id to be navigated when a descendant `<a>` is | ||
* clicked. When `_top`, navigate the window. | ||
*/ | ||
public ?string $target; | ||
|
||
/** | ||
* @var bool Controls whether or not to scroll a [[Frame]] element (and its descendant [[Frame]] elements) | ||
* into view when after loading. | ||
*/ | ||
public bool $autoscroll = false; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @throws InvalidConfigException | ||
*/ | ||
public function init(): void | ||
{ | ||
parent::init(); | ||
|
||
if (!isset($this->options['id'])) { | ||
throw new InvalidConfigException("The 'id' attribute must be set!"); | ||
} | ||
if (isset($this->options['src'])) { | ||
$this->options['src'] = Url::to($this->options['src']); | ||
|
||
if ($this->lazyLoading && !isset($this->options['loading'])) { | ||
$this->options['loading'] = 'lazy'; | ||
} | ||
} | ||
if ($this->disabled && !isset($this->options['disabled'])) { | ||
$this->options['disabled'] = true; | ||
} | ||
if ($this->autoscroll && !isset($this->options['autoscroll'])) { | ||
$this->options['autoscroll'] = true; | ||
} | ||
if (isset($this->target) && !isset($this->options['target'])) { | ||
$this->options['target'] = $this->target; | ||
} | ||
|
||
echo Html::beginTag('turbo-frame', $this->options); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function run() | ||
{ | ||
TurboAsset::register($this->view); | ||
|
||
echo Html::endTag('turbo-frame'); | ||
} | ||
} |
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 | ||
/** | ||
* @package yii2-widget-turbo | ||
* @author Simon Karlen <[email protected]> | ||
*/ | ||
|
||
namespace simialbi\yii2\turbo; | ||
|
||
use yii\base\Widget; | ||
|
||
/** | ||
* | ||
*/ | ||
class Stream extends Widget | ||
{ | ||
|
||
} |
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,37 @@ | ||
<?php | ||
/** | ||
* @package yii2-widget-turbo | ||
* @author Simon Karlen <[email protected]> | ||
*/ | ||
|
||
namespace simialbi\yii2\turbo; | ||
|
||
use simialbi\yii2\web\AssetBundle; | ||
|
||
/** | ||
* The turbo asset bundle | ||
*/ | ||
class TurboAsset extends AssetBundle | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $sourcePath = '@npm/hotwired--turbo/dist'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $js = [ | ||
'turbo.es2017-umd.js' | ||
]; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $publishOptions = [ | ||
'only' => [ | ||
'turbo.es2017-umd.js', | ||
'turbo.es2017-umd.js.map' | ||
] | ||
]; | ||
} |
Oops, something went wrong.