Skip to content

Commit

Permalink
Remve extra space in cookie manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-512 committed Mar 12, 2024
1 parent 99f51db commit 1fa9839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions extra_streamlit_components/CookieManager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from typing import Literal, Optional, Union, Dict

import streamlit as st
import streamlit.components.v1 as components
from extra_streamlit_components import IS_RELEASE

Expand All @@ -21,6 +22,7 @@ def __init__(self, key="init"):
self.cookies = self.cookie_manager(method="getAll", key=key, default={})

def get(self, cookie: str):
self._remove_extra_spacing()
return self.cookies.get(cookie)

def set(
Expand Down Expand Up @@ -54,6 +56,7 @@ def set(
if expires_at is None:
expires_at = datetime.datetime.now() + datetime.timedelta(days=1)

self._remove_extra_spacing()
expires = expires_at.isoformat()
options = {
"path": path,
Expand Down Expand Up @@ -108,5 +111,16 @@ def delete(self, cookie, key="delete"):
del self.cookies[cookie]

def get_all(self, key="get_all"):
self._remove_extra_spacing()
self.cookies = self.cookie_manager(method="getAll", key=key, default={})
return self.cookies

def _remove_extra_spacing(self):
st.markdown(
"""
<style>
.element-container:has(iframe[height="0"]) { display: none; }
</style>
""",
unsafe_allow_html=True,
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="extra_streamlit_components",
version="0.1.60",
version="0.1.71",
author="Mohamed Abdou",
author_email="matex512@gmail.com",
description="An all-in-one place, to find complex or just natively unavailable components on streamlit.",
Expand All @@ -19,7 +19,7 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
keywords=['Python', 'Streamlit', 'React', 'JavaScript'],
keywords=["Python", "Streamlit", "React", "JavaScript"],
python_requires=">=3.6",
install_requires=[
"streamlit >= 1.18.0",
Expand Down

0 comments on commit 1fa9839

Please sign in to comment.