-
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.
- Loading branch information
Showing
8 changed files
with
90 additions
and
71 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% set value = { | ||
label: option.label, | ||
color: option.color, | ||
} %} | ||
{% if ';' in value.color %} | ||
{% set colours = value.color | split(';') %} | ||
{% else %} | ||
{% set colours = value.color | split(',') %} | ||
{% endif %} | ||
|
||
{# Set the default value #} | ||
{% if option.default %} | ||
{% set defaultValue = value|json_encode %} | ||
{% 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 %} | ||
background: {{ value.color|parseRefs|raw }}; | ||
{% default %} | ||
{% set percentage = 100 / colours | length %} | ||
background: 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
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
@Rias500 The reasoning behind my less aesthetically pleasing camelCase naming here was due to the
data-
attributes Craft adds when hiding and showing those color previews dynamically in the settings.It doesn't like spaces. I couldn't figure out a way around it, and I noticed every key in config files are either camelCased or underscored. If there's a way to allow spaces, I'm totally down for it, but if not, we may want to change this example name.