Skip to content

Commit

Permalink
BREAKING CHANGE(web-twig): Remove class prop from all components #D…
Browse files Browse the repository at this point in the history
…S-678

 ## Migration Guide

Rename `class` prop to `UNSAFE_className` on all components.

- `<Alert class="d-none" …>` → `<Alert UNSAFE_className="d-none" …>`

Please refer back to these instructions or reach out to our team
if you encounter any issues during migration.
  • Loading branch information
crishpeen authored and literat committed Jul 21, 2023
1 parent bdc9685 commit 11c6ee6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/web-twig/src/Twig/PropsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ public function useStyleProps(array $props): array
{
$styleProps = [];
if (array_key_exists('class', $props)) {
trigger_error('The "class" property will be removed in the next major version. Use "UNSAFE_className" instead.', E_USER_DEPRECATED);
trigger_error('The "class" property is not allowed. If you really need to add a CSS class, use "UNSAFE_className" instead. Learn more at https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web-twig#escape-hatches', E_USER_WARNING);
}
$styleProps['className'] = $props['UNSAFE_className'] ?? $props['class'] ?? null;
if (array_key_exists('style', $props)) {
trigger_error('The "style" property is not allowed. If you really need to modify the CSS style, use "UNSAFE_style" instead. Learn more at https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web-twig#escape-hatches', E_USER_WARNING);
}
$styleProps['className'] = $props['UNSAFE_className'] ?? null;
$styleProps['style'] = $props['UNSAFE_style'] ?? null;

return $styleProps;
Expand Down

0 comments on commit 11c6ee6

Please sign in to comment.