Repository navigation
feat: render conditional styling in formula cells and previews - #610
Merged
Merged
Conversation
Reviewer's GuideThe PR introduces structured styled text runs for formula values, propagates them through evaluation, formatting, caching, and cell state while preserving plain-text behavior for data operations, and renders the styling in formula cells and editor previews. It adds comprehensive unit, component, cache, and end-to-end regression coverage for conditional styling and live persistence. Sequence diagram for conditional formula styling and renderingsequenceDiagram
actor User
participant Editor as FormulaEditor
participant Evaluator as evaluateFormulaCell
participant Cache as FormulaResultCache
participant Cell as FormulaCell
participant Renderer as FormulaTextContent
User->>Editor: paste conditional formula
Editor->>Evaluator: evaluateFormulaCell
Evaluator->>Evaluator: styleText
Evaluator->>Cache: cache styled result
Evaluator-->>Editor: text and runs
Editor->>Renderer: render preview with runs
User->>Cell: close editor
Cell->>Cache: read evaluated result
Cache-->>Cell: plain text and runs
Cell->>Renderer: render formula cell with runs
User->>Cell: change source values
Cell->>Evaluator: evaluateFormulaCell
Evaluator-->>Cell: updated runs
Cell->>Renderer: render default or red text
Flow diagram for threshold-based formula stylingflowchart TD
Inputs[Done and In progress values] --> Conversion[round conversion percentage]
Conversion --> Threshold{Conversion > 90}
Threshold -->|yes| Red[style formatted value red]
Threshold -->|no| Default[formatted value with default color]
Red --> Runs[structured text runs]
Default --> Runs
Runs --> Display[Formula cell and editor preview]
Runs --> Plain[plain text for comparison sorting filtering export]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Description
Formula
style()previously returned plain text, soif(Conversion > 90, style(format(Conversion), "red"), format(Conversion))displayed every conversion in the default color. Preserve style runs through evaluation and caching, and render them in Formula cells and editor previews. Values above 90 are now red; exactly 90 keeps the default color.The implementation supports text/background colors and bold, italic, underline, strikethrough, and code styles, plus selective
unstyle(). Formatting survives conditionals, variables, concatenation,format,join, andrepeat. Plain text remains the value used for comparisons, sorting, filtering, copying, and export.Tests
The reporter's
notion_formula_conversion_test_data.csvis included unchanged. The CSV Playwright BDD scenario populates all 12 rows, pastes the conversion formula, and checks actual computed text colors, editor preview, live transitions across the threshold, and persistence after reload.All 23 options (five text formats, nine text colors, nine backgrounds) now have explicit individual browser coverage in formula-conditional-styling.feature. Each is applied and cleared through the editor, with strict assertions in both preview and saved cell. Every text leaf must match the expected computed foreground, background, font weight, italic style, decoration, font family and corner radius; an adjacent plain run must stay unstyled. A third scenario checks combined formatting, selective/full removal and color overrides. Engine tests assert exact style metadata for every token; renderer tests check exact emitted styles/classes and clearing.
91: actualrgb(33, 35, 42), expected redrgb(204, 78, 78).TZ=UTC, and the formula cell/editor UI suite passed 27 tests.c(missing background and 4px corner radius). The renderer was restored byte-for-byte before the passing rerun.pnpm lint(TypeScript and ESLint), BDD generation, and separate typed BDD-step lint/format checks passed.Run the focused browser regression against the configured test server with:
Feature Preview
Actual screenshots captured during the failing and passing Playwright runs using the supplied CSV.
Before — failing color assertion:
91,95, and100are still painted in the default color.After — passing regression: the four rows above 90 (
91,95,100,91) are red. Both rows at exactly 90 retain the default color. This capture occurs before the scenario edits row 5 and verifies reload.Checklist