Skip to content

SW-1431: Refactor code structure and enhance theme management across components#45

Open
owilliams-tetrascience wants to merge 37 commits intomainfrom
feat/chacn
Open

SW-1431: Refactor code structure and enhance theme management across components#45
owilliams-tetrascience wants to merge 37 commits intomainfrom
feat/chacn

Conversation

@owilliams-tetrascience
Copy link
Collaborator

@owilliams-tetrascience owilliams-tetrascience commented Mar 12, 2026

PR: Feature: Add shadcn/ui Integration & Components Library Refactor

Summary

This PR introduces comprehensive shadcn/ui integration to the TetraScience UI Kit, replacing custom component implementations with a modern, production-ready component library. The update includes a complete registry configuration, multiple shadcn components, and the addition of essential dependencies for a robust component ecosystem.

Key Changes

🎨 New shadcn/ui Setup

  • components.json - Added shadcn/ui configuration with radix-nova style preset
  • registry.json - Complete component registry with 60+ UI components exported for distribution
  • skills-lock.json - Added shadcn skill locking for AI agent management

🎯 Added Components

  • Core UI components: Button, Input, Select, Card, Badge, Alert, Dialog, Sheet, Drawer
  • Form components: Field, InputGroup, InputOTP, Checkbox, RadioGroup, Switch, Slider
  • Navigation: Breadcrumb, Sidebar, Tabs, Pagination, NavigationMenu
  • Data Display: Table, Avatar, Skeleton, Spinner, Progress, Chart
  • Overlays: Dialog, Sheet, Drawer, AlertDialog, Popover, Tooltip, HoverCard
  • Advanced: Combobox, Command, DropdownMenu, ContextMenu, Carousel, Accordion
  • Plus 30+ additional utility and composite components

📦 New Dependencies

  • @base-ui/react - Headless UI primitives
  • lucide-react - Icon library (default)
  • recharts - Data visualization
  • sonner - Toast notifications
  • cmdk - Command menu library
  • embla-carousel-react - Carousel component
  • class-variance-authority - CSS class composition
  • date-fns - Date utilities
  • react-day-picker - Calendar input
  • input-otp - OTP input handling
  • radix-ui - Primitives for accessible components
  • next-themes - Dark mode support
  • tailwindcss & @tailwindcss/vite - Styling framework (v4.2.1)
  • tailwind-merge - Class name merging
  • react-resizable-panels - Resizable panel layouts
  • vaul - Drawer library

🎭 Storybook Updates

  • Added Storybook theme configuration with TetraScience branding
  • manager.ts - Theme synchronization for dark/light modes
  • preview.ts - Integration of TooltipProvider and Toaster
  • Light & Dark theme files with company branding
  • Custom theme CSS for better documentation UX
  • New storybook/public assets

🗑️ Removed Legacy Code

  • Deleted custom Button, Badge, Card, Checkbox, and ButtonControl components
  • Removed custom Dropdown, ErrorAlert components
  • Removed custom Icon asset files (replaced by lucide-react)
  • Removed legacy color.css and font.css files
  • Cleaned up SCSS component files
  • Removed legacy Storybook configuration

📋 Configuration Updates

  • package.json - Updated with new dependencies and tools
  • tsconfig.json - Updated path aliases for new structure
  • .agents/skills/shadcn/ - Added comprehensive shadcn skill documentation
    • SKILL.md - Complete feature guide and best practices
    • cli.md - CLI commands reference
    • customization.md - Theming guide
    • rules/ - Component composition, styling, and form rules
    • mcp.md - MCP server setup
    • agents/openai.yml - AI agent configuration
    • evals/ - AI evaluation test cases

📖 Documentation

  • Comprehensive shadcn/ui skill documentation
  • Best practices for component composition
  • Dark mode and theming setup
  • CLI command reference
  • AI agent integration guide (MCP)

Migration Guide

For Developers

  1. Replace custom component imports with shadcn components
  2. Update styling from inline SCSS to Tailwind CSS classes
  3. Use semantic color tokens (e.g., bg-primary, text-muted-foreground)
  4. Follow new component composition patterns documented in .agents/skills/shadcn/

For Storybook

  • New theme setup with auto dark/light mode toggle
  • Better visual parity with TetraScience branding
  • Improved component documentation

Component Mapping

Old Component New shadcn Component
Button Button
Badge Badge
Card Card
Checkbox Checkbox
ButtonControl IconButton / Button
Dropdown Select / Combobox
ErrorAlert Alert
Icon lucide-react icons

Benefits

✅ Production-ready components with accessibility built-in
✅ Reduced maintenance burden (community-maintained)
✅ Better TypeScript support and type safety
✅ Consistent design system across all components
✅ Built-in dark mode support
✅ Extensive customization via CSS variables
✅ Active community and regular updates

Testing

  • All existing component tests should be updated to use new shadcn components
  • New component registry entries tested via Storybook
  • Storybook theme synchronization verified

Notes

  • Breaking changes: Component import paths have changed
  • Legacy custom components are fully deprecated
  • All styling should now use Tailwind CSS classes
  • Color system now uses CSS variables for semantic colors

