Added Commands Management
This commit is contained in:
21
src/myfasthtml/icons/Readme.md
Normal file
21
src/myfasthtml/icons/Readme.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Generate Icons
|
||||
|
||||
Create the icons files for FastHtml applications.
|
||||
|
||||
## How to generate the svg files
|
||||
```sh
|
||||
npm i -D @sicons/fa
|
||||
npm i -D @sicons/fluent
|
||||
npm i -D @sicons/ionicons4
|
||||
npm i -D @sicons/ionicons5
|
||||
npm i -D @sicons/antd
|
||||
npm i -D @sicons/material
|
||||
npm i -D @sicons/tabler
|
||||
npm i -D @sicons/carbon
|
||||
```
|
||||
Update the root folder in `update_icons.py` to point to the root folder of the icons.
|
||||
|
||||
##
|
||||
```sh
|
||||
python update_icons.py
|
||||
```
|
||||
0
src/myfasthtml/icons/__init__.py
Normal file
0
src/myfasthtml/icons/__init__.py
Normal file
1679
src/myfasthtml/icons/antd.py
Normal file
1679
src/myfasthtml/icons/antd.py
Normal file
File diff suppressed because it is too large
Load Diff
8907
src/myfasthtml/icons/carbon.py
Normal file
8907
src/myfasthtml/icons/carbon.py
Normal file
File diff suppressed because it is too large
Load Diff
1617
src/myfasthtml/icons/fa.py
Normal file
1617
src/myfasthtml/icons/fa.py
Normal file
File diff suppressed because one or more lines are too long
30900
src/myfasthtml/icons/fluent.py
Normal file
30900
src/myfasthtml/icons/fluent.py
Normal file
File diff suppressed because it is too large
Load Diff
8653
src/myfasthtml/icons/ionicons4.py
Normal file
8653
src/myfasthtml/icons/ionicons4.py
Normal file
File diff suppressed because it is too large
Load Diff
5295
src/myfasthtml/icons/ionicons5.py
Normal file
5295
src/myfasthtml/icons/ionicons5.py
Normal file
File diff suppressed because one or more lines are too long
19062
src/myfasthtml/icons/material.py
Normal file
19062
src/myfasthtml/icons/material.py
Normal file
File diff suppressed because it is too large
Load Diff
10870
src/myfasthtml/icons/tabler.py
Normal file
10870
src/myfasthtml/icons/tabler.py
Normal file
File diff suppressed because it is too large
Load Diff
51
src/myfasthtml/icons/update_icons.py
Normal file
51
src/myfasthtml/icons/update_icons.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import os
|
||||
|
||||
root_folder = "/home/kodjo/Dev/MyDocManager/src/frontend/node_modules/@sicons"
|
||||
|
||||
import re
|
||||
|
||||
|
||||
def pascal_to_snake(name: str) -> str:
|
||||
"""Convert a PascalCase or CamelCase string to snake_case."""
|
||||
# Insert underscore before capital letters (except the first one)
|
||||
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
# Handle consecutive capital letters (like 'HTTPServer' -> 'http_server')
|
||||
s2 = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', s1)
|
||||
return s2.lower()
|
||||
|
||||
|
||||
def create_icons(file, icon_folder):
|
||||
for filename in os.listdir(f"{root_folder}/{icon_folder}"):
|
||||
print("#", end='')
|
||||
if not filename.endswith(".svg"):
|
||||
continue
|
||||
|
||||
with open(f"{root_folder}/{icon_folder}/{filename}", "r") as f_read:
|
||||
svg_content = f_read.read().strip()
|
||||
icon_name = "icon_" + pascal_to_snake(filename.split('.')[0])
|
||||
file.write(f"{icon_name} = NotStr('''{svg_content}''')\n")
|
||||
|
||||
print("")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for folder in ["antd", "material", "carbon", "fa", "fluent", "ionicons4", "ionicons5", "tabler"]:
|
||||
# for folder in ["antd"]:
|
||||
print(f"Processing icons for {folder}")
|
||||
with open(f"{folder}.py", "w") as f_write:
|
||||
|
||||
# Add README.md content to the top of the file
|
||||
if os.path.exists(f"{root_folder}/{folder}/README.md"):
|
||||
with open(f"{root_folder}/{folder}/README.md", "r") as f_readme:
|
||||
for line in f_readme:
|
||||
if line.startswith("#"):
|
||||
f_write.write(line)
|
||||
else:
|
||||
f_write.write(f"# {line}")
|
||||
f_write.write("\n\n")
|
||||
|
||||
# Add imports
|
||||
f_write.write("from fastcore.basics import NotStr\n\n")
|
||||
|
||||
# Add icons
|
||||
create_icons(f_write, folder)
|
||||
Reference in New Issue
Block a user