Styling from design system - #5
Open
anna-follestad-4ss wants to merge 10 commits into
Open
anna-follestad-4ss wants to merge 10 commits into
anna-follestad-4ss wants to merge 10 commits into
Conversation
added 10 commits
September 8, 2026 10:49
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain in fork CI authentication and unrestricted asset serving, alongside moderate dependency, token, and test gaps.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates dashboard styling to use the 4Subsea design-system package, including Plotly themes, CSS tokens, asset serving, validation tests, documentation, and CI authentication.
Changes:
- Replaces hardcoded styling values with design-system tokens.
- Adds packaged CSS serving and token regression tests.
- Updates dependencies, CI configuration, and styling documentation.
File summaries
| File | Summary and review notes |
|---|---|
tests/test_style_tokens.py |
Adds hardcoded-style checks. Moderate issues: Python font families and RGB values are not fully checked, and the font-token check accepts arbitrary var(...) values. |
src/theme.py |
Registers the external Plotly theme. |
src/assets/css/main.css |
Maps application styles to design-system tokens. Moderate issue: --radius usages remain without a local declaration. |
src/app.py |
Serves design-system CSS assets. Critical issue: unrestricted filenames can expose package files. Moderate issue: the asset route lacks a test for successful stylesheet delivery. |
requirements.txt |
Adds the design-system dependency. Moderate issue: the VCS dependency is not pinned to a branch, tag, or commit. |
README.md |
Documents the design-system styling integration. |
CLAUDE.md |
Updates styling conventions. |
.github/workflows/ci.yml |
Configures dependency authentication. Critical issue: forked pull requests cannot access the required secret and will fail during dependency installation. |
Review details
Suppressed comments (6)
.github/workflows/ci.yml:33
- This writes the access token into the global git config and leaves it there for the later
blackandpyteststeps. Because those steps execute PR-controlled code, a test or imported module can read~/.gitconfigand exfiltrateDESIGN_ACCESS_TOKEN; scope the rewrite to the install step and remove it with a trap before running checks.
git config --global url."https://x-access-token:${DESIGN_ACCESS_TOKEN}@github.com/".insteadOf "https://github.com/"
src/app.py:56
- The new route is the only way the browser can load
colors_and_type.css, but the app tests never request it. A wrong package directory or missing packaged asset would therefore return 404 while pytest still passes, leaving every page without the design-system tokens. Add a Flask test-client assertion for the stylesheet response (including a successful status/content type).
@app.server.route(f"{DESIGN_SYSTEM_URL_PREFIX}/<path:filename>")
def design_system_static(filename):
return flask.send_from_directory(DESIGN_SYSTEM_DIR, filename)
src/assets/css/main.css:35
- The only
--radiusdeclaration was removed from:root, but.visual,.slicer, and the modebar still useborder-radius: var(--radius). Unless the external stylesheet happens to export this exact variable, those declarations become invalid and the intended rounded corners disappear; keep an app-local alias to the design-system radius token or update the uses to the package's actual token.
--gap: var(--space-4);
tests/test_style_tokens.py:64
- The README says this guard covers hard-coded colors and font families in both CSS and Python, but the Python test only searches for hex colors. A new Python figure/component can reintroduce a literal
font.familyand all tests still pass, so the stated styling policy is not actually enforced; add a Python font-family check or narrow the documentation to CSS.
@pytest.mark.parametrize("path", _py_files(), ids=lambda p: p.relative_to(SRC))
def test_python_has_no_hardcoded_colors(path):
violations = _matches(path, HEX_COLOR)
tests/test_style_tokens.py:54
- The guard treats any
var(as a valid font token, so a declaration such asfont-family: var(--color), Arialwould pass even though it does not use a font token and still hardcodes a family. Match the declaration against the expected--font-...token instead.
if "font-family" in line and "var(" not in line:
tests/test_style_tokens.py:64
RGB_FUNCis defined specifically for color detection, but the Python test only appliesHEX_COLOR. A future Pythonrgba(...)/rgb(...)literal would therefore bypass the new hardcoded-color guard despite the test's documented purpose; includeRGB_FUNCin this check.
violations = _matches(path, HEX_COLOR)
- Files reviewed: 7/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+30
to
+33
| DESIGN_ACCESS_TOKEN: ${{ secrets.DESIGN_ACCESS_TOKEN }} | ||
| run: | | ||
| echo "token length: ${#DESIGN_ACCESS_TOKEN}" | ||
| git config --global url."https://x-access-token:${DESIGN_ACCESS_TOKEN}@github.com/".insteadOf "https://github.com/" |
Comment on lines
+54
to
+56
| @app.server.route(f"{DESIGN_SYSTEM_URL_PREFIX}/<path:filename>") | ||
| def design_system_static(filename): | ||
| return flask.send_from_directory(DESIGN_SYSTEM_DIR, filename) |
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.
What changed
Why
The styling was based on the current (July 2026) version of 4subsea styling, but hardcoded and so fixed to that version. We want the template repo to reflect actual latest version of the 4subsea style library, so that python dashboards are compliant with the company style.
Definition of done
CI covers the first two. See
CONTRIBUTING.mdfor why each is here.pytestpassesblackis clean.env.example, not hardcoded (unless it'sa documented, deliberate simplification - see README)
CLAUDE.mdupdated if this establishes a new convention,README.mdif itchanges how to run, refresh or deploy anything