Skip to content

Commit 8efdae2

Browse files
authored
ENG-8858: Docs follow ups (#1759)
* ENG-8858: Docs follow ups * grayish text
1 parent de1ca58 commit 8efdae2

File tree

3 files changed

+129
-69
lines changed

3 files changed

+129
-69
lines changed

pcweb/components/icons/icons.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@
517517
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.7484 1.45825C13.2882 1.45825 12.9151 1.83135 12.9151 2.29159C12.9151 2.75182 13.2882 3.12492 13.7484 3.12492H14.2554C13.8453 3.49859 13.2917 3.96377 12.5801 4.48301C10.72 5.84039 7.77562 7.57079 3.48491 9.001C3.0483 9.14659 2.81233 9.6185 2.95787 10.0551C3.1034 10.4918 3.57534 10.7277 4.01196 10.5822C8.47125 9.09575 11.5685 7.28445 13.5626 5.82933C14.3457 5.25788 14.9579 4.74189 15.4151 4.32289V4.79159C15.4151 5.25182 15.7882 5.62492 16.2484 5.62492C16.7087 5.62492 17.0818 5.25182 17.0818 4.79159V2.29159C17.0818 1.83135 16.7087 1.45825 16.2484 1.45825H13.7484ZM15.8332 7.29159H15.815C15.6364 7.29158 15.4724 7.29157 15.3347 7.30097C15.1867 7.31107 15.0238 7.33408 14.8584 7.40259C14.5011 7.55061 14.2172 7.83451 14.0692 8.19184C14.0007 8.35725 13.9777 8.52 13.9676 8.66809C13.9582 8.80584 13.9582 8.96984 13.9582 9.14842V9.16659V16.6848C13.9582 16.8633 13.9582 17.0273 13.9676 17.1651C13.9777 17.3132 14.0007 17.4759 14.0692 17.6413C14.2172 17.9987 14.5011 18.2826 14.8584 18.4306C15.0238 18.4991 15.1867 18.5221 15.3347 18.5322C15.4724 18.5416 15.6365 18.5416 15.815 18.5416H15.8513C16.0298 18.5416 16.1939 18.5416 16.3317 18.5322C16.4798 18.5221 16.6425 18.4991 16.8079 18.4306C17.1653 18.2826 17.4492 17.9987 17.5972 17.6413C17.6657 17.4759 17.6887 17.3132 17.6988 17.1651C17.7082 17.0273 17.7082 16.8633 17.7082 16.6848V9.14842C17.7082 8.96992 17.7082 8.80584 17.6988 8.66809C17.6887 8.52 17.6657 8.35725 17.5972 8.19184C17.4492 7.83451 17.1653 7.55061 16.8079 7.40259C16.6425 7.33408 16.4798 7.31107 16.3317 7.30097C16.1939 7.29157 16.0299 7.29158 15.8513 7.29159H15.8332ZM9.98167 10.2083H9.99984H10.018C10.1966 10.2083 10.3606 10.2083 10.4983 10.2177C10.6464 10.2278 10.8092 10.2508 10.9746 10.3193C11.3319 10.4673 11.6158 10.7512 11.7638 11.1085C11.8323 11.2739 11.8553 11.4367 11.8654 11.5848C11.8748 11.7225 11.8748 11.8865 11.8748 12.0651V16.6848C11.8748 16.8633 11.8748 17.0273 11.8654 17.1651C11.8553 17.3132 11.8323 17.4759 11.7638 17.6413C11.6158 17.9987 11.3319 18.2826 10.9746 18.4306C10.8092 18.4991 10.6464 18.5221 10.4983 18.5322C10.3606 18.5416 10.1965 18.5416 10.018 18.5416H9.98167C9.80317 18.5416 9.63909 18.5416 9.50134 18.5322C9.35334 18.5221 9.19051 18.4991 9.02509 18.4306C8.66776 18.2826 8.38384 17.9987 8.23585 17.6413C8.16733 17.4759 8.14432 17.3132 8.13422 17.1651C8.12482 17.0273 8.12483 16.8633 8.12484 16.6848V12.0833V12.0651C8.12483 11.8865 8.12482 11.7225 8.13422 11.5848C8.14432 11.4367 8.16733 11.2739 8.23585 11.1085C8.38384 10.7512 8.66776 10.4673 9.02509 10.3193C9.19051 10.2508 9.35334 10.2278 9.50134 10.2177C9.63909 10.2083 9.80309 10.2083 9.98167 10.2083ZM4.1665 12.2916H4.14838C3.96983 12.2916 3.80576 12.2916 3.668 12.301C3.51996 12.3111 3.35718 12.3341 3.19176 12.4026C2.83443 12.5506 2.55053 12.8345 2.40251 13.1918C2.334 13.3573 2.31099 13.52 2.30089 13.6681C2.29149 13.8058 2.2915 13.9698 2.2915 14.1484V14.1666V16.6848C2.2915 16.8633 2.29149 17.0273 2.30089 17.1651C2.31099 17.3132 2.334 17.4759 2.40251 17.6413C2.55053 17.9987 2.83443 18.2826 3.19176 18.4306C3.35718 18.4991 3.51996 18.5221 3.668 18.5322C3.80575 18.5416 3.96978 18.5416 4.14833 18.5416H4.18464C4.36318 18.5416 4.52725 18.5416 4.66501 18.5322C4.81305 18.5221 4.97583 18.4991 5.14125 18.4306C5.49859 18.2826 5.78249 17.9987 5.9305 17.6413C5.99901 17.4759 6.02203 17.3132 6.03213 17.1651C6.04153 17.0273 6.04152 16.8633 6.0415 16.6848V14.1484C6.04152 13.9699 6.04153 13.8058 6.03213 13.6681C6.02203 13.52 5.99901 13.3573 5.9305 13.1918C5.78249 12.8345 5.49859 12.5506 5.14125 12.4026C4.97583 12.3341 4.81305 12.3111 4.66501 12.301C4.52725 12.2916 4.36322 12.2916 4.18467 12.2916H4.1665Z" fill="currentColor"/>
518518
</svg>"""
519519

520+
markdown = """<svg width="27" height="16" viewBox="0 0 27 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path d="M24.337 0q-.027 0-.052.026H2.168q-.47 0-.875.22Q.888.469.627.832q-.444.676-.34 1.48v11.975q.027.467.288.844t.626.584q.653.365 1.437.26V16l22.012-.026a1.63 1.63 0 0 0 .849-.286q.378-.259.587-.623.366-.624.261-1.429h.026l-.026-11.922a1.6 1.6 0 0 0-.287-.818 2.2 2.2 0 0 0-.626-.61A2.6 2.6 0 0 0 24.336 0m-.105 1.247h.053q.314 0 .522.13a.6.6 0 0 1 .222.168q.065.091.065.247l.026 11.844v.078q.052.415-.13.753a.6.6 0 0 1-.17.195.42.42 0 0 1-.248.065l-21.934.026h-.079a1.14 1.14 0 0 1-.73-.13.6.6 0 0 1-.223-.168.4.4 0 0 1-.065-.247V2.312l-.026-.104a.9.9 0 0 1 .143-.65q.196-.285.483-.285h21.856zM4.048 3.767v8.493h2.506V7.377l2.507 3.116 2.507-3.116v4.883h2.507V3.766h-2.507L9.06 6.883 6.554 3.766zm14.414 0V8.13h-2.507l3.76 4.13 3.76-4.13h-2.507V3.766z" fill="currentColor"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h27v16H0z"/></clipPath></defs></svg>"""
521+
520522
ICONS = {
521523
# Socials
522524
"github": github,
@@ -596,6 +598,7 @@
596598
"python-01": python_01,
597599
"shield-key": shield_key,
598600
"chart-up": chart_up,
601+
"markdown": markdown,
599602
}
600603

601604

pcweb/pages/docs_landing/views/hero.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def hero() -> rx.Component:
1111
rx.el.div(
1212
rx.el.p(
1313
"About Reflex",
14-
class_name="text-sm font-[525] text-m-slate-10 dark:text-m-slate-6",
14+
class_name="text-sm font-[525] text-primary-10 dark:text-m-slate-6",
1515
),
1616
rx.el.h1(
1717
"Reflex Documentation",

pcweb/templates/docpage/docpage.py

Lines changed: 125 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
import reflex as rx
1010
import reflex_ui as ui
1111
from reflex.components.radix.themes.base import LiteralAccentColor
12+
from reflex.experimental.client_state import ClientStateVar
1213
from reflex.utils.format import to_snake_case, to_title_case
1314

14-
from pcweb.components.button import button
1515
from pcweb.components.icons.icons import get_icon
16+
from pcweb.components.marketing_button import button as marketing_button
1617
from pcweb.route import Route, get_path
1718
from pcweb.styles.colors import c_color
1819

@@ -156,8 +157,8 @@ def footer_link_flex(heading: str, links):
156157

157158
def thumb_card(score: int, icon: str) -> rx.Component:
158159
return rx.el.button(
159-
rx.icon(
160-
tag=icon,
160+
ui.icon(
161+
icon,
161162
color=rx.cond(
162163
FeedbackState.score == score, c_color("slate", 11), c_color("slate", 9)
163164
),
@@ -173,53 +174,39 @@ def thumb_card(score: int, icon: str) -> rx.Component:
173174

174175
def thumbs_cards() -> rx.Component:
175176
return rx.hstack(
176-
thumb_card(1, "thumbs-up"),
177-
thumb_card(0, "thumbs-down"),
177+
thumb_card(1, "ThumbsUpIcon"),
178+
thumb_card(0, "ThumbsDownIcon"),
178179
gap="8px",
179180
)
180181

181182

182183
def feedback_content() -> rx.Component:
183-
return rx.box(
184-
rx.box(
185-
rx.text(
186-
"Send feedback",
187-
class_name="font-md text-slate-11",
188-
),
184+
return rx.el.div(
185+
rx.el.div(
189186
rx.form(
190-
rx.box(
191-
rx.el.textarea(
187+
rx.el.div(
188+
ui.textarea(
192189
name="feedback",
193190
placeholder="Write a comment…",
194191
type="text",
195192
max_length=500,
196193
enter_key_submit=True,
197194
resize="vertical",
198195
required=True,
199-
class_name="w-full h-full p-2 text-slate-11 font-small bg-white-1 border border-slate-4 rounded-[10px] max-h-[300px] min-h-[72px] outline-none overflow-y-auto placeholder-slate-9 focus:border-violet-9 focus:border-1",
200196
),
201197
thumbs_cards(),
202-
rx.el.input(
198+
ui.input(
203199
name="email",
204200
type="email",
205201
placeholder="Contact email (optional)",
206202
max_length=100,
207-
class_name="w-full h-full p-2 text-slate-11 font-small bg-white-1 border border-slate-4 rounded-[10px] box-border outline-none placeholder-slate-9 focus:border-violet-9 focus:border-1",
208203
),
209-
rx.box(
210-
rx.popover.close(
211-
button(
212-
"Send",
213-
type="submit",
214-
)
215-
),
216-
rx.popover.close(
217-
button(
218-
"Cancel",
219-
variant="secondary",
220-
)
221-
),
222-
class_name="flex flex-row gap-4 justify-between items-center",
204+
ui.popover.close(
205+
ui.button(
206+
"Send feedback",
207+
type="submit",
208+
class_name="w-full",
209+
)
223210
),
224211
class_name="w-full gap-4 flex flex-col",
225212
),
@@ -229,48 +216,102 @@ def feedback_content() -> rx.Component:
229216
),
230217
class_name="flex flex-col gap-4 w-full",
231218
),
232-
class_name="rounded-[26px] bg-white-1 w-[341px] max-h-[564px] shadow-large h-auto p-4",
219+
class_name="p-2",
233220
)
234221

235222

236223
def feedback_button() -> rx.Component:
237224
thumb_cn = " flex flex-row items-center justify-center gap-2 text-slate-9 whitespace-nowrap border border-slate-5 bg-slate-1 shadow-large cursor-pointer transition-bg hover:bg-slate-3 font-small"
238-
return rx.popover.root(
239-
rx.box(
240-
rx.popover.trigger(
241-
rx.box(
242-
rx.icon(tag="thumbs-up", size=15, class_name="!text-slate-9"),
243-
rx.text(
244-
"Yes",
225+
return ui.popover.root(
226+
ui.popover.trigger(
227+
render_=rx.el.div(
228+
rx.el.button(
229+
ui.icon("ThumbsUpIcon"),
230+
"Yes",
231+
type="button",
232+
class_name=ui.cn(
233+
"w-full gap-2 border-r-0 px-3 py-0.5 rounded-[20px_0_0_20px]",
234+
thumb_cn,
245235
),
246-
class_name="w-full gap-2 border-r-0 px-3 py-0.5 rounded-[20px_0_0_20px]"
247-
+ thumb_cn,
236+
aria_label="Yes",
237+
on_click=FeedbackState.set_score(1),
248238
),
249-
custom_attrs={"role": "button"},
250-
aria_label="Yes",
251-
on_click=FeedbackState.set_score(1),
252-
),
253-
rx.popover.trigger(
254-
rx.box(
255-
rx.icon(tag="thumbs-down", size=15, class_name="!text-slate-9"),
256-
rx.text(
257-
"No",
239+
rx.el.button(
240+
ui.icon("ThumbsDownIcon"),
241+
"No",
242+
type="button",
243+
class_name=ui.cn(
244+
"w-full gap-2 border-r-0 px-3 py-0.5 rounded-[0_20px_20px_0]",
245+
thumb_cn,
258246
),
259-
class_name="w-full gap-2 px-3 py-0.5 rounded-[0_20px_20px_0]"
260-
+ thumb_cn,
247+
aria_label="No",
248+
on_click=FeedbackState.set_score(0),
261249
),
262-
custom_attrs={"role": "button"},
263-
aria_label="No",
264-
on_click=FeedbackState.set_score(0),
250+
class_name="w-full lg:w-auto items-center flex flex-row",
265251
),
266-
class_name="w-full lg:w-auto items-center flex flex-row",
267252
),
268-
rx.popover.content(
269-
feedback_content(),
270-
align="start",
271-
class_name="border-none left-0 lg:left-[-255px] origin-bottom lg:origin-bottom-right !p-0 overflow-visible !bg-transparent shadow-none",
272-
avoid_collisions=True,
253+
ui.popover.portal(
254+
ui.popover.positioner(
255+
ui.popover.popup(
256+
render_=feedback_content(),
257+
),
258+
),
259+
),
260+
)
261+
262+
263+
def feedback_button_toc() -> rx.Component:
264+
return ui.popover(
265+
trigger=marketing_button(
266+
ui.icon("ThumbsUpIcon"),
267+
"Send feedback",
268+
variant="ghost",
269+
size="sm",
270+
type="button",
271+
on_click=FeedbackState.set_score(1),
272+
class_name="justify-start text-m-slate-7 dark:text-m-slate-6",
273273
),
274+
content=feedback_content(),
275+
)
276+
277+
278+
@rx.memo
279+
def copy_to_markdown(text: str) -> rx.Component:
280+
copied = ClientStateVar.create("is_copied", default=False, global_ref=False)
281+
return marketing_button(
282+
rx.cond(
283+
copied.value,
284+
ui.icon(
285+
"CheckmarkCircle02Icon",
286+
),
287+
get_icon("markdown", class_name="[&_svg]:h-4 [&_svg]:w-auto"),
288+
),
289+
"Copy to markdown",
290+
type="button",
291+
size="sm",
292+
variant="ghost",
293+
class_name="justify-start text-m-slate-7 dark:text-m-slate-6",
294+
on_click=[
295+
rx.call_function(copied.set_value(True)),
296+
rx.set_clipboard(text),
297+
],
298+
on_mouse_down=rx.call_function(copied.set_value(False)).debounce(1500),
299+
)
300+
301+
302+
def ask_ai_chat() -> rx.Component:
303+
from pcweb.pages.docs import ai_builder as ai_builder_pages
304+
305+
return rx.el.a(
306+
marketing_button(
307+
ui.icon("AiChat02Icon"),
308+
"Ask AI about this page",
309+
size="sm",
310+
variant="ghost",
311+
class_name="justify-start text-m-slate-7 dark:text-m-slate-6",
312+
native_button=False,
313+
),
314+
to=ai_builder_pages.integrations.mcp_overview.path,
274315
)
275316

276317

@@ -474,11 +515,11 @@ def get_toc(source, href, component_list=None):
474515
env["__xd"] = xd
475516

476517
# Get the content of the document.
477-
source = source.content
518+
doc_content = source.content
478519

479520
# Get the blocks in the source code.
480521
# Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock)
481-
blocks = xd.get_blocks(source, href)
522+
blocks = xd.get_blocks(doc_content, href)
482523

483524
content_pieces = []
484525
for block in blocks:
@@ -502,7 +543,7 @@ def get_toc(source, href, component_list=None):
502543
headings.append((1, "API Reference"))
503544
for component_tuple in component_list:
504545
headings.append((2, component_tuple[1]))
505-
return headings
546+
return headings, doc_content
506547

507548

508549
def docpage(
@@ -617,13 +658,21 @@ def wrapper(*args, **kwargs) -> rx.Component:
617658
links.append(rx.fragment())
618659

619660
toc = []
661+
doc_content = None
620662
if not isinstance(contents, rx.Component):
621663
comp = contents(*args, **kwargs)
622664
else:
623665
comp = contents
624666

625-
if isinstance(comp, tuple):
626-
toc, comp = comp
667+
if isinstance(comp, tuple) and len(comp) == 2:
668+
first, second = comp
669+
# Check if first is (toc, doc_content) from get_toc
670+
if isinstance(first, tuple) and len(first) == 2:
671+
toc, doc_content = first
672+
comp = second
673+
else:
674+
# Legacy format: (toc, comp)
675+
toc, comp = first, second
627676

628677
show_right_sidebar = right_sidebar and len(toc) >= 2
629678
return rx.box(
@@ -720,9 +769,18 @@ def wrapper(*args, **kwargs) -> rx.Component:
720769
)
721770
for level, text in toc
722771
],
723-
class_name="flex flex-col gap-y-1 list-none shadow-[1.5px_0_0_0_var(--m-slate-4)_inset] dark:shadow-[1.5px_0_0_0_var(--m-slate-9)_inset]",
772+
id="toc-navigation",
773+
class_name="flex flex-col gap-y-1 list-none shadow-[1.5px_0_0_0_var(--m-slate-4)_inset] dark:shadow-[1.5px_0_0_0_var(--m-slate-9)_inset] max-h-[80vh]",
774+
),
775+
rx.el.div(
776+
feedback_button_toc(),
777+
copy_to_markdown(text=doc_content)
778+
if doc_content
779+
else None,
780+
ask_ai_chat(),
781+
class_name="flex flex-col mt-1.5 justify-start",
724782
),
725-
class_name="flex flex-col justify-start gap-y-4 max-h-[80vh] overflow-y-auto sticky top-4",
783+
class_name="flex flex-col justify-start gap-y-4 overflow-y-auto sticky top-4",
726784
),
727785
class_name=(
728786
"w-full h-full"
@@ -732,7 +790,6 @@ def wrapper(*args, **kwargs) -> rx.Component:
732790
" mt-[90px]",
733791
)
734792
),
735-
id="toc-navigation",
736793
),
737794
class_name=(
738795
"w-[240px] h-screen sticky top-0 shrink-0 hidden xl:block"

0 commit comments

Comments
 (0)