Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ’„ Replace Laravel Mix with Bud #59

Merged
merged 14 commits into from
Jun 6, 2024
Merged
4 changes: 1 addition & 3 deletions assets/css/field.scss β†’ assets/field.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
}

svg {
position: absolute;
top: 2px;
left: 2px;
@apply absolute top-[2px] left-[2px];
}
}
}
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions bud.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Bud } from '@roots/bud'

export default async (bud: Bud) => {
bud
.setPath('@src', 'assets')
.setPath('@dist', 'public')
.entry(['field.js', 'field.css'])
.hash()
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"php": ">=7.2"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.10"
},
"autoload": {
"psr-4": {
Expand Down
58 changes: 41 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
"name": "acf-editor-palette",
"private": true,
"scripts": {
"build": "npx mix",
"build:production": "npx mix --production",
"start": "npx mix watch"
},
"devDependencies": {
"autoprefixer": "^10.3.3",
"laravel-mix": "^6.0.28",
"postcss": "^8.3.6",
"sass": "^1.38.2",
"sass-loader": "^12.1.0",
"tailwindcss": "^2.2.9"
"build": "bud build"
},
"dependencies": {
"tinycolor2": "^1.4.2"
},
"devDependencies": {
"@roots/bud": "^6.21.0",
"@roots/bud-postcss": "^6.21.0",
"@roots/bud-tailwindcss": "^6.21.0",
"tailwindcss": "^3.4.4"
}
}
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Advanced Custom Fields: Editor Palette Field
* Plugin URI: https://github.com/log1x/acf-editor-palette
* Description: A Gutenberg-like editor palette color picker field for Advanced Custom Fields.
* Version: 1.1.7
* Version: 1.1.8
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
*/
Expand All @@ -13,7 +13,7 @@

add_filter('after_setup_theme', new class
{
/**
/**
* The field label.
*
* @var string
Expand Down
1 change: 0 additions & 1 deletion public/css/field.css

This file was deleted.

1 change: 1 addition & 0 deletions public/css/field.d1c65e.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions public/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"field": {
"js": [
"js/runtime.b89547.js",
"js/field.563bb8.js"
],
"css": [
"css/field.d1c65e.css"
]
}
}
1 change: 1 addition & 0 deletions public/js/field.563bb8.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion public/js/field.js

This file was deleted.

1 change: 1 addition & 0 deletions public/js/runtime.b89547.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"field.css": "css/field.d1c65e.css",
"field.js": "js/field.563bb8.js",
"runtime.js": "js/runtime.b89547.js",
"entrypoints.json": "entrypoints.json"
}
4 changes: 0 additions & 4 deletions public/mix-manifest.json

This file was deleted.

52 changes: 43 additions & 9 deletions src/Concerns/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,53 @@
trait Asset
{
/**
* Resolve an asset URI from Laravel Mix's manifest.
*
* @param string $asset
* @return string
* The manifest.
*/
public function asset($asset = null)
public array $manifest = [];

/**
* Retrieve the URI of an asset.
*/
public function asset(?string $asset = null): string
{
$asset = $this->manifest($asset);

return $this->uri . $asset;
}

/**
* Retrieve the content of an asset.
*/
public function inlineAsset(string $asset): ?string
{
if (! file_exists($manifest = $this->path . 'mix-manifest.json')) {
return $this->uri . $asset;
$path = $this->path . $this->manifest($asset);

if (! file_exists($path)) {
return null;
}

return file_get_contents($path);
}

/**
* Retrieve the manifest.
*/
public function manifest(?string $asset = null): array|string
{
if ($this->manifest) {
return $asset
? $this->manifest[$asset]
: $this->manifest;
}

if (! file_exists($manifest = $this->path . 'manifest.json')) {
return [];
}

$manifest = json_decode(file_get_contents($manifest), true);
$this->manifest = json_decode(file_get_contents($manifest), true);

return $this->uri . ($manifest[$asset] ?? $asset);
return $asset
? $this->manifest[$asset]
: $this->manifest;
}
}
6 changes: 3 additions & 3 deletions src/Concerns/Palette.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait Palette
/**
* Retrieve the editor color palette.
*
* @param string $color
* @param string $color
* @return string[]
*/
public function palette($color = null)
Expand Down Expand Up @@ -40,11 +40,11 @@ public function palette($color = null)
$value['slug'] => array_merge($value, [
'text' => sprintf('has-text-color has-%s-color', $value['slug']),
'background' => sprintf('has-background has-%s-background-color', $value['slug']),
])
]),
]);
}

return ! empty($color) ? (
return ! empty($color) && is_string($color) ? (
$colors[$color] ?? null
) : $colors;
}
Expand Down
Loading
Loading