|
1 | 1 | """Lucide Icon component.""" |
2 | 2 |
|
3 | 3 | from reflex.components.component import Component |
4 | | -from reflex.utils import format |
| 4 | +from reflex.utils import console, format |
5 | 5 | from reflex.utils.imports import ImportVar |
6 | 6 | from reflex.vars.base import LiteralVar, Var |
7 | 7 | from reflex.vars.sequence import LiteralStringVar, StringVar |
@@ -33,7 +33,6 @@ def create(cls, *children, **props) -> Component: |
33 | 33 |
|
34 | 34 | Raises: |
35 | 35 | AttributeError: The errors tied to bad usage of the Icon component. |
36 | | - ValueError: If the icon tag is invalid. |
37 | 36 | TypeError: If the icon name is not a string. |
38 | 37 |
|
39 | 38 | Returns: |
@@ -73,15 +72,18 @@ def create(cls, *children, **props) -> Component: |
73 | 72 | if isinstance(tag, str): |
74 | 73 | icons_sorted = sorted( |
75 | 74 | LUCIDE_ICON_LIST, |
76 | | - key=lambda s: format.length_of_largest_common_substring(tag, s), |
| 75 | + key=lambda s, tag=tag: format.length_of_largest_common_substring( |
| 76 | + tag, s |
| 77 | + ), |
77 | 78 | reverse=True, |
78 | 79 | ) |
79 | 80 | else: |
80 | 81 | icons_sorted = LUCIDE_ICON_LIST |
81 | | - raise ValueError( |
82 | | - f"Invalid icon tag: {tag}. Please use one of the following: {', '.join(icons_sorted[0:25])}, ..." |
83 | | - "\nSee full list at https://reflex.dev/docs/library/data-display/icon/#icons-list." |
| 82 | + console.warn( |
| 83 | + f"Invalid icon tag: {tag}. Please use one of the following: {', '.join(icons_sorted[0:10])}, ..." |
| 84 | + "\nSee full list at https://reflex.dev/docs/library/data-display/icon/#icons-list. Using 'circle-help' icon instead." |
84 | 85 | ) |
| 86 | + tag = "circle-help" |
85 | 87 |
|
86 | 88 | if tag in LUCIDE_ICON_MAPPING_OVERRIDE: |
87 | 89 | props["tag"] = LUCIDE_ICON_MAPPING_OVERRIDE[tag] |
|
0 commit comments