mirror of
https://github.com/flarum/core.git
synced 2025-07-31 13:40:20 +02:00
feat: extender to add custom less variables (#3530)
This commit is contained in:
3
framework/core/tests/fixtures/less/custom_variable.less
vendored
Normal file
3
framework/core/tests/fixtures/less/custom_variable.less
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.dummy_var_test {
|
||||
--x: @doesnt-exist;
|
||||
}
|
@@ -132,4 +132,28 @@ class ThemeTest extends TestCase
|
||||
$this->assertStringContainsString('.dummy_func_test{color:green}', $contents);
|
||||
$this->assertStringContainsString('.dummy_func_test2{--x:1000;--y:false}', $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function theme_extender_can_add_custom_variable()
|
||||
{
|
||||
$this->extend(
|
||||
(new Extend\Frontend('forum'))
|
||||
->css(__DIR__.'/../../fixtures/less/custom_variable.less'),
|
||||
(new Extend\Theme)
|
||||
->addCustomLessVariable('doesnt-exist', function () {
|
||||
return 'it does';
|
||||
})
|
||||
);
|
||||
|
||||
$response = $this->send($this->request('GET', '/'));
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$cssFilePath = $this->app()->getContainer()->make('filesystem')->disk('flarum-assets')->path('forum.css');
|
||||
$contents = file_get_contents($cssFilePath);
|
||||
|
||||
$this->assertStringContainsString('.dummy_var_test{--x:it does}', $contents);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user