PHP code example of mariohamann / statamic-figma-assets
1. Go to this page and download the library: Download mariohamann/statamic-figma-assets library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mariohamann / statamic-figma-assets example snippets
return [
[
'title' => 'SVG Icons',
'token' => env('FIGMA_TOKEN'),
'figma_api_base_url' => env('FIGMA_API_BASE_URL', 'https://api.figma.com/v1'),
'file_id' => env('FIGMA_FILE_ID'),
'page_title' => 'Marketing Assets',
'frame_title' => 'Logos',
'assets_container' => 'assets',
'format' => 'svg',
'scale' => 1,
'export_children' => true,
'optimize_variant_names' => true,
'assets_transformer' => null,
'figma_batch_size' => 100,
'download_batch_size' => 15,
]
// ... more configurations
]
return [
[
// ... other configuration options
'assets_transformer' => App\Figma\FilterPrivateAssets::class,
],
];
namespace App\Figma;
use MarioHamann\StatamicFigmaAssets\Contracts\AssetsTransformer;
class FilterPrivateAssets implements AssetsTransformer
{
public function transform(array $assets): array
{
return array_values(array_filter(
$assets,
fn (array $asset) => ! preg_match('/(^_|\/_)/', $asset['name'])
));
}
}
return [
[
// ... other configuration options
'before_upload' => App\Figma\OptimizeSvg::class,
],
];
namespace App\Figma;
use MarioHamann\StatamicFigmaAssets\Contracts\BeforeUploadProcessor;
class OptimizeSvg implements BeforeUploadProcessor
{
public function process(string $path): string
{
exec('svgo ' . escapeshellarg($path));
return $path;
}
}
bash
php artisan vendor:publish --tag=statamic-figma-assets --force
bash
php artisan vendor:publish --provider="MarioHamann\StatamicFigmaAssets\ServiceProvider" --tag="config"