Zero icon indicating copy to clipboard operation
Zero copied to clipboard

Shadcn Theming & Styling [added the requirements as stated] #883

Open Zedoman opened this issue 6 months ago • 5 comments

READ CAREFULLY THEN REMOVE

/claim #883

Remove bullet points that are not relevant.

PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.

  • Pull requests that do not follow these guidelines will be closed without review or comment.
  • If you use AI to write your PR description your pr will be close without review or comment.
  • If you are unsure about anything, feel free to ask for clarification.

Resolves: #883

Shadcn Theming & Styling — Complete Implementation

Description

This PR enhances the theming functionality of the application by implementing the remaining requirements for the "Shadcn Theming & Styling" feature. It introduces the ability for users to mark themes as public and display them in a new Theme Marketplace page, where users can copy public themes to their own collection. Additionally, it resolves a TypeScript error in the Connections page related to the useTRPC hook, ensuring proper typing of the trpc client, and adds a theme selection dropdown to the Connections page for managing connection-specific themes. UI/UX improvements were also made to the Appearance page to enhance the visual experience while maintaining its existing functionality. Also the created theme will get stored in the db.

Features Added Mark Themes as Public: Added a "Make Theme Public" toggle in the ThemeEditor component on the Appearance page, allowing users to mark themes as public. Public themes are visible in the Theme Marketplace for other users to discover and copy. Theme Marketplace Page: Created a new ThemeMarketplace.tsx page to list all public themes. Each public theme is displayed in a card with a preview of its primary color, the creator’s ID, and a "Copy Theme" button. Users can copy a public theme to their own collection, creating a new theme with the name <Original Name> (Copy). Theme Selection Dropdown in Connections Page: Added a theme selection dropdown to the Connections page, allowing users to assign a specific theme to each email connection. The dropdown includes a "Default" option to reset the theme and a list of the user’s themes with a preview of the primary color. Indicates the currently selected theme with a "Current" badge. TypeScript Fix for useTRPC: Resolved a TypeScript error ("Type 'never' has no call signatures") in the Connections page by properly typing the trpc client with the AppRouter type. Ensured the useTRPC hook provides a typed trpc client, fixing the issue with trpc.theme.getThemes.query. UI/UX Improvements: Enhanced the Appearance page with animations (using framer-motion) for adding and removing themes. Added a preview of the primary color next to each theme’s name in the "Custom Themes" section. Applied a gradient style to the "Create Theme" button and added hover effects to theme cards for a more engaging experience.


