Spaces:
Sleeping
Sleeping
Update second.py
Browse files
second.py
CHANGED
|
@@ -1,96 +1,126 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
{"name": "
|
| 17 |
-
{"name": "
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
def
|
| 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 |
-
def
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
"MonsterUI Scrollspy Example application"
|
| 3 |
+
|
| 4 |
+
from fasthtml.common import *
|
| 5 |
+
from monsterui.all import *
|
| 6 |
+
import random
|
| 7 |
+
|
| 8 |
+
# Using the "slate" theme with Highlight.js enabled
|
| 9 |
+
hdrs = Theme.slate.headers(highlightjs=True)
|
| 10 |
+
app, rt = fast_app(hdrs=hdrs)
|
| 11 |
+
|
| 12 |
+
################################
|
| 13 |
+
### Example Data and Content ###
|
| 14 |
+
################################
|
| 15 |
+
products = [
|
| 16 |
+
{"name": "Laptop", "price": "$999"},
|
| 17 |
+
{"name": "Smartphone", "price": "$599"}
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
code_example = """
|
| 21 |
+
# Python Code Example
|
| 22 |
+
def greet(name):
|
| 23 |
+
return f"Hello, {name}!"
|
| 24 |
+
|
| 25 |
+
print(greet("World"))
|
| 26 |
+
"""
|
| 27 |
+
testimonials = [
|
| 28 |
+
{"name": "Alice", "feedback": "Great products and excellent customer service!"},
|
| 29 |
+
{"name": "Bob", "feedback": "Fast shipping and amazing quality!"},
|
| 30 |
+
{"name": "Charlie", "feedback": "Amazing experience! Will definitely buy again."},
|
| 31 |
+
{"name": "Diana", "feedback": "Affordable prices and great variety!"},
|
| 32 |
+
{"name": "Edward", "feedback": "Customer support was very helpful."},
|
| 33 |
+
{"name": "Fiona", "feedback": "Loved the design and quality!"}
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
# Team members
|
| 37 |
+
team = [
|
| 38 |
+
{"name": "Isaac Flath", "role": "CEO"},
|
| 39 |
+
{"name": "Benjamin Clavié", "role": "AI Researcher"},
|
| 40 |
+
{"name": "Alexis Gallagher", "role": "ML Engineer"},
|
| 41 |
+
{"name": "Hamel Husain", "role": "Data Scientist"},
|
| 42 |
+
{"name": "Austin Huang", "role": "Software Engineer"},
|
| 43 |
+
{"name": "Benjamin Warner", "role": "Product Manager"},
|
| 44 |
+
{"name": "Jonathan Whitaker", "role": "UX Designer"},
|
| 45 |
+
{"name": "Kerem Turgutlu", "role": "DevOps Engineer"},
|
| 46 |
+
{"name": "Curtis Allan", "role": "DevOps Engineer"},
|
| 47 |
+
{"name": "Audrey Roy Greenfeld", "role": "Security Analyst"},
|
| 48 |
+
{"name": "Nathan Cooper", "role": "Full Stack Developer"},
|
| 49 |
+
{"name": "Jeremy Howard", "role": "CTO"},
|
| 50 |
+
{"name": "Wayde Gilliam", "role": "Cloud Architect"},
|
| 51 |
+
{"name": "Daniel Roy Greenfeld", "role": "Blockchain Expert"},
|
| 52 |
+
{"name": "Tommy Collins", "role": "AI Ethics Researcher"}
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def ProductCard(p,img_id=1):
|
| 57 |
+
return Card(
|
| 58 |
+
PicSumImg(w=500, height=100, id=img_id),
|
| 59 |
+
DivFullySpaced(H4(p["name"]), P(Strong(p["price"], cls=TextT.sm))),
|
| 60 |
+
Button("Details", cls=(ButtonT.primary, "w-full")))
|
| 61 |
+
|
| 62 |
+
def TestimonialCard(t,img_id=1):
|
| 63 |
+
return Card(
|
| 64 |
+
DivLAligned(PicSumImg(w=50, h=50, cls='rounded-full', id=img_id), H4(t["name"])),
|
| 65 |
+
P(Q((t["feedback"]))))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def TeamCard(m,img_id=1):
|
| 69 |
+
return Card(
|
| 70 |
+
DivLAligned(
|
| 71 |
+
PicSumImg(w=50, h=50, cls='rounded-full', id=img_id),
|
| 72 |
+
Div(H4(m["name"]), P(m["role"]))),
|
| 73 |
+
DivRAligned(
|
| 74 |
+
UkIcon('twitter', cls='w-5 h-5'),
|
| 75 |
+
UkIcon('linkedin', cls='w-5 h-5'),
|
| 76 |
+
UkIcon('github', cls='w-5 h-5'),
|
| 77 |
+
cls=TextT.gray+'space-x-2'
|
| 78 |
+
),
|
| 79 |
+
cls='p-3')
|
| 80 |
+
|
| 81 |
+
################################
|
| 82 |
+
### Navigation and Scrollspy ###
|
| 83 |
+
################################
|
| 84 |
+
|
| 85 |
+
scrollspy_links = (
|
| 86 |
+
A("Welcome", href="#welcome-section"),
|
| 87 |
+
A("Products", href="#products-section"),
|
| 88 |
+
A("Testimonials", href="#testimonials-section"),
|
| 89 |
+
A("Team", href="#team-section"),
|
| 90 |
+
A("Code Example", href="#code-section"))
|
| 91 |
+
@rt
|
| 92 |
+
def index():
|
| 93 |
+
def _Section(*c, **kwargs): return Section(*c, cls='space-y-3 my-48',**kwargs)
|
| 94 |
+
return Container(
|
| 95 |
+
NavBar(
|
| 96 |
+
*scrollspy_links,
|
| 97 |
+
brand=DivLAligned(H3("Scrollspy Demo!"),UkIcon('rocket',height=30,width=30)),
|
| 98 |
+
sticky=True, uk_scrollspy_nav=True,
|
| 99 |
+
scrollspy_cls=ScrollspyT.bold),
|
| 100 |
+
NavContainer(
|
| 101 |
+
*map(Li, scrollspy_links),
|
| 102 |
+
uk_scrollspy_nav=True,
|
| 103 |
+
sticky=True,
|
| 104 |
+
cls=(NavT.primary,'pt-20 px-5 pr-10')),
|
| 105 |
+
Container(
|
| 106 |
+
# Notice the ID of each section corresponds to the `scrollspy_links` dictionary
|
| 107 |
+
# So in scollspy `NavContainer` the `href` of each `Li` is the ID of the section
|
| 108 |
+
DivCentered(
|
| 109 |
+
H1("Welcome to the Store!"),
|
| 110 |
+
Subtitle("Explore our products and enjoy dynamic code examples."),
|
| 111 |
+
id="welcome-section"),
|
| 112 |
+
_Section(H2("Products"),
|
| 113 |
+
Grid(*[ProductCard(p,img_id=i) for i,p in enumerate(products)], cols_lg=2),
|
| 114 |
+
id="products-section"),
|
| 115 |
+
_Section(H2("Testimonials"),
|
| 116 |
+
Slider(*[TestimonialCard(t,img_id=i) for i,t in enumerate(testimonials)]),
|
| 117 |
+
id="testimonials-section"),
|
| 118 |
+
_Section(H2("Our Team"),
|
| 119 |
+
Grid(*[TeamCard(m,img_id=i) for i,m in enumerate(team)], cols_lg=2, cols_max=3),
|
| 120 |
+
id="team-section"),
|
| 121 |
+
_Section(H2("Code Example"),
|
| 122 |
+
CodeBlock(code_example, lang="python"),
|
| 123 |
+
id="code-section")),
|
| 124 |
+
cls=(ContainerT.xl,'uk-container-expand'))
|
| 125 |
+
|
| 126 |
+
serve()
|