1
0
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:
David Wheatley
2022-07-14 13:04:38 +01:00
committed by GitHub
parent 819602520a
commit bf6f63cfe1
4 changed files with 83 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
.dummy_var_test {
--x: @doesnt-exist;
}

View File

@@ -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);
}
}