Skip to content

Commit

Permalink
Initital commit. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 19, 2024
1 parent 3cbdc7b commit 62aa510
Show file tree
Hide file tree
Showing 50 changed files with 1,459 additions and 81 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
extensions: runkit7
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
with:
extensions: runkit7
os: >-
['ubuntu-latest']
php: >-
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change Log
==========

## 0.1.0 January 19, 2023

- Initial release.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 yii-tools
Copyright (c) 2023 yii3-extensions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
76 changes: 50 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
<p align="center">
<a href="https://github.com/yii-tools/template" target="_blank">
<a href="https://github.com/yii3-extensions/asset-fontawesome-free" target="_blank">
<img src="https://avatars.githubusercontent.com/u/121752654?s=200&v=4" height="100px">
</a>
<h1 align="center">Template.</h1>
<a href="https://fontawesome.com/start" target="_blank" rel="external">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5f/Font_Awesome_logomark_blue.svg/512px-Font_Awesome_logomark_blue.svg.png?20220809042108" height="100px">
</a>
<h1 align="center">Assets for FontAwesome Free for YiiFramework v.3.0.</h1>
<br>
</p>

<p align="center">
<a href="https://github.com/yii-tools/template/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii-tools/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
<a href="https://github.com/yii3-extensions/asset-fontawesome-free/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii3-extensions/asset-fontawesome-free/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii-tools/template" target="_blank">
<img src="https://codecov.io/gh/yii-tools/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
<a href="https://codecov.io/gh/yii3-extensions/asset-fontawesome-free" target="_blank">
<img src="https://codecov.io/gh/yii3-extensions/asset-fontawesome-free/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii-tools/template/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fasset-bootstrap5%2Fmain" alt="Infection">
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii3-extensions/asset-fontawesome-free/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii3-extensions%2Fasset-fontawesome-free%2Fmain" alt="Infection">
</a>
<a href="https://github.com/yii-tools/template/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii-tools/template/actions/workflows/static.yml/badge.svg" alt="Psalm">
<a href="https://github.com/yii3-extensions/asset-fontawesome-free/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii3-extensions/asset-fontawesome-free/actions/workflows/static.yml/badge.svg" alt="Psalm">
</a>
<a href="https://shepherd.dev/github/yii-tools/template" target="_blank">
<img src="https://shepherd.dev/github/yii-tools/template/coverage.svg" alt="Psalm Coverage">
<a href="https://shepherd.dev/github/yii3-extensions/asset-fontawesome-free" target="_blank">
<img src="https://shepherd.dev/github/yii3-extensions/asset-fontawesome-free/coverage.svg" alt="Psalm Coverage">
</a>
<a href="https://github.styleci.io/repos/494495136?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/494495136/shield?branch=main" alt="Style ci">
<a href="https://github.styleci.io/repos/745519575?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/745519575/shield?branch=main" alt="Style ci">
</a>
</p>

