Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add a placeholder_color param to Figure #104

Merged
merged 6 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added
- **Figure**
- Add the `placeholder_color` param to Figure ([51f625d](https://github.com/studiometa/ui/commit/51f625d), [#100](https://github.com/studiometa/ui/issues/100))
titouanmathis marked this conversation as resolved.
Show resolved Hide resolved

## v0.2.23 (2022-11-17)

### Added
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/atoms/Figure/Figure.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Custom attributes for the image element.
* @param array $caption_attr
* Custom attributes for the caption element.
* @param string $placeholder_color
antoine4livre marked this conversation as resolved.
Show resolved Hide resolved
*
* @block $caption
* Use this block to customize the image's caption.
Expand All @@ -44,12 +45,13 @@
{% set width = width|default(100) %}
{% set lazy = lazy ?? true %}

{% set placeholder_color = placeholder_color|default('#eee') %}
{%- set placeholder_markup -%}
<svg xmlns="http://www.w3.org/2000/svg"
viewbox="0 0 {{ width }} {{ height }}"
width="{{ width }}"
height="{{ height }}">
<rect x="0" y="0" width="{{ width }}" height="{{ height }}" fill="#eee" />
<rect x="0" y="0" width="{{ width }}" height="{{ height }}" fill="{{ placeholder_color }}" />
</svg>
{%- endset -%}
{% set generic_placeholder = 'data:image/svg+xml,%s'|format(placeholder_markup|url_encode) %}
Expand Down