Checklist:

  • All tests updated for new components
  • Documentation updated for new API
  • Storybook stories created/migrated
  • Color palette](#)

@owilliams-tetrascience owilliams-tetrascience requested a review from a team as a code owner March 12, 2026 16:50
@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ts-lib-ui-kit-storybook Ready Ready Preview, Comment Mar 16, 2026 3:32pm

Request Review

…oved readability, maintainability, and build times
- Implemented CodeEditor component with support for multiple languages and themes.
- Added SCSS styling for CodeEditor.
- Created stories for CodeEditor showcasing various use cases including default, light mode, and interactive examples.
- Introduced TDPLink component for navigation with context provider and utility functions for constructing TDP URLs.
- Updated existing stories for AlertDialog, Dialog, Drawer, and Sheet to enhance documentation parameters.
- Refactored index.ts to include new components and removed unused exports.
- Adjusted tsconfig.json to remove isolatedModules setting.
- Implemented a new hook `usePlotlyTheme` to manage Plotly theme colors based on the document's dark mode class.
- Removed the old CSS file `index.css` and replaced it with a more modular approach.
- Updated component imports in `index.ts` to reflect new paths.
- Deleted unused `main.tsx` and SCSS files to streamline the codebase.
- Adjusted Tailwind CSS variables for dark mode to improve color contrast.
- Removed the old theme provider and related types to simplify theming.
- Cleaned up TypeScript configuration by removing obsolete path aliases.
- Changed appPreviewBg color in the dark theme from #11183D to #212948.
- Introduced a new story for ComponentExample showcasing various UI components.
- Removed the old ComponentExample implementation.
- Updated TdpSearch styles to use new color variables and removed unnecessary font-family declarations.
- Refactored TdpSearchServer story to align with new design tokens.
- Deleted unused example and chart components.
- Removed global styles from index.scss and adjusted index.ts exports for better organization.
- Updated tailwind.css to use oklch color values for improved color management.
…le files

- Added missing imports for components in various story files.
- Moved imports to maintain consistency and readability in component files.
- Removed redundant imports and ensured proper usage of React and utility functions.
- Updated state initialization in the useIsMobile hook for better clarity.
- Adjusted Vite configuration for improved plugin management.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@blee-tetrascience blee-tetrascience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — Recommendations

### 1. Bump version to 1.0.0

This PR is a full breaking change — 50+ previously-exported symbols are removed, component APIs are incompatible (e.g. Button variant values changed, Table went from data-driven to raw HTML wrappers, Card became compound components), and the CSS variable namespace changed entirely. Every existing data app consumer will break on upgrade.

The ^0.3.0 pinning in downstream apps accidentally prevents auto-upgrade, but semver clarity is essential. This should ship as 1.0.0 to signal the breaking change explicitly.

Sorry, Claude went a little crazy with the comments on Friday. I don't think we version bump to 1.0.0 is warranted (yet). We can discuss this with the group but I think keeping this package below 1.0.0 (given it's still a bit "unstable") is fine and we can just bump the minor version for now. Open to discussion though

(Remaining recommendations are posted as inline comments on specific files below.)

@@ -1,12 +1,14 @@
import { CodeEditor } from "@atoms/CodeEditor";
import { Modal } from "@atoms/Modal";
import React, { useState } from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix Dialog/Modal control pattern

This component renders <DialogContent> without wrapping it in a <Dialog> root, relying on the consumer to provide the wrapper. But the component's story wires open state independently of the Dialog's internal state, so:

  1. Clicking the trigger opens the dialog via DialogTrigger, but onCancel only updates local React state — the dialog won't actually close on cancel/ESC/overlay click.
  2. The open prop passed in the story is never consumed by the component interface.

Recommend either:

  • (a) Make this component own its <Dialog> and accept open/onOpenChange props, or
  • (b) Rename to PythonEditorDialogContent and document that consumers must provide the controlled <Dialog> wrapper.

Same pattern issue exists in AssistantModal — it manually checks if (!open) return null instead of using Dialog's built-in open/close mechanism.

@@ -1,4 +1,4 @@
@use "../../../styles/variables.scss";
@use "../../styles/variables.scss";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix orphaned CSS variable references

The old colors.scss (--grey-*, --blue-*, --black-*, --white-*) is no longer imported — src/index.scss was deleted and the new entry point is src/index.css (Tailwind-based). But 20+ files still reference the old variables, which will resolve to undefined at runtime → invisible text, missing borders, broken charts.

This file references var(--grey-200), var(--grey-50), var(--grey-800). Other affected files include:

  • src/components/composed/Sidebar/Sidebar.tsxvar(--white-100), var(--white-50)
  • src/components/composed/Navbar/Navbar.tsxvar(--grey-400)
  • src/components/composed/CodeScriptEditorButton/CodeScriptEditorButton.tsxvar(--grey-400)
  • src/components/composed/tdp-link.tsxvar(--theme-primary), var(--blue-600)
  • src/components/composed/AssistantModal/AssistantModal.tsxvar(--black-50), var(--blue-900), var(--blue-600)
  • All chart SCSS files via variables.scsscolors.scss

Either migrate all remaining references to the new Tailwind/CSS variable system, or re-include colors.scss in the build so old variables are still defined.

…wind CSS classes

- Updated Navbar component to use Tailwind CSS for styling instead of styled-components.
- Refactored ProtocolConfiguration component to utilize Tailwind CSS for layout and styling.
- Modified ProtocolYamlCard to replace styled-components with Tailwind CSS classes.
- Adjusted PythonEditorModal and its story to remove styled-components in favor of Tailwind CSS.
- Refactored Sidebar component to eliminate styled-components and implement Tailwind CSS.
- Updated TDPLink component to remove styled-components and use Tailwind CSS for styling.
- Refactored CodeEditor component to replace styled-components with Tailwind CSS classes.
- Removed unused styled-components from input-group and sidebar components.
- Updated yarn.lock to reflect changes in dependencies and versions.
…seTheme with useCodeEditorTheme in CodeEditor and Toaster components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants