-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added font-awesome-based icons #554
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8765e0e
Added font-awesome-based icons matched to the best of my abilities
LucaCappelletti94 d6d9826
Updated History
LucaCappelletti94 20f08af
Resolved github actions code smells
LucaCappelletti94 67a9c36
Resolved other github action code smell
LucaCappelletti94 84799d4
Resolved reaining code smells
LucaCappelletti94 3e4011e
Fixed duplicated color
LucaCappelletti94 1dc30cb
Added missing comma
LucaCappelletti94 bda8e76
Resolve line length
LucaCappelletti94 3e48d50
Fixed code smell according to github actions
LucaCappelletti94 840c788
Trying to follow github actions
LucaCappelletti94 f5a2d31
Replaced remaning pro icons
LucaCappelletti94 c29e513
Added zero case
LucaCappelletti94 10c2df7
Fixed typo
LucaCappelletti94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# ruff: noqa: F401 | ||
from dataclasses import dataclass | ||
from datetime import date, datetime, timedelta | ||
from os.path import abspath, dirname, join | ||
from pathlib import Path | ||
|
@@ -8,6 +9,7 @@ | |
from platformdirs import user_data_dir | ||
from pyrate_limiter.sqlite_bucket import LOCK_PATH as DEFAULT_LOCK_PATH | ||
|
||
|
||
# iNaturalist URLs | ||
API_V0 = 'https://www.inaturalist.org' | ||
API_V1 = 'https://api.inaturalist.org/v1' | ||
|
@@ -86,6 +88,7 @@ | |
48222: 'Chromista', | ||
47686: 'Protozoa', | ||
} | ||
|
||
ICONIC_EMOJI = { | ||
0: '❓', | ||
1: '🐾', | ||
|
@@ -102,6 +105,60 @@ | |
48222: '🟢', | ||
47686: '🦠', | ||
} | ||
|
||
COLORS = { | ||
'blue': '#5778a4', | ||
'orange': '#e49444', | ||
'red': '#d1615d', | ||
'teal': '#85b6b2', | ||
'green': '#6a9f58', | ||
'yellow': '#e7ca60', | ||
'purple': '#a87c9f', | ||
'pink': '#f1a2a9', | ||
'brown': '#967662', | ||
'grey': '#b8b0ac', | ||
'black': '#000000', | ||
} | ||
|
||
|
||
@dataclass | ||
class FontAwesomeIcon: | ||
prefix: str | ||
name: str | ||
color: str | ||
size: int = 16 | ||
|
||
def __str__(self): | ||
return ( | ||
f'<i class="{self.prefix} {self.name}"' | ||
f'style="color: {COLORS[self.color]};' | ||
f'font-size: {self.size}px;"></i>' | ||
) | ||
|
||
def __repr__(self): | ||
return f'<FontAwesomeIcon {self.prefix} {self.name} {self.color} {self.size}>' | ||
|
||
|
||
ICONIC_FONT_AWESOME = { | ||
0: FontAwesomeIcon('fa-solid', 'fa-question-circle', 'grey'), | ||
1: FontAwesomeIcon('fa-solid', 'fa-paw', 'black'), | ||
3: FontAwesomeIcon('fa-solid', 'fa-dove', 'teal'), | ||
20978: FontAwesomeIcon('fa-solid', 'fa-frog', 'green'), | ||
26036: FontAwesomeIcon('fa-solid', 'fa-dragon', 'green'), | ||
40151: FontAwesomeIcon('fa-solid', 'fa-cat', 'orange'), | ||
47178: FontAwesomeIcon('fa-solid', 'fa-fish', 'blue'), | ||
47115: FontAwesomeIcon('fa-solid', 'fa-worm', 'pink'), | ||
47119: FontAwesomeIcon('fa-solid', 'fa-spider', 'black'), | ||
47158: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'purple'), | ||
47126: FontAwesomeIcon('fa-solid', 'fa-leaf', 'green'), | ||
47170: FontAwesomeIcon('fa-solid', 'fa-bacteria', 'brown'), # mushroom | ||
48222: FontAwesomeIcon('fa-solid', 'fa-bowling-ball', 'green'), | ||
47686: FontAwesomeIcon('fa-solid', 'fa-disease', 'green'), | ||
} | ||
|
||
assert set(ICONIC_TAXA.keys()) == set(ICONIC_EMOJI.keys()) | ||
assert set(ICONIC_TAXA.keys()) == set(ICONIC_FONT_AWESOME.keys()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove these asserts? Those should generally only be used in unit tests. |
||
|
||
ROOT_TAXON_ID = 48460 | ||
|
||
# Taxonomic ranks that can be filtered on, and numeric values for comparison | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
"""Extended list of font-awesome icons to represent taxa""" | ||
|
||
from pyinaturalist.constants import FontAwesomeIcon | ||
|
||
EXTENDED_FONT_AWESOME_ICONS = { | ||
0: FontAwesomeIcon('fa-solid', 'fa-question-circle', 'grey'), | ||
# Birds | ||
3: FontAwesomeIcon('fa-solid', 'fa-dove', 'teal'), | ||
# Pheasants, Grouse, and Allies | ||
574: FontAwesomeIcon('fa-solid', 'fa-feather', 'teal'), | ||
879: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'brown'), | ||
71261: FontAwesomeIcon('fa-solid', 'fa-crow', 'black'), | ||
6888: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'green'), | ||
1199: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'brown'), | ||
67569: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'pink'), | ||
2708: FontAwesomeIcon('fa-solid', 'fa-dove', 'teal'), | ||
6913: FontAwesomeIcon('fa-solid', 'fa-dove', 'teal'), | ||
67564: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'blue'), | ||
19350: FontAwesomeIcon('fa-solid', 'fa-crow', 'brown'), | ||
18874: FontAwesomeIcon('fa-solid', 'fa-kiwi-bird', 'green'), | ||
# Amphibians + reptiles | ||
20978: FontAwesomeIcon('fa-solid', 'fa-frog', 'green'), | ||
26036: FontAwesomeIcon('fa-solid', 'fa-dragon', 'green'), | ||
26039: FontAwesomeIcon('fa-solid', 'fa-dragon', 'green'), | ||
39532: FontAwesomeIcon('fa-solid', 'fa-dragon', 'green'), | ||
85553: FontAwesomeIcon('fa-solid', 'fa-worm', 'green'), | ||
# Mammals | ||
786045: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
43579: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
846280: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
47144: FontAwesomeIcon('fa-solid', 'fa-dog', 'brown'), | ||
42048: FontAwesomeIcon('fa-solid', 'fa-dog', 'grey'), | ||
42054: FontAwesomeIcon('fa-solid', 'fa-dog', 'red'), | ||
41660: FontAwesomeIcon('fa-solid', 'fa-dog', 'brown'), | ||
41944: FontAwesomeIcon('fa-solid', 'fa-cat', 'orange'), | ||
846273: FontAwesomeIcon('fa-solid', 'fa-cat', 'yellow'), | ||
43328: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
42158: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
42406: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
568826: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
848343: FontAwesomeIcon('fa-solid', 'fa-paw', 'pink'), | ||
568847: FontAwesomeIcon('fa-solid', 'fa-horse', 'grey'), | ||
42348: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
846209: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
925150: FontAwesomeIcon('fa-solid', 'fa-horse', 'brown'), | ||
43691: FontAwesomeIcon('fa-solid', 'fa-horse', 'grey'), | ||
43698: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
43094: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
45933: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
43791: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
533971: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
40268: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
41636: FontAwesomeIcon('fa-solid', 'fa-paw', 'brown'), | ||
848319: FontAwesomeIcon('fa-solid', 'fa-paw', 'brown'), | ||
42981: FontAwesomeIcon('fa-solid', 'fa-paw', 'grey'), | ||
53537: FontAwesomeIcon('fa-solid', 'fa-paw', 'brown'), | ||
41770: FontAwesomeIcon('fa-solid', 'fa-paw', 'grey'), | ||
526556: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
41871: FontAwesomeIcon('fa-solid', 'fa-otter', 'black'), | ||
846287: FontAwesomeIcon('fa-solid', 'fa-otter', 'brown'), | ||
# Fish | ||
47178: FontAwesomeIcon('fa-solid', 'fa-fish', 'blue'), | ||
47233: FontAwesomeIcon('fa-solid', 'fa-fish-fins', 'blue'), | ||
47177: FontAwesomeIcon('fa-solid', 'fa-fish', 'blue'), | ||
372843: FontAwesomeIcon('fa-solid', 'fa-otter', 'blue'), | ||
152871: FontAwesomeIcon('fa-solid', 'fa-otter', 'blue'), | ||
41479: FontAwesomeIcon('fa-solid', 'fa-otter', 'blue'), | ||
47273: FontAwesomeIcon('fa-solid', 'fa-fish-fins', 'blue'), | ||
# Molluscs | ||
47115: FontAwesomeIcon('fa-solid', 'fa-worm', 'blue'), | ||
47459: FontAwesomeIcon('fa-solid', 'fa-worm', 'blue'), | ||
127352: FontAwesomeIcon('fa-solid', 'fa-worm', 'blue'), | ||
# Arthropods | ||
85493: FontAwesomeIcon('fa-solid', 'fa-shrimp', 'red'), | ||
144114: FontAwesomeIcon('fa-solid', 'fa-shrimp', 'red'), | ||
311310: FontAwesomeIcon('fa-solid', 'fa-shrimp', 'red'), | ||
47119: FontAwesomeIcon('fa-solid', 'fa-spider', 'black'), | ||
48894: FontAwesomeIcon('fa-solid', 'fa-spider', 'black'), | ||
172373: FontAwesomeIcon('fa-solid', 'fa-spider', 'black'), | ||
48900: FontAwesomeIcon('fa-solid', 'fa-spider', 'black'), | ||
372739: FontAwesomeIcon('fa-solid', 'fa-worm', 'green'), | ||
144128: FontAwesomeIcon('fa-solid', 'fa-worm', 'green'), | ||
47822: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'brown'), | ||
153429: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'brown'), | ||
81769: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'brown'), | ||
47651: FontAwesomeIcon('fa-solid', 'fa-locust', 'green'), | ||
47157: FontAwesomeIcon('fa-solid', 'fa-locust', 'teal'), | ||
47201: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'yellow'), | ||
47336: FontAwesomeIcon('fa-solid', 'fa-mosquito', 'yellow'), | ||
48511: FontAwesomeIcon('fa-solid', 'fa-bug', 'brown'), | ||
47208: FontAwesomeIcon('fa-solid', 'fa-bug', 'brown'), | ||
471714: FontAwesomeIcon('fa-solid', 'fa-bugs', 'brown'), | ||
# Plants | ||
47126: FontAwesomeIcon('fa-solid', 'fa-seedling', 'green'), | ||
136329: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
47903: FontAwesomeIcon('fa-solid', 'fa-sun-plant-wilt', 'brown'), | ||
47162: FontAwesomeIcon('fa-solid', 'fa-wheat-awn', 'yellow'), | ||
121943: FontAwesomeIcon('fa-solid', 'fa-pagelines', 'green'), | ||
70233: FontAwesomeIcon('fa-solid', 'fa-seedling', 'green'), | ||
48866: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
544534: FontAwesomeIcon('fa-solid', 'fa-bowling-ball', 'brown'), | ||
47605: FontAwesomeIcon('fa-solid', 'fa-fan', 'yellow'), | ||
605446: FontAwesomeIcon('fa-solid', 'fa-fan', 'yellow'), | ||
47690: FontAwesomeIcon('fa-solid', 'fa-fan', 'pink'), | ||
48796: FontAwesomeIcon('fa-solid', 'fa-fan', 'pink'), | ||
47329: FontAwesomeIcon('fa-solid', 'fa-fan', 'pink'), | ||
47148: FontAwesomeIcon('fa-solid', 'fa-fan', 'red'), | ||
47727: FontAwesomeIcon('fa-solid', 'fa-canadian-maple-leaf', 'red'), | ||
53548: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
47853: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
151882: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
50998: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
47567: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
71434: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
47194: FontAwesomeIcon('fa-solid', 'fa-tree', 'green'), | ||
48699: FontAwesomeIcon('fa-solid', 'fa-carrot', 'orange'), | ||
47204: FontAwesomeIcon('fa-solid', 'fa-seedling', 'green'), | ||
71291: FontAwesomeIcon('fa-solid', 'fa-wine-bottle', 'red'), | ||
48620: FontAwesomeIcon('fa-solid', 'fa-bowling-ball', 'orange'), | ||
62910: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
50623: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
723302: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
49570: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'yellow'), | ||
48874: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'green'), | ||
47351: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
47733: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'green'), | ||
55849: FontAwesomeIcon('fa-solid', 'fa-pepper-hot', 'grey'), | ||
48516: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
48517: FontAwesomeIcon('fa-solid', 'fa-pepper-hot', 'red'), | ||
62848: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
635417: FontAwesomeIcon('fa-solid', 'fa-wheat-awn', 'yellow'), | ||
55150: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'green'), | ||
50299: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'red'), | ||
634914: FontAwesomeIcon('fa-solid', 'fa-apple-whole', 'blue'), | ||
# Other | ||
1: FontAwesomeIcon('fa-solid', 'fa-paw', 'black'), | ||
47491: FontAwesomeIcon('fa-solid', 'fa-worm', 'pink'), | ||
47170: FontAwesomeIcon('fa-solid', 'fa-bacteria', 'brown'), # mushroom | ||
48222: FontAwesomeIcon('fa-solid', 'fa-bowling-ball', 'green'), | ||
67333: FontAwesomeIcon('fa-solid', 'fa-bacterium', 'green'), | ||
131236: FontAwesomeIcon('fa-solid', 'fa-virus', 'red'), | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this isn't currently used by any other library features, could you move all the Font Awesome-related code from
constants.py
to the new modulefont_awesome_icons.py
?