{% macro dropdown_end() %} {% endmacro %} {# Page Actions Dropdown - Split button with Edit action and dropdown for more options Usage: {{ page_actions_dropdown(edit_href="/edit/page") }} {{ page_action_item(text="Copy page", description="Copy page as Markdown for LLMs", icon="clipboard", click="copyMarkdown()") }} {{ dropdown_end() }} #} {% macro page_actions_dropdown(edit_href="", edit_text="Edit", show_edit=True, edit_external=False) %} {#- Split button: two frappe-ui gray-outline Buttons (size md) sharing one border box, so the pair matches Button's h-8 / rounded-4 / colour recipe while still reading as a single control. -#} {% set split_segment = "inline-flex items-center justify-center gap-2 shrink-0 h-8 text-base-medium text-[var(--ink-gray-8)] bg-[var(--surface-base)] active:bg-[var(--surface-gray-4)] transition-colors" %}
{% if show_edit %} {{ render_icon("edit", "w-4 h-4") }} {{ edit_text }} {% else %} {% endif %}
{#- Menu surface: frappe-ui Menu content + its p-1.5 group padding. -#}
{% endmacro %} {# Menu row geometry, straight from frappe-ui's ItemListRow (size sm) plus the Menu highlight colour. Every row in a page-actions menu uses it. #} {% set menu_row = "w-full flex items-center gap-2 min-h-7 px-2 py-1.5 rounded-4 text-base text-left text-[var(--ink-gray-7)] hover:bg-[var(--surface-alpha-gray-2)] transition-colors" %} {# Dropdown row that triggers downloadPage() and reflects the downloadInProgress state. Keeps the dropdown open while preparing the PDF so the loading state stays visible. #} {% macro download_action_item() %} {% endmacro %} {% macro page_action_item(text="", description="", icon="", href="", href_expr="", click="", target="") %} {% if click %} {% else %} {# href_expr reads window.location, which is not reactive: recompute on click so SPA nav gets the current URL, not the load-time one #} {% if icon %} {{ render_icon(icon, "text-[var(--ink-gray-5)]") }} {% endif %}
{{ text }} {% if target == "_blank" %} {{ render_icon("external-link", "w-3 h-3 shrink-0 text-[var(--ink-gray-4)]") }} {% endif %}
{% if description %}
{{ description }}
{% endif %}
{% endif %} {% endmacro %} {# Icon Renderer Helper Lucide icons come from the generated table (scripts/generate-public-lucide.mjs -> wiki/lucide_icons.json), the same pack and the same 1.5 stroke the SPA and the frappe-ui docs draw from. They used to be hand-copied SVGs here, which had quietly drifted to Heroicons for several glyphs — the magnifier, hamburger, check, list and clipboard were all a different shape from the docs'. `edit` is an alias for lucide's `pencil`; brand marks below have no lucide equivalent (the pack dropped them) so they stay inline. Names here must also be listed in CHROME_ICONS in scripts/generate-public-lucide.mjs, which is what puts them in the table. #} {% set LUCIDE_ICON_ALIASES = {"edit": "pencil"} %} {% set LUCIDE_CHROME_ICONS = [ "arrow-down", "arrow-left", "arrow-right", "arrow-up", "check", "chevron-down", "chevron-left", "chevron-right", "chevrons-up-down", "clipboard", "command", "corner-down-left", "download", "edit", "external-link", "file-text", "list", "loader", "menu", "moon", "moon-star", "panel-right-open", "pencil", "search", "sparkles", "sun", "x" ] %} {% macro render_icon(icon, extra_classes="") %} {#- The default w-4/h-4 only applies when the caller didn't size the icon itself. Concatenating both used to let the default win at equal specificity — `size-[18px]` next to `w-4 h-4` silently rendered 16px, because Tailwind emits `w-*`/`h-*` after an arbitrary `size-*`. -#} {% set sizing = namespace(given=false) %} {% for cls in extra_classes.split() %} {% if cls.startswith("size-") or cls.startswith("w-") or cls.startswith("h-") %} {% set sizing.given = true %} {% endif %} {% endfor %} {% set icon_base_classes = extra_classes if sizing.given else "w-4 h-4 " ~ extra_classes %} {% set lucide_name = LUCIDE_ICON_ALIASES.get(icon, icon) %} {% if icon in LUCIDE_CHROME_ICONS %} {{ lucide_svg("lucide-" ~ lucide_name, icon_base_classes) | safe }} {% elif icon == "claude" %} {% elif icon == "openai" %} {% elif icon == "t3" %} T3 {% elif icon == "perplexity" %} {% elif icon == "github" %} {# frappe-ui docs navbar GitHub mark (filled), copied as-is #} {% elif icon == "youtube" %} {% elif icon == "twitter" %} {% elif icon == "linkedin" %} {% elif icon == "discord" %} {% elif icon == "slack" %} {% elif icon == "facebook" %} {% elif icon == "instagram" %} {% elif icon == "reddit" %} {% endif %} {% endmacro %}