Expand All @@ -34,34 +37,55 @@ The preferred way to install this extension is through [composer](https://getcom
Either run

```shell
composer require --prefer-dist package
composer require --prefer-dist yii3-extensions/asset-fontawesome-free
```

or add

```json
"package": "version"
"yii3-extensions/asset-fontawesome-free": "^0.1"
```

to the require-dev section of your `composer.json` file.
## Directory structure

The module directory structure is as follows:

```text
root
├── src Assets for FontAwesome Free.
│ └── Css Directory for Css Assets.
│ └── FontAwesome.php FontAwesome Free All CSS Asset.
│ └── FontAwesomeCdn.php FontAwesome Free All CSS CDN Asset.
│ └── FontAwesomeBrand.php FontAwesome Free Brand CSS Asset.
│ └── FontAwesomeBrandCdn.php FontAwesome Free Brand CSS CDN Asset.
│ └── FontAwesomeRegular.php FontAwesome Free Regular CSS Asset.
│ └── FontAwesomeRegularCdn.php FontAwesome Free Regular CSS CDN Asset.
│ └── FontAwesomeSolid.php FontAwesome Free Solid CSS Asset.
│ └── FontAwesomeSolidCdn.php FontAwesome Free Solid CSS CDN Asset.
│ └── Js Directory for Brand Assets.
│ └── FontAwesome.php FontAwesome Free All JS Asset.
│ └── FontAwesomeCdn.php FontAwesome Free All JS CDN Asset.
│ └── FontAwesomeBrand.php FontAwesome Free Brand JS Asset.
│ └── FontAwesomeBrandCdn.php FontAwesome Free Brand JS CDN Asset.
│ └── FontAwesomeRegular.php FontAwesome Free Regular JS Asset.
│ └── FontAwesomeRegularCdn.php FontAwesome Free Regular JS CDN Asset.
│ └── FontAwesomeSolid.php FontAwesome Free Solid JS Asset.
│ └── FontAwesomeSolidCdn.php FontAwesome Free Solid JS CDN Asset.
├── tests Tests for Assets for FontAwesome Free.
```

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.

## Support versions

[![PHP81](https://img.shields.io/badge/PHP-%3E%3D8.1-787CB5)](https://www.php.net/releases/8.1/en.php)
[![Yii30](https://img.shields.io/badge/Yii%20version-3.0-blue)](https://yiiframework.com)

## Testing

[Check the documentation testing](/docs/testing.md) to learn about testing.

## Our social networks
## License

[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/Terabytesoftw)
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## License
## Our social networks

The MIT License. Please see [License File](LICENSE.md) for more information.
[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/Terabytesoftw)
2 changes: 0 additions & 2 deletions changelog.md

This file was deleted.

5 changes: 5 additions & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"symbol-whitelist": [
"YII_ENV"
]
}
62 changes: 43 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,68 @@
{
"name": "yii-tools/template",
"name": "yii3-extensions/asset-fontawesome-free",
"type": "library",
"description": "template",
"description": "Asset for FontAwesome Free for YiiFramework v.3.0.",
"keywords": [
"template"
"yii3",
"yii3-extensions",
"asset",
"fontawesome-free"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.1"
"php": "^8.1",
"npm-asset/fortawesome--fontawesome-free": "^6.5",
"oomphinc/composer-installers-extender": "^2.0",
"yiisoft/assets": "^4.0",
"yiisoft/files": "^2.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.7",
"php-forge/support": "^0.1",
"phpunit/phpunit": "^10.5",
"roave/infection-static-analysis-plugin": "^1.34",
"symplify/easy-coding-standard": "^12.1",
"vimeo/psalm": "^5.19"
"vimeo/psalm": "^5.19",
"yiisoft/aliases":"^3.0"
},
"autoload": {
"psr-4": {
"Template\\": "src"
}
"psr-4": {"Yii\\Asset\\": "src"}
},
"autoload-dev": {
"psr-4": {
"Template\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
}
"psr-4": {"Yii\\Asset\\Tests\\": "tests"}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true
"infection/extension-installer": true,
"composer/installers": true,
"oomphinc/composer-installers-extender": true
}
},
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"params": "common/param/*.php"
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}": [
"type:bower-asset",
"type:npm-asset"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"scripts": {
"check-dependencies": "composer-require-checker",
"easy-coding-standard": "ecs check",
Expand Down
60 changes: 60 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## 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\Asset\Css\FontAwesome;

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

// Register the asset bundle with a asset manager component.
$assetManager->register(FontAwesome::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\Asset\Css\FontAwesomeCdn;

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

## Using npm packages

You can install [npm](https://www.npmjs.com/) packages [fxpio/foxy](https://github.com/fxpio/foxy), and they will be
available in the `node_modules` directory.
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
Expand All @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Template">
<testsuite name="Asset-Fontawesome-Free">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<projectFiles>
<directory name="src" />
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<UndefinedConstant errorLevel="suppress" />
</issueHandlers>
</psalm>
18 changes: 18 additions & 0 deletions src/Css/Depend/DependCdn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Yii\Asset\Css\Depend;

use Yiisoft\Assets\AssetBundle;

final class DependCdn extends AssetBundle
{
public bool $cdn = true;
public array $css = ['https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css'];
public array $cssOptions = [
'integrity' => 'sha512-d0olNN35C6VLiulAobxYHZiXJmq+vl+BGIgAxQtD5+kqudro/xNMvv2yIHAciGHpExsIbKX3iLg+0B6d0k4+ZA==',
'crossorigin' => 'anonymous',
'referrerpolicy' => 'no-referrer',
];
}
29 changes: 29 additions & 0 deletions src/Css/FontAwesome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Yii\Asset\Css;

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

final class FontAwesome extends AssetBundle
{
public string|null $basePath = '@assets';
public string|null $baseUrl = '@assetsUrl';
public string|null $sourcePath = '@fontawesome-free/css';

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

$environment = defined('YII_ENV') ? YII_ENV : 'prod';
$cssFiles = $environment === 'prod' ? 'all.min.css' : 'all.css';
$fontAwesomeFile = $environment === 'prod' ? 'fontawesome.min.css' : 'fontawesome.css';

$this->css = [$cssFiles];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/css/{$cssFiles}", "**/{$fontAwesomeFile}", '**/webfonts/*'),
];
}
}

0 comments on commit 62aa510

Please sign in to comment.