-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace markhuot\keystone\actions; | ||
|
||
class MapExpandedAttributeValue | ||
{ | ||
public function handle(?array $value, string $property, ?string $expandedProperty=null) | ||
{ | ||
if ($expandedProperty === null) { | ||
$expandedProperty = "{$property}-&"; | ||
} | ||
|
||
if ($value['useExpanded'] ?? false) { | ||
return collect($value['expanded']) | ||
->mapWithKeys(fn ($value, $key) => [str_replace('&', $key, $expandedProperty) => $value]) | ||
->filter(); | ||
} | ||
else { | ||
return collect([$property => $value['shorthand']]) | ||
->filter(); | ||
} | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
{% from '_includes/forms' import field as renderField, textField %} | ||
{{ textField({ | ||
'label': 'Border Radius', | ||
'name': name, | ||
'value': value, | ||
}) }} | ||
{% from '_includes/forms' import textField, colorField, selectField %} | ||
|
||
<div class="k-space-y-6"> | ||
{{ textField({ | ||
'label': 'Border Radius', | ||
'name': name ~ '[radius]', | ||
'value': value.radius|default, | ||
}) }} | ||
|
||
<div class="k-grid k-grid-cols-3 k-gap-6"> | ||
{% include "keystone/styles/margin" with { | ||
label: 'Width', | ||
name: name ~ '[width]', | ||
value: value.width|default | ||
} %} | ||
|
||
{{ selectField({ | ||
'label': 'Style', | ||
'name': name ~ '[style]', | ||
'options': [ | ||
{label: 'Solid', value: 'solid'}, | ||
{label: 'Dashed', value: 'dashed'}, | ||
{label: 'Dotted', value: 'dotted'}, | ||
{label: 'Double', value: 'double'}, | ||
{label: 'Hidden', value: 'hidden'}, | ||
{label: 'None', value: 'none'}, | ||
], | ||
value: value.style|default | ||
}) }} | ||
|
||
{{ colorField({ | ||
label: 'Color', | ||
name: name ~ '[color]', | ||
value: value.color|default, | ||
}) }} | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use markhuot\keystone\attributes\Border; | ||
|
||
it('renders borders', function () { | ||
$border = new Border(); | ||
|
||
expect($border->getCssRules())->not->toHaveKey('border'); | ||
}); | ||
|
||
it('renders border width shorthand', function () { | ||
$border = new Border(['width' => ['shorthand' => '10px']]); | ||
|
||
expect($border->getCssRules())->get('border-width')->toBe('10px'); | ||
}); | ||
|
||
it('renders expanded borders', function () { | ||
$border = new Border(['width' => ['useExpanded' => '1', 'expanded' => ['top' => '10px', 'left' => '']]]); | ||
|
||
expect($border->getCssRules()) | ||
->get('border-top-width')->toBe('10px') | ||
->has('border-right-width')->toBeFalse() | ||
->has('border-bottom-width')->toBeFalse() | ||
->has('border-left-width')->toBeFalse(); | ||
}); |