gamcoh / st-card

Streamlit component for UI cards
https://pypi.org/project/streamlit-card/
MIT License
119 stars 21 forks source link

Card without image gives error, support colored bg instead of image #25

Closed norbusan closed 6 months ago

norbusan commented 11 months ago

The documentation says that the image parameter is optional, but if I don't pass it, I get warning messages:

2024-01-03 21:56:32.558 ComponentRequestHandler: GET /Users/preining/.pyenv/versions/3.10.13/envs/ffe-eval-dash2/lib/python3.10/site-packages/streamlit_card/frontend/build/null read error
Traceback (most recent call last):
  File "/Users/preining/.pyenv/versions/3.10.13/envs/ffe-eval-dash2/lib/python3.10/site-packages/streamlit/web/server/component_request_handler.py", line 55, in get
    with open(abspath, "rb") as file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/preining/.pyenv/versions/3.10.13/envs/ffe-eval-dash2/lib/python3.10/site-packages/streamlit_card/frontend/build/null'

In fact, what I would like to see is that one can just give a color for the background, and no image is needed.

Is this possible?

Thanks for providing this widget!

gamcoh commented 11 months ago

The image parameter is not optional.

But it can be, we just need the implementation

norbusan commented 11 months ago

Hi @gamcoh ahhh, not optional ... you might want to update the documentation: https://github.com/gamcoh/st-card/blob/main/streamlit_card/__init__.py#L37 ;-)

I think a simple (- though don't ask me for javascript code) check for whether the image parameter is null, and then not adding the url stuff in the div should work.

Although not at all a JS guy, I might look into it.

adchalmers commented 9 months ago

Not really a TS/JS person either, however, happy to have a look as well.

I set the image to something blank. I used: image = "https://upload.wikimedia.org/wikipedia/en/4/48/Blank.JPG"

ethanknights commented 9 months ago

Hey @norbusan CC @gamcoh - I noticed the same error yesterday when omitting a background image - I've attempted to address this part of the issue here: #27.