Skip to content

[ThemeProvider] Remove @ts-ignore comments, fix callback dependencies, and clean up vendor prefixes #646

@ravisuhag

Description

@ravisuhag

Summary

ThemeProvider is a custom theme management system with light/dark mode, localStorage persistence, and system preference detection. Has TypeScript safety issues, stale closure bugs, and obsolete CSS.

Improvements

1. Remove @ts-ignore comments (lines 95, 168)

Two TypeScript suppressions without explanation. Should use proper type assertions or fix the underlying type mismatch.

2. Fix missing useCallback dependencies

  • setTheme callback (line 125) is missing storageKey in dependency array — can cause stale closure bugs
  • handleMediaQuery callback (line 137) is missing enableSystem dependency

3. Fix invalid JavaScript string generation (line 278)

val construction uses name + "|| ''" which creates syntactically invalid JavaScript in the injected script.

4. Remove obsolete -o- vendor prefix

CSS transition disabling string includes Opera prefix (-o-transition) which is unnecessary in modern browsers.

5. Add onThemeChange callback

No event hook for applications that need to react to theme changes.

6. Centralize hardcoded default values

Defaults (style = 'modern', accentColor = 'indigo', grayColor = 'gray', storageKey = 'theme') are scattered. Consider named constants.

Files

  • packages/raystack/raystack/components/theme-provider/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions