Sentiment-Classifier-App / st_functions.py
gArthur98's picture
uopdate
38468af
import streamlit as st
def load_css():
with open("pages/style.css") as f:
st.markdown('<style>{}</style>'.format(f.read()), unsafe_allow_html=True)
st.markdown('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">', unsafe_allow_html=True)
def st_button(icon, url, label, iconsize):
if icon == 'email':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-youtube" viewBox="0 0 16 16">
<path d="M8.051 1.999h.089c.822.003 4.987.033 6.11.335a2.01 2.01 0 0 1 1.415 1.42c.101.38.172.883.22 1.402l.01.104.022.26.008.104c.065.914.073 1.77.074 1.957v.075c-.001.194-.01 1.108-.082 2.06l-.008.105-.009.104c-.05.572-.124 1.14-.235 1.558a2.007 2.007 0 0 1-1.415 1.42c-1.16.312-5.569.334-6.18.335h-.142c-.309 0-1.587-.006-2.927-.052l-.17-.006-.087-.004-.171-.007-.171-.007c-1.11-.049-2.167-.128-2.654-.26a2.007 2.007 0 0 1-1.415-1.419c-.111-.417-.185-.986-.235-1.558L.09 9.82l-.008-.104A31.4 31.4 0 0 1 0 7.68v-.123c.002-.215.01-.958.064-1.778l.007-.103.003-.052.008-.104.022-.26.01-.104c.048-.519.119-1.023.22-1.402a2.007 2.007 0 0 1 1.415-1.42c.487-.13 1.544-.21 2.654-.26l.17-.007.172-.006.086-.003.171-.007A99.788 99.788 0 0 1 7.858 2h.193zM6.4 5.209v4.818l4.157-2.408L6.4 5.209z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'twitter':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-twitter" viewBox="0 0 16 16">
<path d="M5.026 15c6.038 0 9.341-5.003 9.341-9.334 0-.14 0-.282-.006-.422A6.685 6.685 0 0 0 16 3.542a6.658 6.658 0 0 1-1.889.518 3.301 3.301 0 0 0 1.447-1.817 6.533 6.533 0 0 1-2.087.793A3.286 3.286 0 0 0 7.875 6.03a9.325 9.325 0 0 1-6.767-3.429 3.289 3.289 0 0 0 1.018 4.382A3.323 3.323 0 0 1 .64 6.575v.045a3.288 3.288 0 0 0 2.632 3.218 3.203 3.203 0 0 1-.865.115 3.23 3.23 0 0 1-.614-.057 3.283 3.283 0 0 0 3.067 2.277A6.588 6.588 0 0 1 .78 13.58a6.32 6.32 0 0 1-.78-.045A9.344 9.344 0 0 0 5.026 15z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'linkedin':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-linkedin" viewBox="0 0 16 16">
<path d="M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'mail':
button_code = f'''
<p>
<a href="mailto:{url}" class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width="{iconsize}" height="{iconsize}" fill="currentColor" class="bi bi-envelope-fill" viewBox="0 0 16 16">
<path d="M13.268 1.803L14.89.182a.486.486 0 0 1 .689.014l.014.014c.215.197.215.514.014.713l-2.67 2.67a.502.502 0 0 1-.713 0L7.805 1.286a.486.486 0 0 1 .014-.689l.014-.014a.502.502 0 0 1 .713 0l4.726 4.725c.202.202.509.23.713.014l.014-.014 1.62-1.62a.486.486 0 0 1 .014-.689l-.014-.014a.502.502 0 0 1-.713 0l-1.62 1.62-4.725-4.726a.502.502 0 0 1 0-.713L12.554.196c.199-.199.516-.201.713-.014l.014.014zM1.063 5.041l-.057.05a.486.486 0 0 0-.027.68l.027.034L6.5 10.436l5.42-4.583-.045-.057a.486.486 0 0 0-.68-.027l-.034.027L6.5 9.564 1.063 5.041zm-1.041 8.69a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V5.193l-6.902 5.833a2.48 2.48 0 0 1-2.196.377A2.48 2.48 0 0 1 4.1 10.026L10 4.193H2a2 2 0 0 0-2 2v7.538z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'medium':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-medium" viewBox="0 0 16 16">
<path d="M9.025 8c0 2.485-2.02 4.5-4.513 4.5A4.506 4.506 0 0 1 0 8c0-2.486 2.02-4.5 4.512-4.5A4.506 4.506 0 0 1 9.025 8zm4.95 0c0 2.34-1.01 4.236-2.256 4.236-1.246 0-2.256-1.897-2.256-4.236 0-2.34 1.01-4.236 2.256-4.236 1.246 0 2.256 1.897 2.256 4.236zM16 8c0 2.096-.355 3.795-.794 3.795-.438 0-.793-1.7-.793-3.795 0-2.096.355-3.795.794-3.795.438 0 .793 1.699.793 3.795z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'github':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.582 0 8.002c0 3.537 2.29 6.53 5.47 7.59.4.074.546-.173.546-.385 0-.19-.007-.693-.01-1.36-2.225.482-2.695-1.07-2.695-1.07-.364-.926-.89-1.17-.89-1.17-.727-.497.055-.487.055-.487.803.057 1.227.826 1.227.826.714 1.222 1.873.87 2.33.665.072-.517.28-.87.508-1.07-1.777-.2-3.644-.888-3.644-3.95 0-.87.31-1.586.823-2.145-.09-.2-.36-1.015.07-2.117 0 0 .67-.215 2.2.82.64-.18 1.32-.27 2-.274.68.004 1.36.094 2 .275 1.52-1.036 2.19-.82 2.19-.82.43 1.102.16 1.917.08 2.117.51.56.82 1.274.82 2.145 0 3.07-1.87 3.747-3.65 3.943.29.247.54.733.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.14.46.55.38C13.72 14.53 16 11.53 16 8.003 16 3.582 12.418 0 8 0z"/>
</svg>
{label}
</a>
</p>'''
elif icon == 'cup':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
<svg xmlns="http://www.w3.org/2000/svg" width={iconsize} height={iconsize} fill="currentColor" class="bi bi-cup-fill" viewBox="0 0 16 16">
<path d="M1 2a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v1h.5A1.5 1.5 0 0 1 16 4.5v7a1.5 1.5 0 0 1-1.5 1.5h-.55a2.5 2.5 0 0 1-2.45 2h-8A2.5 2.5 0 0 1 1 12.5V2zm13 10h.5a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.5-.5H14v8z"/>
</svg>
{label}
</a>
</p>'''
elif icon == '':
button_code = f'''
<p>
<a href={url} class="btn btn-outline-primary btn-lg btn-block" type="button" aria-pressed="true">
{label}
</a>
</p>'''
return st.markdown(button_code, unsafe_allow_html=True)