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(config): Config the font-family of chat content #5179

Merged
merged 2 commits into from
Aug 3, 2024

Conversation

frostime
Copy link
Contributor

@frostime frostime commented Aug 3, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

  • 在设置中添加了「聊天字体」项目,用来设置在聊天过程中,markdown 文字的显示字体
  • 默认置空:使用全局字体;可填入 CSS font-family 字段来设置对话字体
  • 添加了对应的 I18n

📝 补充信息 | Additional Information

实现方案和 fontSize 相同,均是给 Markdown 组件添加内联属性;如果设置的 fontFamily 为空,则默认使用 inherit

效果如下:

image

image

Summary by CodeRabbit

  • New Features

    • Introduced a customizable font family setting in the chat interface, allowing users to select their preferred font style.
    • Added input fields in the Settings component for users to specify the desired font family.
    • Enhanced localization support to provide font family settings in multiple languages, improving usability for diverse user bases.
  • Bug Fixes

    • Adjusted text area resizing functionality to ensure visual consistency with the selected font family.
  • Documentation

    • Updated locale files to include details on font family customization across various languages.

Copy link

vercel bot commented Aug 3, 2024

@frostime is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 3, 2024

Walkthrough

The recent updates introduce a customizable fontFamily feature across various components and locale settings within the application. This enhancement allows users to personalize the chat interface visually, improving the overall user experience. By integrating localized strings and modifying components to accept the new font property, the changes promote greater flexibility in styling, accommodating diverse user preferences.

Changes

Files Change Summary
app/components/chat.tsx Added fontFamily from config for flexible chat styling.
app/components/exporter.tsx Introduced fontFamily prop in ImagePreviewer to enhance text rendering customization.
app/components/markdown.tsx Added optional fontFamily prop for Markdown styling, with default settings.
app/components/settings.tsx Implemented input field for fontFamily, allowing user configuration in settings.
app/locales/ar.ts Added FontFamily section with localized strings for chat font settings.
app/locales/bn.ts Introduced FontFamily with localized chat font settings for Bengali.
app/locales/cn.ts Added FontFamily section for Chinese locale with chat font customization options.
app/locales/cs.ts Introduced support for FontFamily customization in Czech locale.
app/locales/de.ts Added FontFamily section to German locale for chat font settings.
app/locales/en.ts Introduced FontFamily entries for English locale, enhancing customization options.
app/locales/es.ts Added FontFamily section for Spanish locale with chat font guidance.
app/locales/fr.ts Introduced FontFamily settings in French locale, improving user interface options.
app/locales/id.ts Added FontFamily section for Indonesian localization, enriching customization.
app/locales/it.ts Introduced FontFamily settings in Italian localization for chat font customization.
app/locales/jp.ts Added FontFamily section for Japanese locale, enhancing user customization.
app/locales/ko.ts Introduced FontFamily object for Korean localization with chat font settings.
app/locales/no.ts Added FontFamily section for Norwegian locale, improving font customization.
app/locales/pt.ts Introduced FontFamily entries in Portuguese locale, enhancing user interface.
app/locales/ru.ts Added FontFamily section for Russian locale, offering font customization options.
app/locales/sk.ts Introduced FontFamily object in Slovak locale for chat font settings.
app/locales/tr.ts Added FontFamily section for Turkish locale, enhancing customization capabilities.
app/locales/tw.ts Introduced FontFamily entries for Traditional Chinese localization, improving chat options.
app/locales/vi.ts Added FontFamily section in Vietnamese locale for customized chat font.
app/store/config.ts Introduced fontFamily property in DEFAULT_CONFIG for application-wide customization.
app/utils.ts Updated autoGrowTextArea to set fontFamily, enhancing text area resizing consistency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsComponent
    participant Config
    participant ChatComponent

    User->>SettingsComponent: Specifies fontFamily
    SettingsComponent->>Config: Updates fontFamily
    Config->>ChatComponent: Applies new fontFamily setting
    ChatComponent->>User: Renders chat with custom font
Loading

🐇
In the land of hops and play,
A new font style comes to stay.
In chats we’ll cheer, with colors bright,
Custom fonts bring pure delight!
So let your text dance, twist, and twirl,
As we celebrate our font-filled world!
🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d9e407f and 8ec6acc.

Files selected for processing (25)
  • app/components/chat.tsx (3 hunks)
  • app/components/exporter.tsx (1 hunks)
  • app/components/markdown.tsx (2 hunks)
  • app/components/settings.tsx (1 hunks)
  • app/locales/ar.ts (1 hunks)
  • app/locales/bn.ts (1 hunks)
  • app/locales/cn.ts (1 hunks)
  • app/locales/cs.ts (1 hunks)
  • app/locales/de.ts (1 hunks)
  • app/locales/en.ts (1 hunks)
  • app/locales/es.ts (1 hunks)
  • app/locales/fr.ts (1 hunks)
  • app/locales/id.ts (2 hunks)
  • app/locales/it.ts (1 hunks)
  • app/locales/jp.ts (1 hunks)
  • app/locales/ko.ts (1 hunks)
  • app/locales/no.ts (1 hunks)
  • app/locales/pt.ts (1 hunks)
  • app/locales/ru.ts (1 hunks)
  • app/locales/sk.ts (1 hunks)
  • app/locales/tr.ts (1 hunks)
  • app/locales/tw.ts (1 hunks)
  • app/locales/vi.ts (1 hunks)
  • app/store/config.ts (1 hunks)
  • app/utils.ts (1 hunks)
