File size: 3,836 Bytes
4a3a4a3
 
 
 
 
 
 
f0296d1
 
4a3a4a3
 
f0296d1
4a3a4a3
f0296d1
4a3a4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0296d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a3a4a3
 
f0296d1
4a3a4a3
 
 
73df6bf
f0296d1
4a3a4a3
 
 
 
f0296d1
 
4a3a4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import base64
import os
from datetime import datetime
from pathlib import Path

import mailerlite as MailerLite
import streamlit as st
import streamlit.components.v1 as components


client = MailerLite.Client({
    'api_key': os.environ['mailerlitetoken']
})
NEWSLETTER_GROUP_ID = int(os.environ['NEWSLETTERGROUPID'])


def get_timestamp():
    return datetime.now().strftime('%Y-%m-%d %H:%M:%S')


def add_logo_to_sidebar():
    st.markdown(
        f"""
            <style>
                [data-testid="stSidebarNav"] {{
                    background-image: url(data:image/png;base64,{base64.b64encode(Path('logo.png').read_bytes()).decode()});
                    background-repeat: no-repeat;
                    background-position: 20px 20px;
                    background-size: 300px;
                    padding-top: 100px
                }}
            </style>
            """,
        unsafe_allow_html=True,
    )


def add_share_to_twitter_button():
    return components.html(
        """
            <a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" 
            data-text="Checkout the Legal AI Actions Demo from @simplexico_ 🎈" 
            data-url="https://simplexico-legal-ai-actions.hf.space"
            data-show-count="false">
            data-size="Large" 
            data-hashtags="legalai,legalnlp"
            Tweet
            </a>
            <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
        """, height=30
    )


def add_footer():
    st.markdown("""
    ### πŸ™‹β€β™‚οΈ Interested in building out your own tailored Legal AI solutions?
    - 🌐 Check out our [website](https://simplexico.ai)
    - πŸ“ž Book a call with [us](https://calendly.com/uwais-iqbal/discovery-call)
    - βœ‰οΈ Send us an [email](mailto:[email protected])
    
    #### πŸ™Œ Follow Us on Social Media - [πŸ₯ Twitter](https://twitter.com/_simplexico) | [πŸ’Ό LinkedIn](https://www.linkedin.com/company/simplexico/?viewAsMember=true)
    """)


def add_email_signup_form():
    st.markdown("### πŸ’Œ Join our mailing list!")
    st.markdown('Keep up to date with all things simplexico with our monthly newsletter.')
    col1, col2 = st.columns(2)
    with st.form(key='email-form'):
        name = col1.text_input(label='Enter your name', placeholder='John Doe')
        email = col2.text_input(label='Enter your email', placeholder='[email protected]')

        submit_button = st.form_submit_button(label='Submit', type='primary', use_container_width=True)

        if submit_button:
            valid_name = True
            valid_email = True

            if name == "":
                st.error('❌ Error! Please enter a name.')
                valid_name = False

            if email == "":
                st.error('❌ Error! Please enter an email.')
                valid_email = False
            elif not '@' in email:
                st.error('❌ Error! Please enter a valid email.')
                valid_email = False
            elif not '.' in email.split('@')[-1]:
                st.error('❌ Error! Please enter a valid email.')
                valid_email = False

            if valid_name and valid_email:
                response = client.subscribers.create(email, fields={'name': name},
                                                     groups=[NEWSLETTER_GROUP_ID],
                                                     status='active', subscribed_at=get_timestamp())
                try:
                    if response['data']['status'] == 'active':
                        st.success(f'βœ… πŸ‘‹ Hey {name}! Welcome to our mailing list.')
                except Exception as e:
                    st.error(f"πŸ˜• Sorry {name}. Something went wrong. We weren't able to add you to our mailing list.")