Skip to content

Commit

Permalink
Initial commit. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 31, 2023
1 parent cee38f5 commit 7b38522
Show file tree
Hide file tree
Showing 26 changed files with 715 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ phpunit.phar

# windows thumbnail cache
Thumbs.db

#package-lock.json
/package-lock.json
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
<p align="center">
<a href="https://github.com/yii-tools/template" target="_blank">
<a href="https://github.com/yii-tools/vanillajs-datepicker-asset" target="_blank">
<img src="https://avatars.githubusercontent.com/u/121752654?s=200&v=4" height="100px">
</a>
<h1 align="center">Template.</h1>
<h1 align="center">Asset for VanillaJs DatePicker for YiiFramework v.3.0.</h1>
<br>
</p>

## Requirements

The minimun version of PHP required by this package is PHP 8.1.

For install this package, you need [composer](https://getcomposer.org/) and [npm](https://www.npmjs.com/).

## Install

For use create a new repository from this template. For more information see [Creating a repository from a template](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template).
Preferably install with composer:

```shell
composer require yii-tools/vanillajs-datepicker-asset
```

## Usage

Also you can git clone this repository. For more information see [Cloning a repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
For use this package, read the [docs](/docs/install.md).

## Checking dependencies

Expand Down Expand Up @@ -48,12 +60,12 @@ composer run test

## CI status

[![build](https://github.com/yii-tools/template/actions/workflows/build.yml/badge.svg)](https://github.com/yii-tools/template/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/yii-tools/template/branch/main/graph/badge.svg?token=MF0XUGVLYC)](https://codecov.io/gh/yii-tools/template)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii-tools%2Ftemplate%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/yii-tools/template/main)
[![static analysis](https://github.com/yii-tools/template/actions/workflows/static.yml/badge.svg)](https://github.com/yii-tools/template/actions/workflows/static.yml)
[![type-coverage](https://shepherd.dev/github/yii-tools/template/coverage.svg)](https://shepherd.dev/github/yii-tools/template)
[![StyleCI](https://github.styleci.io/repos/494495136/shield?branch=main)](https://github.styleci.io/repos/494495136?branch=main)
[![build](https://github.com/yii-tools/vanillajs-datepicker-asset/actions/workflows/build.yml/badge.svg)](https://github.com/yii-tools/vanillajs-datepicker-asset/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/yii-tools/vanillajs-datepicker-asset/branch/main/graph/badge.svg?token=MF0XUGVLYC)](https://codecov.io/gh/yii-tools/vanillajs-datepicker-asset)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii-tools%2Fvanillajs-datepicker-asset%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/yii-tools/vanillajs-datepicker-asset/main)
[![static analysis](https://github.com/yii-tools/vanillajs-datepicker-asset/actions/workflows/static.yml/badge.svg)](https://github.com/yii-tools/vanillajs-datepicker-asset/actions/workflows/static.yml)
[![type-coverage](https://shepherd.dev/github/yii-tools/vanillajs-datepicker-asset/coverage.svg)](https://shepherd.dev/github/yii-tools/vanillajs-datepicker-asset)
[![StyleCI](https://github.styleci.io/repos/595529272/shield?branch=main)](https://github.styleci.io/repos/595529272?branch=main)

## License

Expand Down
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "yii-tools/template",
"name": "yii-tools/vanillajs-datepicker-asset",
"type": "library",
"description": "_____",
"description": "Asset for VanillaJs DatePicker for YiiFramework v.3.0.",
"keywords": [
"_____"
"yii-tools",
"asset",
"vanillajs-datepicker",
"yii3"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.1"
"php": "^8.1",
"foxy/foxy": "^1.2",
"yiisoft/assets": "^3.0",
"yiisoft/files": "^2.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.3",
Expand All @@ -19,12 +25,12 @@
},
"autoload": {
"psr-4": {
"Template\\": "src"
"Yii\\DatePicker\\Asset\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Template\\Tests\\": "tests"
"Yii\\DatePicker\\Asset\\Tests\\": "tests"
}
},
"extra": {
Expand All @@ -35,7 +41,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true
"infection/extension-installer": true,
"foxy/foxy": true
}
},
"scripts": {
Expand Down
57 changes: 57 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Using assets

Assets are files that are not processed by Webpack. They are copied directly to the output folder. This includes images, fonts, and any other files that you want to use in your project.

To use an asset, you need to import it from JavaScript or CSS.

Register the asset bundle with a view component such as a layout view. You can register it in a layout view so that it is available in all views that extend from this layout, or you can register it in a view that uses the asset.

```php
file: ./resources/views/layout/main.php

<?php

declare(strict_types=1);

use Yii\DatePicker\Asset\Npm\Dev\DatePickerBootstrap5Asset;

/**
* @var \Yiisoft\Assets\AssetManager $assetManager
*/

// Register the asset bundle with a asset manager component.
$assetManager->register(DatePickerBootstrap5Asset::class);

// Set parameters for the registered asset bundle a view component.
$this->addCssFiles($assetManager->getCssFiles());
$this->addCssStrings($assetManager->getCssStrings());
$this->addJsFiles($assetManager->getJsFiles());
$this->addJsStrings($assetManager->getJsStrings());
$this->addJsVars($assetManager->getJsVars());
```

Also you can register the asset bundle via container configuration:

```php
file: ./config/params.php

<?php

declare(strict_types=1);

use Yii\DatePicker\Asset\Cdn\DatePickerBootstrap5Asset;

return [
'yiisoft/assets' => [
'assetManager' => [
'register' => [
DatePickerBootstrap5Asset::class,
],
],
],
];
```

## Using npm packages

[npm](https://www.npmjs.com/) packages are installed via [fxpio/foxy](https://github.com/fxpio/foxy) and are available in the `node_modules` directory.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "vainilla-datepicker",
"version": "1.0.0",
"dependencies": {
"vanillajs-datepicker": "^1.2.0"
},
"license": "mit"
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</coverage>

<testsuites>
<testsuite name="Template">
<testsuite name="DatePicker-Asset">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
13 changes: 13 additions & 0 deletions src/Cdn/DatePickerAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Cdn;

use Yiisoft\Assets\AssetBundle;

final class DatePickerAsset extends AssetBundle
{
public bool $cdn = true;
public array $js = ['https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/dist/js/datepicker-full.min.js'];
}
14 changes: 14 additions & 0 deletions src/Cdn/DatePickerBootstrap5Asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Cdn;

use Yiisoft\Assets\AssetBundle;

final class DatePickerBootstrap5Asset extends AssetBundle
{
public bool $cdn = true;
public array $css = ['https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/dist/css/datepicker-bs5.min.css'];
public array $depends = [DatePickerAsset::class];
}
14 changes: 14 additions & 0 deletions src/Cdn/DatePickerBulmaAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Cdn;

use Yiisoft\Assets\AssetBundle;

final class DatePickerBulmaAsset extends AssetBundle
{
public bool $cdn = true;
public array $css = ['https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/dist/css/datepicker-bulma.min.css'];
public array $depends = [DatePickerAsset::class];
}
16 changes: 16 additions & 0 deletions src/Cdn/DatePickerFoundationAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Cdn;

use Yiisoft\Assets\AssetBundle;

final class DatePickerFoundationAsset extends AssetBundle
{
public bool $cdn = true;
public array $css = [
'https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.2.0/dist/css/datepicker-foundation.min.css',
];
public array $depends = [DatePickerAsset::class];
}
13 changes: 0 additions & 13 deletions src/Example.php

This file was deleted.

27 changes: 27 additions & 0 deletions src/Npm/Dev/DatePickerAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Npm\Dev;

use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

final class DatePickerAsset extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
public string|null $sourcePath = '@npm/vanillajs-datepicker/dist';
public array $js = ['js/datepicker-full.js'];

public function __construct()
{
$pathMatcher = new PathMatcher();

$this->publishOptions = [
'filter' => $pathMatcher->only(
'**/js/datepicker-full.js',
),
];
}
}
28 changes: 28 additions & 0 deletions src/Npm/Dev/DatePickerBootstrap5Asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Npm\Dev;

use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

final class DatePickerBootstrap5Asset extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
public string|null $sourcePath = '@npm/vanillajs-datepicker';
public array $css = ['dist/css/datepicker-bs5.css'];
public array $depends = [DatePickerAsset::class];

public function __construct()
{
$pathMatcher = new PathMatcher();

$this->publishOptions = [
'filter' => $pathMatcher->only(
'**/dist/css/datepicker-bs5.css',
),
];
}
}
28 changes: 28 additions & 0 deletions src/Npm/Dev/DatePickerBulmaAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Npm\Dev;

use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

final class DatePickerBulmaAsset extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
public string|null $sourcePath = '@npm/vanillajs-datepicker';
public array $css = ['dist/css/datepicker-bulma.css'];
public array $depends = [DatePickerAsset::class];

public function __construct()
{
$pathMatcher = new PathMatcher();

$this->publishOptions = [
'filter' => $pathMatcher->only(
'**/dist/css/datepicker-bulma.css',
),
];
}
}
28 changes: 28 additions & 0 deletions src/Npm/Dev/DatePickerFoundationAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Yii\DatePicker\Asset\Npm\Dev;

use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

final class DatePickerFoundationAsset extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
public string|null $sourcePath = '@npm/vanillajs-datepicker';
public array $css = ['dist/css/datepicker-foundation.css'];
public array $depends = [DatePickerAsset::class];

public function __construct()
{
$pathMatcher = new PathMatcher();

$this->publishOptions = [
'filter' => $pathMatcher->only(
'**/dist/css/datepicker-foundation.css',
),
];
}
}

0 comments on commit 7b38522

Please sign in to comment.