Skip to content

Commit 2a3af4f

Browse files
committed
add compiler
1 parent 9196b90 commit 2a3af4f

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Radial
22

3-
Beautiful donut and pie charts for [Flux UI](https://fluxui.dev). Drop-in components with hover effects, legends, and dark mode support.
3+
Radial is a companion for [Flux UI](https://fluxui.dev), adding donut and pie charts styled to match Flux’s look and feel. Simple to use, with hover effects, legends, and dark mode support.
44

55
| Light | Dark |
66
|-------|------|

resources/views/radial/donut/index.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
},
101101
102102
handleHover(event, index) {
103-
console.log('handleHover called', { isStatic: this.isStatic, index });
104103
if (this.isStatic) return;
105104
106105
this.hovered = index;

resources/views/radial/pie/index.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
segments: @js($segments),
8080
8181
handleHover(event, index) {
82-
console.log('pie handleHover called', { isStatic: this.isStatic, index });
8382
if (this.isStatic) return;
8483
8584
this.hovered = index;

src/RadialServiceProvider.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class RadialServiceProvider extends ServiceProvider
1010
public function boot(): void
1111
{
1212
$this->registerBladeComponents();
13+
$this->registerTagPrecompiler();
1314
}
1415

1516
protected function registerBladeComponents(): void
@@ -19,4 +20,14 @@ protected function registerBladeComponents(): void
1920
'radial'
2021
);
2122
}
23+
24+
protected function registerTagPrecompiler(): void
25+
{
26+
$compiler = new RadialTagCompiler;
27+
28+
// Run before compileComponentTags so <radial:foo> becomes <x-radial::foo> and gets compiled
29+
Blade::prepareStringsForCompilationUsing(function (string $string) use ($compiler): string {
30+
return $compiler->compile($string);
31+
});
32+
}
2233
}

src/RadialTagCompiler.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Radial;
4+
5+
/**
6+
* Precompiler that converts <radial:component> tags to <x-radial::component>
7+
* so Laravel's Blade compiler will compile them (it only compiles x- and x: tags).
8+
*/
9+
class RadialTagCompiler
10+
{
11+
public function compile(string $value): string
12+
{
13+
$value = preg_replace('/<radial:([\w\-\.]+)/', '<x-radial::$1', $value);
14+
15+
$value = preg_replace('/<\/radial:([\w\-\.]+)\s*>/', '</x-radial::$1>', $value);
16+
17+
return $value;
18+
}
19+
}

0 commit comments

Comments
 (0)