Last active
July 12, 2017 08:56
-
-
Save bastianallgeier/a8ff0b6cee56b36d3aa2b616e8ad981b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'props' => [ | |
'title' => [ | |
'type' => 'field', | |
'required' => true, | |
], | |
'links' => [ | |
'type' => 'structure', | |
'required' => true | |
], | |
'modifier' => [ | |
'type' => 'string', | |
'default' => 'Example--dark', | |
'validator => function($value) { | |
return v::in($value, ['Example--dark', 'Example--light']); | |
} | |
] | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="ExamplePattern <?= $modifier ?>"> | |
<h2><?= $title->html() ?></h2> | |
<ul> | |
<?php foreach ($links as $link) ?> | |
<li><a href="<?= $link->url() ?>"><?= $link->text() ?></a></li> | |
<?php endforeach ?> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ExamplePatternTest extends TestCase | |
{ | |
protected $fixtures = __DIR__ . '/_fixtures'; | |
public function testExample() | |
{ | |
$page = page('some-page/from/fixtures'); | |
$dom = $this->patternDom('example-pattern', [ | |
'title' => $page->title(), | |
'links' => $page->links() | |
'modifier' => 'Example--light', | |
]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php snippet('header') ?> | |
<?php pattern('example-pattern', [ | |
'title' => $page->title(), | |
'links' => $page->links() | |
'modifier' => 'Example--light', | |
]) ?> | |
<?php snippet('footer') ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment