Skip to content

[Icons] Cache icon set list #1601

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

Closed

Conversation

smnandre
Copy link
Member

@smnandre smnandre commented Mar 9, 2024

We should keep the list of iconset locally .. it will help a lot to limit the number of http request / checks / etc

(pr used as example, this would need a bit more test ^^)

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Mar 9, 2024
if (200 !== $response->getStatusCode()) {
throw new \RuntimeException('Could not fetch icon collections from iconify.design.');
}
if (null === $collections = $response->toArray()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toArray never returns null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg what did wrote ?

(the idea behind this PR was to prevent some unhandled 404 (when the icon set does not exists).. but with your refacto this is probably no more usefull)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can close it now i think ?

@kbond
Copy link
Member

kbond commented Mar 10, 2024

Closing in favor of #1594

@kbond kbond closed this Mar 10, 2024
kbond added a commit that referenced this pull request Mar 10, 2024
…kbond)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[Icons] Improve cache warmup by looking at every string

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Issues        | n/a
| License       | MIT

Improve working with dynamic icon names (inspired by https://v2.tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html)

```twig
{# This will be cached #}
{{ ux_icon('flag-fr') }}

{# This will NOT be cached #}
{{ ux_icon('flag-' ~ locale) }}

{% set flags = {fr: 'flag-fr', de: 'flag-de'} %} {# both "flag-fr" and "flag-de" will be cached #}
{{ ux_icon(flags[locale]) }}
```

Closes #1601

Commits
-------

c3f7627 [Icons] Improve cache warmup by looking at every string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants