Add toggle_label field to AnalysisCardBase for custom subtitle expansion text#5124
Open
shrutipatel31 wants to merge 2 commits intofacebook:mainfrom
Open
Add toggle_label field to AnalysisCardBase for custom subtitle expansion text#5124shrutipatel31 wants to merge 2 commits intofacebook:mainfrom
shrutipatel31 wants to merge 2 commits intofacebook:mainfrom
Conversation
Summary: Matches the web UI change from D97406631 for notebook (Jupyter/Bento) rendering of Ax analysis cards. **Before**: Subtitles were hidden behind a clickable <details>/<summary> element with an info icon - users had to click to reveal the subtitle text. **After**: Subtitles are now shown as visible, secondary-styled text directly beneath the title, line-clamped to a single line. A "See more"/"See less" toggle appears automatically when the subtitle text overflows, allowing users to expand and collapse the full text. Key changes to html_card_template in analysis_card.py: - Replaced <details>/<summary> with always-visible <p class="card-subtitle"> using CSS -webkit-line-clamp: 2 - Added a "See more"/"See less" <button> toggle that is shown only when the subtitle is actually clamped (detected via scrollHeight > clientHeight in a requestAnimationFrame callback) - The inline script uses `document.currentScript.previousElementSibling` to locate its sibling card element and querySelector to find the subtitle and toggle within it, avoiding the need for unique DOM IDs or any Python-side bookkeeping - Removed the info icon CSS (content: "ℹ️") and hover-to-reveal interaction Differential Revision: D98690381
…ion text Summary: Adds a serializable `toggle_label: str` field to `AnalysisCardBase` that allows analyses to customize the subtitle expand/collapse toggle button text. When non-empty, `toggle_label` replaces the default "See more" text with a context-specific label (e.g., "Expand to see annotated parameters."). The field is persisted to both SQA and JSON storage backends, and used by the notebook HTML template for rendering. Changes: - Add `toggle_label` field + constructor param (default "") to AnalysisCardBase - Update notebook `_to_html()` to use `self.toggle_label or "See more"` - Add `toggle_label` nullable column to SQAAnalysisCard - Update SQA encoder/decoder (all 8 card-type callsites) - Update JSON encoder for both card and group dicts - Unit tests Differential Revision: D98738752
|
@shrutipatel31 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98738752. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5124 +/- ##
=======================================
Coverage 96.40% 96.41%
=======================================
Files 613 613
Lines 68142 68161 +19
=======================================
+ Hits 65694 65717 +23
+ Misses 2448 2444 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Adds a serializable
toggle_label: strfield toAnalysisCardBasethat allowsanalyses to customize the subtitle expand/collapse toggle button text.
When non-empty,
toggle_labelreplaces the default "See more" text witha context-specific label (e.g., "Expand to see annotated parameters.").
The field is persisted to both SQA and JSON storage backends, and used by
the notebook HTML template for rendering.
Changes:
toggle_labelfield + constructor param (default "") to AnalysisCardBase_to_html()to useself.toggle_label or "See more"toggle_labelnullable column to SQAAnalysisCardDifferential Revision: D98738752