[1.0.0-beta1] Remove IconDefinition::DEFAULT_TEMPLATE

Created on 13 September 2024, 4 months ago
Updated 18 September 2024, 4 months ago

Problem/Motivation

class IconDefinition implements IconDefinitionInterface {

  private const DEFAULT_TEMPLATE = '<img class="icon icon-{{ icon_id|clean_class }}" src="{{ source }}" title="{{ title|default(name) }}" alt="{{ alt|default(name) }}" width="{{ width|default(24) }}" height="{{ height|default(24) }}">';

}

This constant is problematic:

  • it promotes title, alt, width & default but they are only icon pack related settings, we can't be renamed or removed according to the icon pack upstream documentation.
  • because 📌 [1.0.0-beta1] Clean *.ui_icons.yml Needs work was not done yet (it was planned for beta2, but I have just moved it to beta1), it gave the false illusion than most of those very specific templates can be factorized.
  • it is not compatible with extractor already planned or not, and it may confused the icon pack author which will not understand why its icon pack is not rendering correctly. Example: ✨ [1.0.0-beta2] Add font/codepoint icon extractor Needs work
  • any change in this constant in a future version of UI Icons can break all iconpack relying on the default

Proposed resolution

So:

  • remove the constant
  • make the template property mandatory in JSON schema
  • put the expected template code in iconpack, according to the upstream documentation
  • do also similar task 📌 [1.0.0-beta1] Clean *.ui_icons.yml Needs work
📌 Task
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • 🇫🇷France pdureau Paris
  • Status changed to Needs work 4 months ago
  • 🇫🇷France pdureau Paris

    We also do 📌 [1.0.0-beta1] Clean *.ui_icons.yml Needs work in this merge request.

    Nearl yfinished, we jsut need to run prettier on the heavily edited YAML

  • Assigned to mogtofu33
  • Status changed to Needs review 4 months ago
  • 🇫🇷France pdureau Paris

    I have run prettier on modified YAML instead of eslint --config=./.eslintrc.json --no-error-on-unmatched-pattern --ext .yml --resolve-plugins-relative-to ./node_modules but the pipeline is OK.

    However, one phpunit failure:

    1) Drupal\Tests\ui_icons\Kernel\Plugin\IconPackManagerKernelTest::testListIconPackOptions
    Failed asserting that two arrays are identical.
    --- Expected
    +++ Actual
    @@ @@
     Array &0 (
         'test_local_files' => 'Local files (8)'
    +    'test_no_settings' => 'No Settings (5)'
         'test_local_svg' => 'SVG manual (7)'
         'test_local_svg_sprite' => 'Small sprite (5)'
    -    'test_no_settings' => 'No Settings (5)'
     )
  • Assigned to pdureau
  • Status changed to Needs work 4 months ago
  • 🇫🇷France pdureau Paris

    Do some tweaking to have nice previews

  • Assigned to mogtofu33
  • 🇫🇷France pdureau Paris

    So,

    • we keep Pierres's 2 first commits a a startign point for siplifictaion
    • we get rid of Pierre's third commti because we have a better solution than CSS tweaking
    • we ignore settings in Drupal config schema
    • we don't promote "size" as a global variable, it stays as a icon pack specific variable
    • We introduce a new preview_template property to icon definition, to render preview with an expected size (which one? 96px? 48px ?):
      • which will be optional for renderable based on IMG or SVG HTML elements, because there will have a "default default template" with IMG and source + icon_id are enough to build it, and we can leverage WIDTH & HEIGHT HTML attributes
      • which will be expected for renderable based on CLASS or DATA- HTML attributes, because size management is very specific

    Also, let's add this pack:

    font_awesome_names:
      label: Font Awesome [Icon name]
      description: The Internet's icon library and toolkit, used by millions of designers, developers, and content creators. 
      links:
        - https://docs.fontawesome.com/web/add-icons/svg-unicodes 
      extractor: svg
      config:
        sources:
          - /libraries/fontawesome/svgs/{group}/{icon_id}.svg
      settings:
        size:
          title: "Size"
          type: "integer"
          default: 32
      template: >
        <i class="fa-solid fa-{{ icon_id }}"></i>
    
  • Issue was unassigned.
  • Status changed to Closed: outdated 4 months ago
Production build 0.71.5 2024