Skip to content
Snippets Groups Projects

SVG generation #3424744

Closed Ivan Berdinsky requested to merge issue/navigation-3424744:3424744-svg-generate into 1.x
1 unresolved thread

Closes #3424744

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
7 7 extra_classes,
8 8 ]
9 9 %}
10 <{{html_tag|default('button')}}{{ attributes.addClass(classes) }}>
10
11 {% if text %}
12 {# Trim the text and get the first two characters #}
13 {%
14 set short_text = text|render|trim|slice(0, 2)|join('')
15 %}
16 {% endif %}
17
18 <{{html_tag|default('button')}}{{ attributes.addClass(classes).setAttribute('data-short', short_text) }}>
19 <style>
20 [data-short="{{ short_text }}"] {
21 --default-icon: url("data:image/svg+xml, %3Csvg width='20' height='20' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' font-size='60' font-weight='700' font-family='arial'%3E ~ {{ short_text }} ~ %3C/text%3E%3C/svg%3E");
  • Thanks for this @finnsky, this is a really clever solution!

    In addition to the inline comment, I have two pieces of feedback, one minor and one a larger question.

    The larger question is that inline <style> tags will break CSP. Is that okay in Drupal core @ckrina?

    The smaller issue is that, according to the mocks, the two letters should be aligned to the baseline, instead of the top.

    Mock

    Screenshot_2024-03-20_at_4.57.37_PM

    MR

    Screenshot_2024-03-20_at_4.47.47_PM

  • this css <style> can be generated on backend i guess. and never affects anything. it has attribute selector

    Only one problem seems now. that different font.

    Edited by Ivan Berdinsky
  • closed

  • Please register or sign in to reply
    Loading