Type of Change

  • [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
  • [ ] ✨ New feature (non-breaking change which adds functionality)
  • [ ] 🎨 UI/UX improvement

Areas Affected

  • [ ] Email Integration (Gmail, IMAP, etc.)
  • [ ] User Interface/Experience
  • [ ] Data Storage/Management
  • [ ] API Endpoints

Testing Done

Describe the tests you've done:

  • [ ] Manual testing performed Mark Theme as Public: Toggled the "Make Theme Public" switch in the Appearance page and verified the isPublic field updates in the database. Confirmed the theme appears in the Theme Marketplace. Theme Marketplace: Navigated to the Theme Marketplace page and verified public themes are listed. Copied a public theme and confirmed a new theme is created with the correct name and isPublic: false. Theme Selection in Connections Page: Assigned a theme to a connection and verified the theme applies (via the /api/v1/connections/[id]/theme endpoint). Reset the theme to default and confirmed the themeId is set to null. Verified loading and empty states in the theme dropdown. Appearance Page Enhancements: Created and deleted themes to confirm animations work. Verified the primary color preview and hover effects.

Security Considerations

For changes involving data or authentication:

  • [ ] No sensitive data is exposed
  • [ ] Authentication checks are in place
  • [ ] Input validation is implemented

Checklist

  • [ ] I have read the CONTRIBUTING document
  • [ ] My code follows the project's style guidelines
  • [ ] I have performed a self-review of my code
  • [ ] I have commented my code, particularly in complex areas
  • [ ] I have updated the documentation
  • [ ] My changes generate no new warnings
  • [ ] All tests pass locally
  • [ ] Any dependent changes are merged and published

Screenshots/Recordings

https://github.com/user-attachments/assets/85a671c6-b2ec-422c-b50e-390949660b6c

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive theme management, including creation, editing, deletion, and copying of custom themes.
    • Added a Theme Marketplace for browsing and copying public themes.
    • Enabled per-connection theme selection and updating.
    • Integrated UI components for color picking, font selection, and theme editing.
    • Added support for marking themes as public, default, or favorites.
    • Dynamic application of theme styles throughout the app.
  • Bug Fixes

    • Improved type safety and clarity in theme-related components.
  • Style

    • Enhanced global CSS with theme variables, animations, and editor styles.
  • Chores

    • Updated dependencies and configuration for theme-related packages and plugins.
  • Database

    • Added new tables and migrations to support user themes, favorites, and theme associations.

Zedoman avatar Jun 16 '25 19:06 Zedoman

Walkthrough

This change implements a comprehensive theming system for the mail application. It introduces database tables, API endpoints, UI components, and settings pages for creating, editing, deleting, sharing, and applying custom themes. Users can manage colors, fonts, spacing, shadows, and more, set themes per connection, and browse or copy public themes.

Changes

File(s) / Group Change Summary
apps/mail/app/(routes)/settings/appearance/page.tsx
apps/mail/app/(routes)/settings/themes/page.tsx
apps/mail/app/(routes)/settings/themes/marketplace/page.tsx
apps/mail/app/(routes)/settings/connections/page.tsx
Added/updated UI for theme management, theme marketplace, per-connection theme selection, and CRUD operations for themes.
apps/mail/app/(auth)/login/login-client.tsx Added type definitions and integrated theme fetching logic.
apps/mail/app/+types/theme.ts
apps/mail/types/theme.ts
Introduced new Theme interfaces and default theme object.
apps/mail/components/theme/theme-editor.tsx
apps/mail/components/ui/color-picker.tsx
apps/mail/components/ui/font-selector.tsx
apps/mail/components/ui/range-input.tsx
apps/mail/components/ui/slider.tsx
Added new UI components for theme editing: color picker, font selector, range input, slider, and theme editor.
apps/mail/app/globals.css Added CSS variables, animations, and utility classes for theming and UI.
apps/mail/locales/en.json Added localization strings for theme management actions and confirmations.
apps/mail/package.json Added/updated dependencies for UI components and theming.
apps/mail/vite.config.ts
tsconfig.json
Configuration updates for build and module resolution.
apps/server/src/db/migrations/0029_eminent_theme.sql
apps/server/src/db/migrations/0030_exotic_elektra.sql
apps/server/src/db/migrations/meta/0029_snapshot.json
apps/server/src/db/migrations/meta/0030_snapshot.json
apps/server/src/db/migrations/meta/_journal.json
Database migrations and schema snapshots for theme tables, connections, favorites, and related entities.
apps/server/src/db/schema.ts Added theme, userFavoriteThemes tables; updated connection table.
apps/server/src/lib/utils.ts Added utility functions for authentication and connection retrieval.
apps/server/src/routes/v1/themes/route.ts
apps/server/src/routes/v1/themes/[id]/route.ts
apps/server/src/routes/v1/themes/copy/route.ts
apps/server/src/routes/v1/themes/default/route.ts
apps/server/src/routes/v1/themes/favorites/route.ts
apps/server/src/routes/v1/connections/[id]/theme/route.ts
Implemented REST API endpoints for theme CRUD, copying, setting default, managing favorites, and per-connection theme assignment.
apps/server/src/trpc/routes/themeRouter.ts
apps/server/src/trpc/index.ts
apps/server/src/trpc/trpc.ts
Added tRPC router and procedures for theme management and context extension.
packages/tailwind-config/tailwind.config.ts Extended Tailwind config for themeable tokens via CSS variables.
apps/server/package.json
apps/server/tsconfig.json
Added/updated dependencies and TypeScript options.
apps/mail/app/(routes)/layout.tsx Indentation/formatting only (no functional change).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant API
    participant DB

    User->>UI: Opens Appearance/Theme Settings
    UI->>API: Fetches user's themes (GET /api/v1/themes)
    API->>DB: Query themes by userId
    DB-->>API: Return themes
    API-->>UI: Return themes list
    User->>UI: Edits/creates theme (colors, fonts, etc.)
    UI->>API: Save theme (POST/PATCH /api/v1/themes)
    API->>DB: Insert/update theme record
    DB-->>API: Confirm save
    API-->>UI: Return saved theme
    User->>UI: Sets theme public or copies from marketplace
    UI->>API: Update/copy theme (PATCH/POST /api/v1/themes/copy)
    API->>DB: Copy/modify theme record
    DB-->>API: Confirm copy/update
    API-->>UI: Return new/updated theme
    User->>UI: Assigns theme to connection
    UI->>API: PATCH /api/v1/connections/[id]/theme
    API->>DB: Update connection's themeId
    DB-->>API: Confirm update
    API-->>UI: Return updated connection

Assessment against linked issues

Objective Addressed Explanation
Theme dropdown in connection screen for managing/creating themes (#883)
Customization of colors, fonts (Google fonts), spacing, shadows, radius, backgrounds (#883)
Save/manage/delete themes in database (#883)
Load theme for activeConnection (#883)
Mark theme as public for marketplace (#883)
Page to list/copy public themes (#883)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

  • Mail-0/Zero#564: Related changes to login-client.tsx including type definitions and theme fetching logic; both PRs modify login client components and improve type safety and data fetching.

Suggested reviewers

  • MrgSub

Poem

In the meadow of code where the themes now bloom,
Rabbits have painted with colors and room.
Fonts hop and skip, shadows swirl in delight,
Spacing and corners just feel so right.
Public or private, your palette’s your own—
Hop to the marketplace, let your style be shown!
🐇✨🎨


📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c8ddbd9e94789e83805a5921f0f8f522f1bbdd8 and 46ecd5f2d166a073e9e697dff7ab032f6e9c9df7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/mail/app/(routes)/layout.tsx (1 hunks)
  • apps/mail/app/globals.css (1 hunks)
  • apps/mail/locales/en.json (2 hunks)
  • apps/mail/package.json (3 hunks)
  • apps/mail/vite.config.ts (2 hunks)
  • apps/server/src/trpc/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/server/src/trpc/index.ts
  • apps/mail/vite.config.ts
  • apps/mail/app/(routes)/layout.tsx
  • apps/mail/package.json
  • apps/mail/locales/en.json
  • apps/mail/app/globals.css
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jun 16 '25 19:06 coderabbitai[bot]

@MrgSub Sir please check it once

Zedoman avatar Jun 16 '25 19:06 Zedoman

@MrgSub Sir please check it once

Please resolve CodeRabbit comments :)

MrgSub avatar Jun 17 '25 01:06 MrgSub

@MrgSub Sir please check it once

We don't use Next anymore, most of your work is using next patterns and libraries...

MrgSub avatar Jun 17 '25 01:06 MrgSub

Ok sir doing the changes.

Zedoman avatar Jun 17 '25 05:06 Zedoman