-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from percipioglobal/feature/color-config-arrays
Feature: allow custom attributes to be created in the colour-swatches.php config file
- Loading branch information
Showing
12 changed files
with
226 additions
and
58 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,20 +1,39 @@ | ||
{% set value = { | ||
label: option.label, | ||
color: option.color, | ||
} %} | ||
{% if ';' in value.color %} | ||
{% set colours = value.color | split(';') %} | ||
{% if option.color is iterable %} | ||
{# option.color is an array #} | ||
{% set value = { | ||
label: option.label, | ||
color: option.color, | ||
} %} | ||
|
||
{% set colours = option.color %} | ||
<button type="button" title="{{ option.label }}" data-value="{{ value | json_encode }}" class="option {% if (option.default and (not fieldValue is defined or (fieldValue is defined and not fieldValue.color))) or (fieldValue is defined and fieldValue.color == option.color) %} active{% endif %}" style=" | ||
{% switch colours | length %} | ||
{% case 1 %} | ||
--color: {{ value.color[0].color|parseRefs|raw }}; | ||
{% default %} | ||
{% set percentage = 100 / colours | length %} | ||
--color: linear-gradient(to bottom right, {% for color in colours %}{{ color.color|parseRefs|raw }} {{ percentage * loop.index0 }}%, {{ color.color|parseRefs|raw }} {{ percentage * loop.index }}%{% if not loop.last %},{% endif %}{% endfor %}); | ||
{% endswitch %} | ||
"></button> | ||
{% else %} | ||
{% set colours = value.color | split(',') %} | ||
{# option.color is a string #} | ||
{% set value = { | ||
label: option.label, | ||
color: option.color, | ||
} %} | ||
{% if ';' in value.color %} | ||
{% set colours = value.color | split(';') %} | ||
{% else %} | ||
{% set colours = value.color | split(',') %} | ||
{% endif %} | ||
<button type="button" title="{{ option.label }}" data-value="{{ value | json_encode }}" class="option {% if (option.default and (not fieldValue is defined or (fieldValue is defined and not fieldValue.color))) or (fieldValue is defined and fieldValue.color == option.color) %} active{% endif %}" style=" | ||
{% switch colours | length %} | ||
{% case 1 %} | ||
--color: {{ value.color|parseRefs|raw }}; | ||
{% default %} | ||
{% set percentage = 100 / colours | length %} | ||
--color: linear-gradient(to bottom right, {% for colour in colours %}{{ colour|parseRefs|raw }} {{ percentage * loop.index0 }}%, {{ colour|parseRefs|raw }} {{ percentage * loop.index }}%{% if not loop.last %},{% endif %}{% endfor %}); | ||
{% endswitch %} | ||
"></button> | ||
{% endif %} | ||
|
||
<button type="button" title="{{ option.label }}" data-value="{{ value | json_encode }}" class="option {% if (option.default and (not fieldValue is defined or (fieldValue is defined and not fieldValue.color))) or (fieldValue is defined and fieldValue.color == option.color) %} active{% endif %}" | ||
style=" | ||
{% switch colours | length %} | ||
{% case 1 %} | ||
--color: {{ value.color|parseRefs|raw }}; | ||
{% default %} | ||
{% set percentage = 100 / colours | length %} | ||
--color: linear-gradient(to bottom right, {% for colour in colours %}{{ colour|parseRefs|raw }} {{ percentage * loop.index0 }}%, {{ colour|parseRefs|raw }} {{ percentage * loop.index }}%{% if not loop.last %},{% endif %}{% endfor %}); | ||
{% endswitch %} | ||
"></button> |
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