instruction
stringlengths
0
1k
input
stringlengths
1
1k
output
stringlengths
10
6.51k
rx.box( *breadcrumbs, class_name="flex flex-row items-center gap-[5px] lg:gap-4 overflow-hidden", ), rx.box( rx.icon(tag="chevron-down", size=14, class_name="!text-slate-9"), class_name="p-[0.563rem] lg:hidden flex", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children.
headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need
if not hasattr(comp, "children") or comp.children is None: return []
-center gap-[5px] lg:gap-4 overflow-hidden", ), rx.box( rx.icon(tag="chevron-down", size=14, class_name="!text-slate-9"), class_name="p-[0.563rem] lg:hidden flex", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return []
for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.
headings = []
lg:gap-4 overflow-hidden", ), rx.box( rx.icon(tag="chevron-down", size=14, class_name="!text-slate-9"), class_name="p-[0.563rem] lg:hidden flex", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = []
return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".j
for child in comp.children: headings.extend(get_headings(child))
ize=14, class_name="!text-slate-9"), class_name="p-[0.563rem] lg:hidden flex", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings
def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied.
def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings
ss_name="p-[0.563rem] lg:hidden flex", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None):
component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. heading
from pcweb.flexdown import xd
x", ), class_name="relative z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd
component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component
component_list = component_list or []
e z-10 flex flex-row justify-between items-center gap-4 lg:gap-0 border-slate-4 bg-slate-1 mt-12 mb-6 lg:mb-8 p-[0.5rem_1rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or []
# Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API
component_list = component_list[1:]
rem_0.5rem_1rem] lg:p-0 border-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code.
env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1]))
env = source.metadata
rder-b lg:border-none w-full" + rx.cond( HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata
# Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings
env["__xd"] = xd
HostingBannerState.show_banner, " lg:mt-[175px]", " lg:mt-[119px]", ), ) def get_headings(comp): """Get the strings from markdown component.""" if isinstance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document.
# Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = No
source = source.content
tance(comp, mistletoe.block_token.Heading): heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock)
content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the web
blocks = xd.get_blocks(source, href)
: heading_text = "".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href)
for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and
content_pieces = []
"".join( token.content for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = []
content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Re
for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content)
ontent for token in comp.children if hasattr(token, "content") ) return [(comp.level, heading_text)] # Recursively get the strings from the children. if not hasattr(comp, "children") or comp.children is None: return [] headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks:
# Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the pa
if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue
headings = [] for child in comp.children: headings.extend(get_headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need
content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseu
content = block.get_content(env)
headings(child)) return headings def get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content)
doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that re
content = "\n".join(content_pieces)
ef get_toc(source, href, component_list=None): from pcweb.flexdown import xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces)
# Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ d
doc = mistletoe.Document(content)
port xd component_list = component_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers.
if len(component_list): headings.append((1, "API Reference")) for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap
headings = get_headings(doc)
onent_list or [] component_list = component_list[1:] # Generate the TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc)
for component_tuple in component_list: headings.append((2, component_tuple[1])) return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A f
if len(component_list): headings.append((1, "API Reference"))
he TOC # The environment used for execing and evaling code. env = source.metadata env["__xd"] = xd # Get the content of the document. source = source.content # Get the blocks in the source code. # Note: we must use reflex-web's special flexdown instance xd here - it knows about all custom block types (like DemoBlock) blocks = xd.get_blocks(source, href) content_pieces = [] for block in blocks: if ( not isinstance(block, flexdown.blocks.MarkdownBlock) or len(block.lines) == 0 or not block.lines[0].startswith("#") ): continue # Now we should have all the env entries we need content = block.get_content(env) content_pieces.append(content) content = "\n".join(content_pieces) doc = mistletoe.Document(content) # Parse the markdown headers. headings = get_headings(doc) if len(component_list): headings.append((1, "API Reference"))
return headings def docpage( set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the te
for component_tuple in component_list: headings.append((2, component_tuple[1]))
set_path: str | None = None, t: str | None = None, right_sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """
title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_f
path = get_path(contents) if set_path is None else set_path
sidebar: bool = True, page_title: str | None = None, pseudo_right_bar: bool = False, ): """A template that most pages on the reflex.dev site should use. This template wraps the webpage with the navbar and footer. Args: set_path: The path to set for the sidebar. t: The title to set for the page. right_sidebar: Whether to show the right sidebar. page_title: The full title to set for the page. If None, defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path
@functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev
title = contents.__name__.replace("_", " ").title() if t is None else t
defaults to `{title} · Reflex Docs`. pseudo_right_bar: Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """
from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-cente
from pcweb.components.docpage.navbar import navbar
Whether to show a pseudo right sidebar (empty space). Returns: A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar
from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full",
from pcweb.components.docpage.sidebar import get_prev_next
A wrapper function that returns the full webpage. """ def docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next
from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none",
from pcweb.components.docpage.sidebar import sidebar as sb
f docpage(contents: Callable[[], Route]) -> Route: """Wrap a component in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb
sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name
from pcweb.components.hosting_banner import HostingBannerState
nt in a docpage template. Args: contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState
nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small te
sidebar = sb(url=path, width="300px")
contents: A function that returns a page route. Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px")
prev, next = get_prev_next(path) links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color",
nav_sidebar = sb(url=path, width="100%")
Returns: The final route with the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%")
links = [] if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ),
prev, next = get_prev_next(path)
h the template applied. """ path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path)
if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_nam
links = []
""" path = get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = []
links.append(rx.spacer()) if next: next_prev_name = ( next.alt_name_for_next_prev if next.alt_name_for_next_prev else next.names ) links.append( rx.box( rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"),
if prev: next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names ) links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1", ) ) else: links.append(rx.fragment())
= get_path(contents) if set_path is None else set_path title = contents.__name__.replace("_", " ").title() if t is None else t @functools.wraps(contents) def wrapper(*args, **kwargs) -> rx.Component: """The actual function wrapper. Args: *args: Args to pass to the contents function. **kwargs: Kwargs to pass to the contents function. Returns: The page with the template applied. """ from pcweb.components.docpage.navbar import navbar from pcweb.components.docpage.sidebar import get_prev_next from pcweb.components.docpage.sidebar import sidebar as sb from pcweb.components.hosting_banner import HostingBannerState sidebar = sb(url=path, width="300px") nav_sidebar = sb(url=path, width="100%") prev, next = get_prev_next(path) links = [] if prev:
links.append( rx.box( rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1", ) ) else: links.append(rx.frag
next_prev_name = ( prev.alt_name_for_next_prev if prev.alt_name_for_next_prev else prev.names )
rx.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1", ) ) else: links.append(rx.fragment()) links.append(rx.spacer())
toc = [] if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else: comp = contents if isinstance(comp, tuple): toc, comp = comp show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar),
if next: next_prev_name = ( next.alt_name_for_next_prev if next.alt_name_for_next_prev else next.names ) links.append( rx.box( rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment())
x.link( rx.box( get_icon( icon="arrow_right", transform="rotate(180deg)" ), "Back", class_name="flex flex-row justify-center lg:justify-start items-center gap-2 rounded-lg w-full", ), underline="none", href=prev.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1", ) ) else: links.append(rx.fragment()) links.append(rx.spacer()) if next:
links.append( rx.box( rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component):
next_prev_name = ( next.alt_name_for_next_prev if next.alt_name_for_next_prev else next.names )
else next.names ) links.append( rx.box( rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = []
if isinstance(comp, tuple): toc, comp = comp show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0" + rx.cond( Hos
if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else: comp = contents
links.append( rx.box( rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component):
else: comp = contents if isinstance(comp, tuple): toc, comp = comp show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0"
comp = contents(*args, **kwargs)
rx.link( rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else:
if isinstance(comp, tuple): toc, comp = comp show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0" + rx.cond( Hos
comp = contents
rx.box( "Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else: comp = contents
show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0" + rx.cond( HostingBannerState.show_banner, " mt-[90p
if isinstance(comp, tuple): toc, comp = comp
"Next", get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else: comp = contents if isinstance(comp, tuple):
show_right_sidebar = right_sidebar and len(toc) >= 2 return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0" + rx.cond( HostingBannerState.show_banner, " mt-[90p
toc, comp = comp
get_icon(icon="arrow_right"), class_name="flex flex-row lg:justify-start items-center gap-2 rounded-lg w-full self-end", ), underline="none", href=next.link, class_name="py-0.5 lg:py-0 rounded-lg lg:w-auto font-small text-slate-9 hover:!text-slate-11 transition-color", ), rx.text(next_prev_name, class_name="font-smbold text-slate-12"), class_name="flex flex-col justify-start gap-1 items-end", ) ) else: links.append(rx.fragment()) toc = [] if not isinstance(contents, rx.Component): comp = contents(*args, **kwargs) else: comp = contents if isinstance(comp, tuple): toc, comp = comp
return rx.box( navbar(), rx.el.main( rx.box( sidebar, class_name=( "w-full max-w-[300px] h-screen shrink-0 hidden lg:block z-10 " + rx.cond( HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), ), rx.box( rx.box( breadcrumb(path=path, nav_sidebar=nav_sidebar), class_name=( "px-0 xl:px-14 pt-0" + rx.cond( HostingBannerState.show_banner, " mt-[90px]", "",
show_right_sidebar = right_sidebar and len(toc) >= 2
HostingBannerState.show_banner, " mt-[146px]", " mt-[90px]", ) ), id="toc-navigation", ), class_name=( "w-[240px] h-screen sticky top-0 shrink-0 hidden xl:block" ), ) if show_right_sidebar and not pseudo_right_bar else rx.box( class_name="w-[180px] h-screen sticky top-0 shrink-0 hidden xl:block" ), class_name="flex justify-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), )
category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None ) if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"),
components = path.split("/")
how_banner, " mt-[146px]", " mt-[90px]", ) ), id="toc-navigation", ), class_name=( "w-[240px] h-screen sticky top-0 shrink-0 hidden xl:block" ), ) if show_right_sidebar and not pseudo_right_bar else rx.box( class_name="w-[180px] h-screen sticky top-0 shrink-0 hidden xl:block" ), class_name="flex justify-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/")
if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), cl
category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None )
toc-navigation", ), class_name=( "w-[240px] h-screen sticky top-0 shrink-0 hidden xl:block" ), ) if show_right_sidebar and not pseudo_right_bar else rx.box( class_name="w-[180px] h-screen sticky top-0 shrink-0 hidden xl:block" ), class_name="flex justify-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/") category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None )
return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-1
if page_title: return Route( path=path, title=page_title, component=wrapper, )
class_name="w-[180px] h-screen sticky top-0 shrink-0 hidden xl:block" ), class_name="flex justify-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/") category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None ) if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage
def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): format
class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color
class_name="flex justify-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/") category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None ) if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event
def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): format
def set_color(self, color: str): self.color = color
y-center mx-auto mt-0 max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/") category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None ) if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str):
def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): format
self.color = color
max-w-[94.5em] h-full min-h-screen w-full lg:px-10", ), class_name="flex flex-col justify-center bg-slate-1 w-full relative", on_mount=rx.call_script(right_sidebar_item_highlight()), ) components = path.split("/") category = ( " ".join( word.capitalize() for word in components[2].replace("-", " ").split() ) if len(components) > 2 else None ) if page_title: return Route( path=path, title=page_title, component=wrapper, ) return Route( path=path, title=f"{title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color
def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant
def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), )
title} · Reflex Docs" if category is None else title, component=wrapper, ) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), )
def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) else:
def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts)
) return docpage class RadixDocState(rx.State): """The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts
# Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not N
formatted_parts = []
"""The app state.""" color: str = "tomato" @rx.event def set_color(self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items
# Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high
for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part)
self, color: str): self.color = color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair
# Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True:
if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}"
color def hover_item(component: rx.Component, component_str: str) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str):
# Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast,
formatted_part = f'{key}="{value}"'
rx.hover_card.root( rx.hover_card.trigger(rx.flex(component)), rx.hover_card.content( rx.el.button( get_icon(icon="copy", class_name="p-[5px]"), rx.text( component_str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else:
# Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True:
formatted_part = f"{key}={value}"
str, class_name="flex-1 font-small truncate", ), on_click=rx.set_clipboard(component_str), class_name="flex flex-row items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts)
def style_grid( component_used: rx.Component, component_used_str: str, variants: list, components_passed: rx.Component | str | None = None, disabled: bool = False, **kwargs, ) -> rx.Component: text_cn = "text-nowrap font-md flex items-center" return rx.box( rx.grid( rx.text("", size="5"), *[ rx.text(variant, class_name=text_cn + " text-slate-11") for variant in variants ], rx.text( "Accent", color=f"var(--{RadixDocState.color}-10)", class_name=text_cn, ), *[ hover_item( component=used_component( component_used=component_used, components_passed=components_passed, color_scheme=RadixDocState.color, variant=variant, high_contrast=False,
def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) else: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, )
er:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-[300px] text-slate-11 transition-bg cursor-pointer", ), ), ) def dict_to_formatted_string(input_dict): # List to hold formatted string parts formatted_parts = [] # Iterate over dictionary items for key, value in input_dict.items(): # Format each key-value pair if isinstance(value, str): formatted_part = f'{key}="{value}"' # Enclose string values in quotes else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component:
def style_grid( component_used: rx.Component, component_used_str: str, variants: list, components_passed: rx.Component | str | None = None, disabled: bool = False, **kwargs, ) -> rx.Component: text_cn = "text-nowrap font-md flex items-center" return rx.box( rx.grid( rx.text("", size="5"), *[ rx.text(variant, class_name=text_cn + " text-slate-11") for variant in variants ], rx.text( "Accent", color=f"var(--{RadixDocState.color}-10)", class_name=text_cn, ), *[ hover_item( component=used_component( component_used=component_used, components_passed=components_passed, color_scheme=RadixDocState.color, variant=variant, high_contrast=False,
if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) else: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, )
else: formatted_part = f"{key}={value}" # Non-string values as is # Append the formatted part to the list formatted_parts.append(formatted_part) # Join all parts with a comma and a space return ", ".join(formatted_parts) def used_component( component_used: rx.Component, components_passed: rx.Component | str | None, color_scheme: str, variant: str, high_contrast: bool, disabled: bool = False, **kwargs, ) -> rx.Component: if components_passed is None and disabled is False: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, )
def style_grid( component_used: rx.Component, component_used_str: str, variants: list, components_passed: rx.Component | str | None = None, disabled: bool = False, **kwargs, ) -> rx.Component: text_cn = "text-nowrap font-md flex items-center" return rx.box( rx.grid( rx.text("", size="5"), *[ rx.text(variant, class_name=text_cn + " text-slate-11") for variant in variants ], rx.text( "Accent", color=f"var(--{RadixDocState.color}-10)", class_name=text_cn, ), *[ hover_item( component=used_component( component_used=component_used, components_passed=components_passed, color_scheme=RadixDocState.color, variant=variant, high_contrast=False,
elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) else: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, )
s, ) elif components_passed is not None and disabled is False: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, **kwargs, ) elif components_passed is None and disabled is True: return component_used( color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) else: return component_used( components_passed, color_scheme=color_scheme, variant=variant, high_contrast=high_contrast, disabled=True, **kwargs, ) def style_grid( component_used: rx.Component, component_used_str: str, variants: list, components_passed: rx.Component | str | None = None, disabled: bool = False, **kwargs, ) -> rx.Component:
return rx.box( rx.grid( rx.text("", size="5"), *[ rx.text(variant, class_name=text_cn + " text-slate-11") for variant in variants ], rx.text( "Accent", color=f"var(--{RadixDocState.color}-10)", class_name=text_cn, ), *[ hover_item( component=used_component( component_used=component_used, components_passed=components_passed, color_scheme=RadixDocState.color, variant=variant, high_contrast=False, **kwargs, ), component_str=f"{component_used_str}(color_scheme={RadixDocState.color}, variant={variant}, high_contrast=False, {dict_to_formatted_string(kwargs)})", ) for variant in vari
text_cn = "text-nowrap font-md flex items-center"
"""The state for the navbar component."""
from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload,
import contextlib
"""The state for the navbar component.""" import contextlib
from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.r
from datetime import datetime
"""The state for the navbar component.""" import contextlib from datetime import datetime
import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status()
from typing import Optional
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional
import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True
import httpx
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx
from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx
import reflex as rx
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx
from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: ret
from httpx import Response
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response
from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_f
from sqlmodel import Field
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field
class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord messag
from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL
class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact
class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event
def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """ def _build_integration_request_message(self, form_data: dict) -> str: """B
def set_score(self, value: int): self.score = value
"""The state for the navbar component.""" import contextlib from datetime import datetime from typing import Optional import httpx import reflex as rx from httpx import Response from sqlmodel import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int):
def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """ def _build_integration_request_message(self, form_data: dict) -> str: """B
self.score = value
import Field from pcweb.constants import REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL class Feedback(rx.Model, table=True): email: Optional[str] feedback: str score: Optional[int] date_created: datetime = Field(default_factory=datetime.utcnow, nullable=False) page: str class FeedbackState(rx.State): """The state for feedback components.""" score: Optional[int] = None @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False
def _build_integration_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_
def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """
one @rx.event def set_score(self, value: int): self.score = value def _send_to_webhook(self, payload: dict, webhook_url: str) -> bool: """Send payload to webhook URL. Returns: True if successful, False otherwise """ try: with httpx.Client() as client: response: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """
@rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.err
def _build_integration_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """
nse: Response = client.post( webhook_url, json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """ def _build_integration_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission."""
# Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""",
feedback = form_data.get("feedback", "")
json=payload, ) response.raise_for_status() return True except httpx.HTTPError: return False def _build_feedback_message(self, form_data: dict) -> str: """Build Discord message for feedback form.""" current_page_route: str = self.router.page.raw_path email: str = form_data.get("email", "") feedback: str = form_data["feedback"] return f""" Contact: {email} Page: {current_page_route} Score: {"👍" if self.score == 1 else "👎"} Feedback: {feedback} """ def _build_integration_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation
# Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict):
if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, )
== 1 else "👎"} Feedback: {feedback} """ def _build_integration_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message
payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send
discord_message = self._build_feedback_message(form_data)
n_request_message(self, form_data: dict) -> str: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data)
success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = se
payload = {"text": discord_message}
tr: """Build Discord message for integration request form.""" request: str = form_data["request"] return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message}
if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message} success = self._send
success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL )
return f""" Integration Request: {request} """ @rx.event def handle_submit(self, form_data: dict): """Handle feedback form submission.""" feedback = form_data.get("feedback", "") # Validation if len(feedback) < 10 or len(feedback) > 500: return rx.toast.warning( "Please enter your feedback. Between 10 and 500 characters.", close_button=True, ) # Send to general webhook (suppressed errors) with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL )
yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file
if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, )
with contextlib.suppress(httpx.HTTPError) and httpx.Client() as client: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission."""
# Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
request = form_data.get("request", "")
ient: client.post( REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL, json=form_data, ) # Build and send Discord message discord_message = self._build_feedback_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation
# Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, )
t": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message
payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
discord_message = self._build_integration_request_message(form_data)
yload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data)
success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
payload = {"text": discord_message}
EBHOOK_URL ) if not success: return rx.toast.error( """An error occurred while submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message}
if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL )
e submitting your feedback. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, ) yield rx.toast.success( "Thank you for your feedback!", close_button=True, ) @rx.event def handle_integration_request(self, form_data: dict): """Handle integration request form submission.""" request = form_data.get("request", "") # Validation if len(request) < 10 or len(request) > 2000: return rx.toast.warning( "Please describe your integration request. Between 10 and 2000 characters.", close_button=True, ) # Build and send Discord message discord_message = self._build_integration_request_message(form_data) payload = {"text": discord_message} success = self._send_to_webhook( payload, REFLEX_DEV_WEB_GENERAL_FORM_FEEDBACK_WEBHOOK_URL )
yield rx.toast.success( "Thank you for your integration request!", close_button=True, )
if not success: return rx.toast.error( """An error occurred while submitting your request. If the issue persists, please file a Github issue or stop by our Discord.""", close_button=True, )
"""Code block components for documentation pages."""
import pcweb.styles.fonts as fonts from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language) def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a docume
import reflex as rx
"""Code block components for documentation pages.""" import reflex as rx
from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language) def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args:
import pcweb.styles.fonts as fonts
"""Code block components for documentation pages.""" import reflex as rx import pcweb.styles.fonts as fonts
@rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language) def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args: command: The command
from pcweb import styles
"""Code block components for documentation pages.""" import reflex as rx import pcweb.styles.fonts as fonts from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", )
def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args: command: The command to display. output: The output of the command. theme: The theme of the component. Returns: The styled command and its example output. """ return rx.vstack( rx._x.code_block( command, can_copy=True, border_radius=styles.DOC_BORDER_RADIUS, background="transparent", theme="ayu-dark", language="bash", code_tag_props={ "style": { "fontFamily": "inherit", } }, style=fonts.code, font_family="Source Code Pro", width="100%", ), rx._x.code_
def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language)
"""Code block components for documentation pages.""" import reflex as rx import pcweb.styles.fonts as fonts from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props):
return code_block(code=children[0], language=language) def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args: command: The command to display. output: The output of the command. theme: The theme of the component. Returns: The styled command and its example output. """ return rx.vstack( rx._x.code_block( command, can_copy=True, border_radius=styles.DOC_BORDER_RADIUS, background="transparent", theme="ayu-dark", language="bash", code_tag_props={ "style": { "fontFamily": "inherit", } }, style=fonts.code, font_family="Source Code Pro
language = props.get("language", "plain")
"""Code block components for documentation pages.""" import reflex as rx import pcweb.styles.fonts as fonts from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language)
def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args: command: The command to display. output: The output of the command. theme: The theme of the component. Returns: The styled command and its example output. """ return rx.vstack( rx._x.code_block( command, can_copy=True, border_radius=styles.DOC_BORDER_RADIUS, background="transparent", theme="ayu-dark", language="bash", code_tag_props={ "style": { "fontFamily": "inherit", } }, style=fonts.code, font_family="Source Code Pro", width="100%", ), rx._x.code_block( output, can_copy=False, border_radius="12px", background="transparent", theme="ayu-dark",
def code_block_markdown_dark(*children, **props): language = props.get("language", "plain") return code_block_dark(code=children[0], language=language)
"""Code block components for documentation pages.""" import reflex as rx import pcweb.styles.fonts as fonts from pcweb import styles @rx.memo def code_block(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative mb-4", ) @rx.memo def code_block_dark(code: str, language: str): return rx.box( rx._x.code_block( code, language=language, class_name="code-block", can_copy=True, ), class_name="relative", ) def code_block_markdown(*children, **props): language = props.get("language", "plain") return code_block(code=children[0], language=language) def code_block_markdown_dark(*children, **props):
return code_block_dark(code=children[0], language=language) def doccmdoutput( command: str, output: str, ) -> rx.Component: """Create a documentation code snippet. Args: command: The command to display. output: The output of the command. theme: The theme of the component. Returns: The styled command and its example output. """ return rx.vstack( rx._x.code_block( command, can_copy=True, border_radius=styles.DOC_BORDER_RADIUS, background="transparent", theme="ayu-dark", language="bash", code_tag_props={ "style": { "fontFamily": "inherit", } }, style=fonts.code, font_family="Source Code Pro", width="100%", ), rx._x.code_block( output, can_copy=False, border_radius="12px",
language = props.get("language", "plain")
"""Components for rendering code demos in the documentation."""
from typing import Any import reflex as rx import ruff_format from .code import code_block, code_block_dark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code
import textwrap
"""Components for rendering code demos in the documentation.""" import textwrap
import reflex as rx import ruff_format from .code import code_block, code_block_dark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ #
from typing import Any
"""Components for rendering code demos in the documentation.""" import textwrap from typing import Any
import ruff_format from .code import code_block, code_block_dark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets,
import reflex as rx
"""Components for rendering code demos in the documentation.""" import textwrap from typing import Any import reflex as rx
from .code import code_block, code_block_dark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with
import ruff_format
"""Components for rendering code demos in the documentation.""" import textwrap from typing import Any import reflex as rx import ruff_format
def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python": cod
from .code import code_block, code_block_dark
"""Components for rendering code demos in the documentation.""" import textwrap from typing import Any import reflex as rx import ruff_format from .code import code_block, code_block_dark
def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python": code = ruff_format.format_string(textwrap.dedent(code)).strip() # If needed, only display a subset of the lines. if lines is not None: code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip() # Create the code snippet. cb = code_block_dark if theme == "dark" else code_block return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = No
def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", )
e import code_block, code_block_dark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black.
# If needed, only display a subset of the lines. if lines is not None: code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip() # Create the code snippet. cb = code_block_dark if theme == "dark" else code_block return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = None, comp: rx.Component | None = None, context: bool = False, demobox_props: dict[str, Any] | None = None, theme: str | None = None, **props, ) -> rx.Component: """Create a documentation demo with code and output. Args: code: The code to render the component. state: Code for any state needed for the component. comp: The pre-rendered component. context: Whether to wrap the render code in a function. demobox_props: Props to apply to the demo box. theme: The theme for the code snippet. props: Addit
if language == "python": code = ruff_format.format_string(textwrap.dedent(code)).strip()
ark def docdemobox(*children, **props) -> rx.Component: """Create a documentation demo box with the output of the code. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python":
# If needed, only display a subset of the lines. if lines is not None: code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip() # Create the code snippet. cb = code_block_dark if theme == "dark" else code_block return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = None, comp: rx.Component | None = None, context: bool = False, demobox_props: dict[str, Any] | None = None, theme: str | None = None, **props, ) -> rx.Component: """Create a documentation demo with code and output. Args: code: The code to render the component. state: Code for any state needed for the component. comp: The pre-rendered component. context: Whether to wrap the render code in a function. demobox_props: Props to apply to the demo box. theme: The theme for the code snippet. props: Addit
code = ruff_format.format_string(textwrap.dedent(code)).strip()
de. Args: children: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python": code = ruff_format.format_string(textwrap.dedent(code)).strip() # If needed, only display a subset of the lines.
# Create the code snippet. cb = code_block_dark if theme == "dark" else code_block return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = None, comp: rx.Component | None = None, context: bool = False, demobox_props: dict[str, Any] | None = None, theme: str | None = None, **props, ) -> rx.Component: """Create a documentation demo with code and output. Args: code: The code to render the component. state: Code for any state needed for the component. comp: The pre-rendered component. context: Whether to wrap the render code in a function. demobox_props: Props to apply to the demo box. theme: The theme for the code snippet. props: Additional props to apply to the component. Returns: The styled demo. """ demobox_props = demobox_props or {} # Render the component if necessary. if comp is None: comp
if lines is not None: code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip()
n: The children to display. props: Additional props to apply to the box. Returns: The styled demo box. """ return rx.box( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python": code = ruff_format.format_string(textwrap.dedent(code)).strip() # If needed, only display a subset of the lines. if lines is not None:
# Create the code snippet. cb = code_block_dark if theme == "dark" else code_block return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = None, comp: rx.Component | None = None, context: bool = False, demobox_props: dict[str, Any] | None = None, theme: str | None = None, **props, ) -> rx.Component: """Create a documentation demo with code and output. Args: code: The code to render the component. state: Code for any state needed for the component. comp: The pre-rendered component. context: Whether to wrap the render code in a function. demobox_props: Props to apply to the demo box. theme: The theme for the code snippet. props: Additional props to apply to the component. Returns: The styled demo. """ demobox_props = demobox_props or {} # Render the component if necessary. if comp is None: comp
code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip()
x( *children, **props, class_name="flex flex-col p-6 rounded-xl overflow-x-auto border border-slate-4 bg-slate-2 items-center justify-center w-full", ) def doccode( code: str, language: str = "python", lines: tuple[int, int] | None = None, theme: str = "light", ) -> rx.Component: """Create a documentation code snippet. Args: code: The code to display. language: The language of the code. lines: The start/end lines to display. theme: The theme for the code snippet. Returns: The styled code snippet. """ # For Python snippets, lint the code with black. if language == "python": code = ruff_format.format_string(textwrap.dedent(code)).strip() # If needed, only display a subset of the lines. if lines is not None: code = textwrap.dedent( "\n".join(code.strip().splitlines()[lines[0] : lines[1]]) ).strip() # Create the code snippet.
return cb( code=code, language=language, ) def docdemo( code: str, state: str | None = None, comp: rx.Component | None = None, context: bool = False, demobox_props: dict[str, Any] | None = None, theme: str | None = None, **props, ) -> rx.Component: """Create a documentation demo with code and output. Args: code: The code to render the component. state: Code for any state needed for the component. comp: The pre-rendered component. context: Whether to wrap the render code in a function. demobox_props: Props to apply to the demo box. theme: The theme for the code snippet. props: Additional props to apply to the component. Returns: The styled demo. """ demobox_props = demobox_props or {} # Render the component if necessary. if comp is None: comp = eval(code) # Wrap the render code in a function if needed. if context: c
cb = code_block_dark if theme == "dark" else code_block