Additional comments not posted (29)
app/store/config.ts (1)

36-36: Addition of fontFamily property to DEFAULT_CONFIG.

The new fontFamily property allows customization of the font used in the application. This enhances the flexibility of the configuration settings without altering the existing logic or control flow.

app/locales/no.ts (1)

69-74: Addition of FontFamily section to the Norwegian locale configuration.

The new FontFamily section includes a title, subtitle, and placeholder for the font family settings related to chat content. This addition enhances the locale's functionality by allowing users to specify a font type for chat content.

app/locales/ko.ts (1)

75-79: Addition of FontFamily section to the Korean locale configuration.

The new FontFamily section includes a title, subtitle, and placeholder for the font family settings related to chat content. This addition enhances the locale's functionality by allowing users to specify a font type for chat content.

app/utils.ts (1)

197-197: LGTM! The addition of the fontFamily style improves visual consistency.

The code change ensures that the measured text reflects the same font family as the input text area.

app/components/markdown.tsx (2)

235-235: LGTM! The addition of the fontFamily property enhances customization options.

The default value of "inherit" ensures that the component inherits the font from the parent element if no custom font is provided.


247-247: LGTM! The fontFamily style is correctly implemented in the component's inline style.

This ensures that the custom font is applied to the rendered Markdown component.

app/locales/cs.ts (1)

74-79: LGTM! The new FontFamily section enhances localization capabilities.

The entries are correctly added and translated, allowing users to set and customize the font used in chat content.

app/locales/vi.ts (1)

74-79: Localization strings for FontFamily look good.

The new FontFamily object is correctly localized and consistent with the rest of the file.

app/locales/tr.ts (1)

74-79: Localization strings for FontFamily look good.

The new FontFamily object is correctly localized and consistent with the rest of the file.

app/locales/it.ts (1)

74-79: Localization strings for FontFamily look good.

The new FontFamily object is correctly localized and consistent with the rest of the file.

app/locales/es.ts (1)

74-79: Translation and consistency check for FontFamily section.

The translations for the FontFamily section look correct and consistent with the rest of the file. The Title, SubTitle, and Placeholder properties are appropriately translated.

app/locales/ru.ts (1)

74-79: Translation and consistency check for FontFamily section.

The translations for the FontFamily section look correct and consistent with the rest of the file. The Title, SubTitle, and Placeholder properties are appropriately translated.

app/locales/jp.ts (1)

121-126: Translation and consistency check for FontFamily section.

The translations for the FontFamily section look correct and consistent with the rest of the file. The Title, SubTitle, and Placeholder properties are appropriately translated.

app/locales/de.ts (1)

74-79: LGTM!

The FontFamily section is correctly added and translated.

app/locales/ar.ts (1)

114-118: LGTM!

The FontFamily section is correctly added and translated.

app/locales/bn.ts (1)

139-144: LGTM!

The FontFamily section is correctly added and translated.

app/locales/fr.ts (1)

114-119: Accurate translations and consistent formatting.

The translations for the FontFamily section are accurate and consistent with the rest of the file. The formatting is also correct.

app/locales/id.ts (1)

143-148: Accurate translations and consistent formatting.

The translations for the FontFamily section are accurate and consistent with the rest of the file. The formatting is also correct.

app/locales/tw.ts (1)

156-160: Accurate translations and consistent formatting.

The translations for the FontFamily section are accurate and consistent with the rest of the file. The formatting is also correct.

app/locales/cn.ts (1)

159-163: Translation and consistency check for FontFamily object.

The translations for Title, SubTitle, and Placeholder appear accurate and consistent with the rest of the file. The addition is well-integrated.

app/locales/pt.ts (1)

156-161: Translation and consistency check for FontFamily object.

The translations for Title, SubTitle, and Placeholder appear accurate and consistent with the rest of the file. The addition is well-integrated.

app/locales/sk.ts (1)

158-163: Translation and consistency check for FontFamily object.

The translations for Title, SubTitle, and Placeholder appear accurate and consistent with the rest of the file. The addition is well-integrated.

app/locales/en.ts (1)

161-166: Add new locale entries for FontFamily

The new locale entries for FontFamily are correctly added, providing a title, subtitle, and placeholder for the font family setting.

app/components/exporter.tsx (1)

586-586: Add fontFamily property to Markdown component

The fontFamily property is correctly added to the Markdown component, allowing customization of the font family for the rendered text.

app/components/settings.tsx (1)

1319-1334: Add input field for configuring font family

The new input field for configuring the font family is correctly added, including a title, subtitle, and placeholder sourced from localization constants. The input field is bound to the config.fontFamily state, enabling real-time updates via the onChange event handler.

app/components/chat.tsx (4)

735-735: Initialize fontFamily variable.

The fontFamily variable is correctly initialized from the configuration.


1486-1486: Apply fontFamily to Markdown component.

The fontFamily variable is correctly applied to the Markdown component, allowing for the customization of the font family in chat messages.


1581-1581: Apply fontFamily to chat input textarea.

The fontFamily variable is correctly applied to the chat input textarea, allowing for the customization of the font family in the input field.


Line range hint 1598-1601: No changes in the Chat function.

The Chat function is unchanged and correctly wraps the _Chat component.

Copy link
Contributor

github-actions bot commented Aug 3, 2024

Your build has completed!

Preview deployment

@Dogtiti Dogtiti merged commit 764c0cb into ChatGPTNextWeb:main Aug 3, 2024
1 of 2 checks passed
This was referenced Oct 10, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 6, 2024
10 tasks
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.

2 participants