Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add custom login background image and filter #1885

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

hexart
Copy link
Contributor

@hexart hexart commented Feb 11, 2025

Feature Description

This PR introduces the ability to customize the login page background image and apply image filters, providing more flexible UI customization options for Chainlit applications.

Screenshot

example: login_page_image_filter = "sepia-[1] hue-rotate-[310deg] blur-[2px]"
2025-02-13 21 27 49

Implementation Details

  • Added login_page_image and login_page_image_filter to the configuration return in backend/chainlit/auth/__init__.py
  • Add usage description in backend/chainlit/config.py
  • Updated type definitions in libs/react-client/types/config.ts
  • Added export function generateFilterStyle in frontend/src/lib/utils.ts for consistent filter processing
  • Modified frontend/src/pages/Login.tsx to support custom image and filter

Key Improvements

  • Added support for custom login page background image
  • Implemented dynamic CSS filter generation
  • Created a versatile utility function generateFilterStyle for filter parsing

Utility Function Benefit

The generateFilterStyle function in utils.ts provides a significant advantage beyond the login page:

  • Can be reused across different components requiring CSS filter parsing
  • Supports both light and dark mode filters
  • Provides a centralized, type-safe method for filter configuration

Usage Example

// In Login.tsx or any other component
const { lightFilter, darkFilter } = generateFilterStyle(config?.ui?.login_page_image_filter);

Configuration Format

# In .chainlit/config.toml
login_page_image = "/public/custom-background.jpg"
login_page_image_filter = "dark:brightness-[0.5] light:grayscale-[0.7]"

Technical Details

  • Implemented flexible filter parsing
  • Supports filter types:
    • brightness
    • contrast
    • opacity
    • grayscale
    • blur
    • saturate
    • sepia
    • hue-rotate
    • invert
  • Compatible with Tailwind CSS dynamic class generation

@hexart hexart marked this pull request as ready for review February 12, 2025 01:33
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request frontend Pertains to the frontend. labels Feb 12, 2025
@hexart hexart marked this pull request as draft February 12, 2025 01:49
@hexart hexart marked this pull request as ready for review February 12, 2025 02:18
@hexart hexart marked this pull request as draft February 13, 2025 08:00
…boundary

- Restore UI configuration return in auth/__init__.py
- Add overflow-hidden to login page image container
- Ensure backend UI configuration is properly transmitted
@hexart hexart marked this pull request as ready for review February 13, 2025 13:35
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Pertains to the frontend. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant