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

Implement full and custom width conversation view options #35

Merged
merged 27 commits into from
Jul 14, 2024

Conversation

itsmartashub
Copy link
Owner

@itsmartashub itsmartashub commented Jun 13, 2024

1. Chat Width Customization [#1, #37]:

  • Add a settings checkbox/switch that allows users to set a full width for the chat area.
  • Add a settings option that allows users to set a custom width for the chat area.
  • Implement a slider where users can specify the desired width as a percentage of the chat width.
  • Ensure that the chat area dynamically adjusts to the specified width, providing a real-time preview of the changes.
  • Change the edit state icon position for user chats avoiding its cutting when increasing the chats width
  • Add reset button for all width options (chats, prompt field, sync prompt)
  • Cross page consistency (storage saving)

2. Prompt Field Width Customization [#37]:

  • Similarly, provide a settings option for customizing the width of the textarea prompt where users type their messages.
  • Allow users to set a custom width as a percentage, to suit their typing preferences.
  • Ensure that the chat area dynamically adjusts to the specified width, providing a real-time preview of the changes.
  • Cross page consistency (storage saving)

3. Sync Feature for Prompt Field [#38]:

  • Introduce a sync option for the textarea prompt width, implemented as a switch/checkbox.
  • When enabled, the textarea prompt width automatically follows the chat width, providing a consistent layout.
  • If disabled, the custom prompt width settings become active, allowing users to set their preferred width independently from the chat width.
  • Add a lock icon indicator on the prompt message sync custom width which will dynamically appears based on the state of the prompt sync switch value
  • Cross page consistency (storage saving)

4. Implement responsive full-width adjustment for chat bubbles and prompt textarea when resizing window [#39]

  • Only add the event listener for resizing if the user has made changes to the chat width options. If the user hasn't touched any custom options or full-width settings, the resizing event should not be triggered
  • Detect when the screen size is <= 768px
  • When the screen size meets this condition, apply a style that sets the chat bubbles and prompt textarea to full width.
  • Ensure that the full-width adjustment is applied smoothly during resizing, providing a seamless user experience.
  • ❗When the screen size is greater than 768px and the interface is being resized, remove the full-width adjustment and reset to the default or previously chosen width options. So first, I have to detect if the user change the default preferences.
  • Use debounce fn to prevent unnecessary resizing events and ensure smooth adjustments.

Closes: #1, #37, #38, #39

- Start working on the chat full-width feature
- Implement basic UI with switch checkboxes

Changes summary:
- Initiated the development of the chat full-width feature:
  - Implemented a basic UI with switch checkboxes to toggle the full-width mode for chats.
- Improve the full-width chat toggle by setting the `chat-bubble-full-width` class on checked
- Note: Saving the setting for future page loads and across different pages is not yet implemented

Changes summary:
- Improved the full-width chat toggle behavior:
  - Set the `chat-bubble-full-width` class on checked, providing a visual indication of the selected mode.
  - Note: The setting is not yet saved for future page loads or across different pages.
… var instead of a class

- Improve the logic for toggling full-width chat bubbles by utilizing a CSS variable instead of a class
- This approach ensures that the setting is correctly applied only when chat bubbles are present, avoiding potential errors

Changes summary:
- Optimized the logic for toggling full-width chat bubbles:
  - Utilize a CSS variable (`--chat-bubble-full-width`) to control the full-width setting, providing a more robust and error-free implementation.
  - This approach ensures that the setting is correctly applied only when chat bubbles are present on the page, avoiding potential errors and improving the user experience.
- Save the full-width chat settings into storage to apply chosen settings across all pages and page reloads

Changes summary:
- Added the ability to persist the full-width chat settings:
  - Save the user's chosen settings into storage, ensuring that the selected full-width mode is applied consistently across all pages and retained during page reloads.
- Set the `checked` attribute of the full-width chat checkbox based on the stored value
- This ensures that the checkbox accurately reflects the user's chosen setting across platform restarts

Changes summary:
- Synchronized the full-width chat checkbox with the stored value:
  - Set the `checked` attribute based on the stored full-width chat setting, ensuring that the checkbox accurately reflects the user's chosen preference across platform restarts and page reloads.
… the chat's width

- Make the `prompt-textarea` width sync with the chat's width
- Fix the edit icon in user chat bubbles to be visible when chat bubbles are at 90% width

Changes summary:
- Improved UI synchronization:
  - Synchronized the width of the `prompt-textarea` with the chat's width for a consistent appearance.
  - Ensured the edit icon in user chat bubbles remains visible when chat bubbles are set to 90% width, providing users with editing capabilities.
@itsmartashub itsmartashub linked an issue Jun 13, 2024 that may be closed by this pull request
3 tasks
@itsmartashub itsmartashub self-assigned this Jun 13, 2024
@itsmartashub itsmartashub changed the title Full-width conversation view option #1 feat(chat-full-width): Full-width conversation view option (#1) Jun 13, 2024
…al `svg` icon

- Add a hover state for the full-width option in the settings
- Include the actual full-width SVG icon

Changes summary:
- Enhanced the full-width option in the settings:
  - Added a hover state to provide visual feedback when hovering over the full-width option.
  - Included the actual full-width SVG icon, improving the user interface and providing a clearer representation of the feature.
@itsmartashub
Copy link
Owner Author

itsmartashub commented Jun 13, 2024

Fix edit icon disappearance in full-width mode

In the new UI, when the full-width option is enabled, the edit icon for user chats disappears due to the restricted width of the user chat element. This pull request aims to fix this issue by repositioning the edit icon and ensuring it remains visible and accessible to users. Additionally, we will address the overflow issue by applying overflow: visible to the user chat element, while thoroughly testing for any potential layout breaks caused by this change.

  • Add CSS vars for repositioning the edit icon to make it easily editable via JS in full width.
  • Reposition the edit icon to ensure it remains visible and accessible to users.
  • Apply overflow: visible to the user chat element to address the overflow issue.
  • ❗Thoroughly test the new layout for any potential breaks, especially in elements near the user chat, as the ChatGPT dev team likely had a reason for the previous overflow-x-hidden setting.
  • Ensure that the fix is compatible with various screen sizes and device types.

…t icon being cropped/invisible

- Make user chat bubbles also 100% width when full width mode is enabled
- Fix the edit icon being cropped and invisible by repositioning it to the right and bottom corner

Changes summary:
- Improved the design of user chat bubbles in full-width mode:
  - User chat bubbles now also occupy 100% width when full-width mode is enabled, providing a consistent appearance with GPT chat bubbles.
  - Repositioned the edit icon to the right and bottom corner to ensure visibility
…e chat's width

- Unsync the `prompt-textarea` width from the chat's width
- Consider making this behavior optional in future updates

Changes summary:
- Adjusted the width synchronization of the `prompt-textarea`:
  - The `prompt-textarea` width is now independent of the chat's width, providing a consistent input field size.
  - Consider making this behavior optional in future updates to allow users to choose their preferred textarea width.
@NeeRaj-2401
Copy link

NeeRaj-2401 commented Jun 14, 2024

hello @itsmartashub , i have some sugestions regarding the chat width implementation,

  1. i cant see edit msg icon on my msg
  2. can we have option something like slider to customize the width as per user's choice (with a min and max predefined)

@itsmartashub
Copy link
Owner Author

itsmartashub commented Jun 14, 2024

  1. Hmm, it looks like the prompt field in your screenshot is synchronized with the chat width, which makes me think you're not using the latest pushed full-chat-width version. In the most recent pushed version, I restyled the edit icon to be visible and on the right bottom side of the user chat (when in full width mode). I think it's more convenient there because the Cancel and Submit edit state buttons are immediately next to it.

image

  1. As I mentioned, I definitely plan to introduce custom width options, and I'm actually working on custom width sliders right now, and it's going great, lol 🥲

image

- Finish the design of range input sliders for custom chat bubble width

Changes summary:
- Completed the design of range input sliders used for adjusting custom chat bubble width:
  - Improved the visual appearance of the sliders for a more polished and user-friendly experience.
@NeeRaj-2401
Copy link

Aah ok my bad, apologies :(
Its looks good, thanks 🙌

- Add a custom width slider for the `prompt-textarea`

Changes summary:
- Implemented a custom width slider for the `prompt-textarea`:
  - Allows users to adjust the width of the textarea independently from chat bubble width.
- Bring back the option to toggle full-width mode for all chats
- Note: This requires additional fixes and calculations, especially with custom widths. Reset buttons will also be implemented to restore default options.

Changes summary:
- Reintroduced the option to toggle full-width mode for all chats:
  - Provides users with the ability to enable or disable full-width mode for all chat bubbles.
  - ❗ TODO: Additional fixes and calculations are required, especially when considering custom widths.
  - ❗ TODO: Reset buttons will be implemented to allow users to easily restore default options.
@NeeRaj-2401
Copy link

hello @itsmartashub , i did notice a small behaviour of chat-full-width implementation, it does maintain the selected width % even after smaller device breakpoint which shouldnt be the case

- Implement "Sync Textarea with Chat Width" logic to synchronize prompt textarea width with chat bubbles
- Add "Reset All Widths" buttons to easily restore default width settings for chat bubbles and prompt textarea

Changes summary:
- Enhanced width customization options:
  - Introduced the ability to synchronize the prompt textarea width with the width of chat bubbles, providing a consistent user experience.
  - Added "Reset All Widths" buttons to allow users to conveniently restore the default width settings for both chat bubbles and the prompt textarea.
@itsmartashub
Copy link
Owner Author

hello @itsmartashub , i did notice a small behaviour of chat-full-width implementation, it does maintain the selected width % even after smaller device breakpoint which shouldnt be the case

Hi there, dear @NeeRaj-2401. Yap, I'm aware of that. Just I've got a lot on my plate these days and not a lot of free time to focus on the extension.

Also, since this extension is primarily for the desktop versions, I tend to work in a similar way. So, I always make sure everything is working properly on the desktop versions first, and then once I'm sure everything is tested, I move on to mobile (smaller breakpoints).

In this case, the full/custom width feature is far from finished, so mobile is even further away.

I hope you don't mind me asking, but I'm curious about why you think the currently selected width should be different at different breakpoints?

@NeeRaj-2401
Copy link

NeeRaj-2401 commented Jun 29, 2024

I hope you don't mind me asking, but I'm curious about why you think the currently selected width should be different at different breakpoints?

The only reason 😅

- Refactor and fix issues related to custom chat bubble and prompt textarea widths
- Implement proper synchronization between chat bubble width and prompt textarea width
- Fix issues with locking the textarea width to chat widths

Changes summary:
- Overhauled the width customization logic:
  - Refactored and fixed issues related to custom chat bubble and prompt textarea widths.
  - Implemented proper synchronization between chat bubble width and prompt textarea width, ensuring a consistent user experience.
  - Addressed and resolved issues with locking the textarea width to chat widths.
- Fix user chat bubble width behavior to match GPT chat bubbles
- Ensure the edit icon is visible and accessible for user chat bubbles

Changes summary:
- Corrected the width behavior of user chat bubbles to match the width of GPT chat bubbles, ensuring a consistent user experience.
- Ensured the edit icon for user chat bubbles is visible and accessible, providing users with the ability to edit their messages.
- Apply the DRY (Don't Repeat Yourself) principle by eliminating code duplication and improving code reusability

Changes summary:
- Applied the DRY (Don't Repeat Yourself) principle:
  - Eliminated code duplication to improve maintainability and reduce redundancy.
  - Improved code reusability by extracting common functionality into reusable functions or components.
- Add a lock icon indicator on the textarea message sync switch to show when it is locked to chat widths
- The lock icon dynamically appears based on the state of the textarea sync switch

Changes summary:
- Added a visual indicator for the textarea message sync switch:
  - A lock icon is displayed when the textarea width is locked to chat widths, providing a clear indication of the current synchronization state.
  - The lock icon dynamically appears or disappears based on the state of the textarea sync switch, offering users a straightforward way to understand the synchronization behavior.
… and checkbox styling

- Enhance the style of the lock indicator and width switches for full-width chat options
- Add proper icons for the full-width chat switches

Changes summary:
- Improved the design of the full-width chat options:
  - Enhanced the style of the lock indicator and width switches, providing a more polished appearance.
  - Added distinct icons for the full-width chat switches, making the options clearer and more visually appealing.
…sues

- Change percentage values to REM units where appropriate
- Fix the initial state of the `textarea-sync` switch to ensure it starts as expected

Changes summary:
- Corrected unit inconsistencies by changing percentage values to REM units where appropriate, ensuring consistent sizing across different screen sizes and font sizes.
- Addressed an issue with the initial state of the `textarea-sync` switch, ensuring it starts in the expected default state.
@itsmartashub itsmartashub changed the title feat(chat-full-width): Full-width conversation view option (#1) Full and custom width conversation view options (#1) Jul 12, 2024
@itsmartashub itsmartashub changed the title Full and custom width conversation view options (#1) Full and custom width conversation view options Jul 12, 2024
@itsmartashub itsmartashub changed the title Full and custom width conversation view options Implement full and custom width conversation view options Jul 12, 2024
@itsmartashub itsmartashub added Feature A proposal for a new feature or an enhancement Status: WIP Work In Progress labels Jul 12, 2024
- Make new css var for max-width to separate `max-width` and `width` for user chat bubbles
- Fix user chat bubble width to match the content width, ensuring it doesn't become wider than necessary
- Make user chat bubbles full width when the full chat width option is toggled
- Set user chat bubble width to 70% when adjusted chat width via the custom width slider

Changes summary:
- Improved the width calculation for user chat bubbles:
  - Introduced separate `max-width` and `width` variables to better control the width behavior.
  - Fixed an issue where user chat bubbles could become wider than necessary; now, the width matches the content width.
  - User chat bubbles will be full width when the full chat width option is enabled.
  - Set user chat bubble width to 70% when adjusted via the custom width slider, providing a clear distinction from GPT chat bubbles.
@itsmartashub
Copy link
Owner Author

I hope you don't mind me asking, but I'm curious about why you think the currently selected width should be different at different breakpoints?

The only reason 😅

I understand that. But what if someone uses the extension on tablets or phones and wants the width to be custom, say, 85% instead of 100%? If I reset the width to 100% at the tablet/phones breakpoint, this feature wouldn't make sense on smaller devices/breakpoints, right? After all, you suggested the full-width feature (and there shouldn't be such "problems" with dynamic width), if I'm not mistaken. This slider customization is just a bonus.

But I can certainly look into what I can do when the user resizes the window if that would help you. If you have a better idea than changing the widths on the window resizing event to solve this, please suggest it.

…39)

- Implement a new resizing function to make chat bubbles and the prompt textarea full width on smaller screens (breakpoint < 768px)
- Reset to default or previously chosen width options on larger screens
- Note: The responsive width adjustment is not saved, so on page refresh, the options won't remain full width

Changes summary:
- Added a responsive width adjustment feature:
  - On smaller screens (breakpoint < 768px), chat bubbles and the prompt textarea are automatically set to full width for improved mobile experience.
  - On larger screens, the width settings reset to default or previously chosen options, ensuring a balanced layout for desktop users.
  - Note: The responsive width adjustment is not saved, so on page refresh, the options won't remain full width.
…h adjustment

- Improve the responsive width adjustment logic:
  - The resize event listener is now added only when chat width settings differ from defaults.
  - Full-width behavior on resize applies only if chat width settings have been modified.
  - If the user resets the widths, the resize listener is removed.
  - The code automatically detects changes to chat width settings by comparing with default values, eliminating the need for manual flags.

Changes summary:
- Optimized the responsive width adjustment logic:
  - Reduced unnecessary event listeners by adding the resize listener only when chat width settings deviate from defaults.
  - Ensured full-width behavior on resize is triggered only when chat width settings have been intentionally modified by the user.
  - Removed the resize listener when the user resets the widths, reducing redundant code execution.
  - Implemented automatic detection of changes to chat width settings by comparing with default values, simplifying the logic and improving performanc
- Main changes:
  - Introduced a configuration object for constants and default values.
  - Improved error handling (with some TODOs remaining for user-friendly messages).
  - Adopted modern JS features like optional chaining.
  - Refactored code for better modularization and organization.
  - Enforced consistent use of `const` and `let`.
  - Enhanced naming conventions and code structure.

- `renderSwitch` improvements:
  - Utilized template literals for string concatenation.
  - Employed default parameter syntax for optional parameters.
  - Implemented input sanitization to prevent XSS attacks.
  - Enhanced accessibility with ARIA attributes.
  - Laid the groundwork for internationalization (actual implementation requires a translation function).
  - Used more semantic HTML structure.

Changes summary:
- Overhauled the structure and organization of the `mainAssets.js` file:
  - Introduced a configuration object for centralizing constants and default values, improving maintainability.
  - Enhanced error handling for more robust code (with some TODOs remaining for user-friendly error messages).
  - Leveraged modern JavaScript features like optional chaining for cleaner code.
  - Refactored functions for better modularization and organization, improving code readability.
  - Enforced consistent use of `const` and `let` for variable declaration.
  - Adopted improved naming conventions and code structure for clearer code logic.

- Enhanced the `renderSwitch` function:
  - Utilized template literals for more readable and maintainable string concatenation.
  - Employed default parameter syntax for optional parameters, reducing function complexity.
  - Implemented input sanitization to prevent potential XSS attacks, enhancing security.
  - Incorporated ARIA attributes to improve accessibility for assistive technologies.
  - Laid the foundation for internationalization, though actual translation requires a separate translation function.
  - Utilized more semantic HTML structure for improved code semantics and accessibility.
- Remove unused JavaScript files to reduce repository size and improve maintainability

Changes summary:
- Removed unused JavaScript files, reducing clutter and improving the overall maintainability of the codebase.
… All`

- Remove resettable items from storage when using the "Reset All Widths" option to relieve storage usage

Changes summary:
- Optimized storage usage:
  - Removed resettable items from storage when the "Reset All Widths" option is used, reducing storage utilization and improving long-term maintainability.
- Comment out development testing code to prevent accidental execution

Changes summary:
- Commented out development testing code to ensure it is not accidentally executed in production, reducing potential issues and maintaining code integrity.
- Fix the unit of the custom width slider tooltip to display percentages (%) instead of REM

Changes summary:
- Corrected the unit displayed in the custom width slider tooltip:
  - The tooltip now correctly displays percentages (%) instead of REM units, providing a clearer indication of the slider value.
@itsmartashub itsmartashub changed the base branch from master to main July 14, 2024 21:03
@itsmartashub itsmartashub merged commit 4adae76 into main Jul 14, 2024
2 checks passed
@itsmartashub itsmartashub deleted the feat/chat-full-width branch October 10, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A proposal for a new feature or an enhancement Status: WIP Work In Progress
Projects
None yet
2 participants