sammoftah commited on
Commit
d2991ca
·
verified ·
1 Parent(s): fc5eae3

Polish landing page hero

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +8 -3
  3. shared/components.py +90 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: Token Playground
3
- emoji: 🎮
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
 
1
  ---
2
+ title: 06 Token Playground
3
+ emoji: 🚀
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
app.py CHANGED
@@ -2,7 +2,7 @@
2
  import gradio as gr
3
  import sys, os
4
  sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
5
- from shared.components import create_header, create_footer
6
  from shared.utils import estimate_tokens, calculate_cost
7
 
8
  TOKENIZERS = {
@@ -47,8 +47,13 @@ custom_css = """
47
  """
48
 
49
  with gr.Blocks(css=custom_css, title="Token Playground", theme=gr.themes.Soft()) as app:
50
- create_header("Token Playground", "Compare tokenizers • Calculate costs", "🎮")
51
- gr.Markdown("Paste a prompt, paragraph, or product description and compare rough token usage across model families.")
 
 
 
 
 
52
  with gr.Row():
53
  with gr.Column(scale=1):
54
  text_input = gr.Textbox(
 
2
  import gradio as gr
3
  import sys, os
4
  sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
5
+ from shared.components import create_premium_hero, create_footer
6
  from shared.utils import estimate_tokens, calculate_cost
7
 
8
  TOKENIZERS = {
 
47
  """
48
 
49
  with gr.Blocks(css=custom_css, title="Token Playground", theme=gr.themes.Soft()) as app:
50
+ create_premium_hero(
51
+ "Token Playground",
52
+ "See token counts before you ship. Compare rough usage and cost across popular model families in one fast, elegant panel.",
53
+ "🎮",
54
+ badge="Model Economics",
55
+ highlights=["Token estimates", "Cost comparison", "Fast text analysis"],
56
+ )
57
  with gr.Row():
58
  with gr.Column(scale=1):
59
  text_input = gr.Textbox(
shared/components.py CHANGED
@@ -55,6 +55,86 @@ class SharedComponents:
55
  ">
56
  <strong style="color:#e2e8f0;">HF-Master v{version}</strong> | Built with ❤️ for the AI community
57
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  """)
59
 
60
  @staticmethod
@@ -255,6 +335,16 @@ def create_footer(version: str = "1.0.0") -> gr.Markdown:
255
  return SharedComponents.create_footer(version)
256
 
257
 
 
 
 
 
 
 
 
 
 
 
258
  class ProgressTracker:
259
  """Track multi-step progress"""
260
 
 
55
  ">
56
  <strong style="color:#e2e8f0;">HF-Master v{version}</strong> | Built with ❤️ for the AI community
57
  </div>
58
+ """)
59
+
60
+ @staticmethod
61
+ def create_premium_hero(
62
+ title: str,
63
+ description: str,
64
+ emoji: str = "🚀",
65
+ badge: str = "Featured Space",
66
+ highlights: Optional[List[str]] = None,
67
+ ) -> gr.HTML:
68
+ """Create a richer landing-page hero for Spaces."""
69
+ highlights = highlights or []
70
+ chips = "".join(
71
+ f"""
72
+ <span style="
73
+ display:inline-flex;
74
+ align-items:center;
75
+ gap:0.4rem;
76
+ padding:0.45rem 0.8rem;
77
+ border-radius:999px;
78
+ background: rgba(255,255,255,0.08);
79
+ border: 1px solid rgba(255,255,255,0.10);
80
+ color:#e2e8f0;
81
+ font-size:0.88rem;
82
+ font-weight:600;
83
+ ">{item}</span>
84
+ """
85
+ for item in highlights
86
+ )
87
+
88
+ return gr.HTML(f"""
89
+ <div style="
90
+ background:
91
+ linear-gradient(135deg, rgba(78,205,196,0.18), rgba(255,107,107,0.14)),
92
+ rgba(15, 23, 42, 0.88);
93
+ border: 1px solid rgba(255,255,255,0.12);
94
+ border-radius: 28px;
95
+ padding: 2rem;
96
+ margin-bottom: 1.25rem;
97
+ box-shadow: 0 22px 50px rgba(0,0,0,0.22);
98
+ backdrop-filter: blur(16px);
99
+ ">
100
+ <div style="display:flex; align-items:flex-start; gap:1rem; flex-wrap:wrap; justify-content:space-between;">
101
+ <div style="display:flex; gap:1rem; align-items:flex-start; flex:1; min-width: 260px;">
102
+ <div style="
103
+ width:4rem;
104
+ height:4rem;
105
+ display:flex;
106
+ align-items:center;
107
+ justify-content:center;
108
+ border-radius:1.25rem;
109
+ background: rgba(255,255,255,0.09);
110
+ border: 1px solid rgba(255,255,255,0.12);
111
+ font-size:1.8rem;
112
+ flex-shrink:0;
113
+ ">{emoji}</div>
114
+ <div>
115
+ <div style="
116
+ display:inline-flex;
117
+ align-items:center;
118
+ padding:0.35rem 0.75rem;
119
+ border-radius:999px;
120
+ background: rgba(255,255,255,0.08);
121
+ border: 1px solid rgba(255,255,255,0.10);
122
+ color:#cbd5e1;
123
+ font-size:0.8rem;
124
+ font-weight:700;
125
+ letter-spacing:0.08em;
126
+ text-transform:uppercase;
127
+ margin-bottom:0.8rem;
128
+ ">{badge}</div>
129
+ <h1 style="margin:0 0 0.35rem 0; font-size:clamp(2rem, 4vw, 3.35rem); line-height:1.05; letter-spacing:-0.04em; color:#f8fafc;">{title}</h1>
130
+ <p style="margin:0; color:#cbd5e1; font-size:1.05rem; line-height:1.65; max-width: 62ch;">{description}</p>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ <div style="display:flex; gap:0.6rem; flex-wrap:wrap; margin-top:1.25rem;">
135
+ {chips}
136
+ </div>
137
+ </div>
138
  """)
139
 
140
  @staticmethod
 
335
  return SharedComponents.create_footer(version)
336
 
337
 
338
+ def create_premium_hero(
339
+ title: str,
340
+ description: str,
341
+ emoji: str = "🚀",
342
+ badge: str = "Featured Space",
343
+ highlights: Optional[List[str]] = None,
344
+ ) -> gr.HTML:
345
+ return SharedComponents.create_premium_hero(title, description, emoji, badge, highlights)
346
+
347
+
348
  class ProgressTracker:
349
  """Track multi-step progress"""
350