diff --git a/CHANGELOG.md b/CHANGELOG.md index 056e1022..1b09be91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ([#104](https://github.com/studiometa/ui/pull/104), [#100](https://github.com/studiometa/ui/issues/100)) + ## v0.2.23 (2022-11-17) ### Added diff --git a/packages/docs/components/atoms/Figure/twig-api.md b/packages/docs/components/atoms/Figure/twig-api.md index 11332032..9724c9cb 100644 --- a/packages/docs/components/atoms/Figure/twig-api.md +++ b/packages/docs/components/atoms/Figure/twig-api.md @@ -76,6 +76,30 @@ Use absolute position on the image holder instead of relative. Wether to enable the display of the figure inline or not. When `inline`, the root element will have a max-width set corresponding to the `width` given. Use with caution. +### `placeholder` + +- Type: `string` + +Use a custom placeholder instead of the generic placeholder: +```twig +{%- set placeholder_markup -%} + + + +{%- endset -%} +{% set generic_placeholder = 'data:image/svg+xml,%s'|format(placeholder_markup|url_encode) %} +``` + +### `placeholder_color` + +- Type: `string` +- Default: `"#eee"` + +Define the color of the generic placeholder. + ### `attr` - Type: `array` @@ -100,7 +124,6 @@ Custom attributes for the image element. Custom attributes for the caption element. - ## Blocks ### `caption` diff --git a/packages/ui/atoms/Figure/Figure.twig b/packages/ui/atoms/Figure/Figure.twig index c1bdf912..b6723538 100644 --- a/packages/ui/atoms/Figure/Figure.twig +++ b/packages/ui/atoms/Figure/Figure.twig @@ -18,6 +18,10 @@ * @param boolean $inline * Wether to enable the display of the figure inline or not. When `inline`, the root element * will have a max-width set corresponding to the `width` given. Use with caution. + * @param string $placeholder + * Use a custom placeholder. + * @param string $placeholder_color + * Set an hexadecimal custom color for the generic placeholder. * @param array $attr * Custom attributes for the root element. * @param array $inner_attr @@ -44,12 +48,13 @@ {% set width = width|default(100) %} {% set lazy = lazy ?? true %} +{% set placeholder_color = placeholder_color|default('#eee') %} {%- set placeholder_markup -%} - + {%- endset -%} {% set generic_placeholder = 'data:image/svg+xml,%s'|format(placeholder_markup|url_encode) %}