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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fef3c09
feat(chat-full-width): Initiate chat full-width feature (#1)
itsmartashub Jun 13, 2024
c613751
feat(chat-full-width): Add the full-width chat toggle logic
itsmartashub Jun 13, 2024
84a01c0
refactor(chat-full-width): Improve toggling full-w by utilizing a CSS…
itsmartashub Jun 13, 2024
584c098
feat(chat-full-width): Save the full-width chat settings into storage
itsmartashub Jun 13, 2024
ec1e40b
refactor(chat-full-width): Sync checkbox with stored value
itsmartashub Jun 13, 2024
87e3539
refactor(chat-full-width): Make the `prompt-textarea` width sync with…
itsmartashub Jun 13, 2024
a337386
feat(chat-full-width): Add a hover state for the FW option and the re…
itsmartashub Jun 13, 2024
bf449e8
refactor(chat-full-width): Make user chat also `100%` and fix the edi…
itsmartashub Jun 14, 2024
d48bffa
refactor(chat-full-width): Unsync the `prompt-textarea` width from th…
itsmartashub Jun 14, 2024
20c10b7
feat(custom-chat-width): Complete custom width slider design
itsmartashub Jun 14, 2024
5195916
feat(custom-width-textarea): Implement prompt textarea width slider
itsmartashub Jun 14, 2024
5f96c15
feat(chat-full-width): Bring back toggle full-width mode for all chats
itsmartashub Jun 14, 2024
0626032
feat(textarea-sync): Enhance width customization options
itsmartashub Jun 19, 2024
6885de2
refactor: Overhaul width customization
itsmartashub Jul 11, 2024
2a9cdeb
fix(chat-custom-width): Correct user chat bubble width and edit icon
itsmartashub Jul 11, 2024
7a08d29
refactor(chat-custom-width): Apply `DRY` principle
itsmartashub Jul 11, 2024
fcb9b81
feat(textarea-sync/lock-indicator): Add lock icon indicator
itsmartashub Jul 11, 2024
29d56c5
refactor(chat-full-width): Add proper icons. Improve locked indicator…
itsmartashub Jul 12, 2024
82cfb4f
fix(chat-custom-width): Correct unit and initial prompt sync state is…
itsmartashub Jul 12, 2024
59a8371
fix(chat-full-width): Improve user chat bubble width calculation
itsmartashub Jul 13, 2024
6e89b63
feat(chat-custom-width/window-resizing): Responsive width adjustment …
itsmartashub Jul 14, 2024
1340445
refactor(chat-custom-width/window-resizing): Optimize responsive widt…
itsmartashub Jul 14, 2024
be27c77
refactor(main-assets): Overhaul code structure
itsmartashub Jul 14, 2024
84ac040
chore(chat-custom-width/cleanup): Remove unused files
itsmartashub Jul 14, 2024
56ea483
refactor(chat-custom-width/storage): Optimize storage usage on `Reset…
itsmartashub Jul 14, 2024
d8c62cb
chore(chat-custom-width/testing): Remove dev testing code
itsmartashub Jul 14, 2024
4c4a48a
fix(chat-custom-width): Correct slider tooltip unit to be `%`
itsmartashub Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/js/app/components/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/js/app/components/renderButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function renderButton({ name, className, id, content, disabled = false }) {
return `
<button id="${id}" class="btn block relative text-center ${className}" ${disabled ? 'disabled' : ''}>
${content}
</button>
`
}
8 changes: 0 additions & 8 deletions src/js/app/components/renderFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,3 @@ export function renderFontBigCard({

// return cardHtml
// }

export function renderButton({ name, className, id, content, disabled = false }) {
return `
<button id="${id}" class="btn block relative text-center ${className}" ${disabled ? 'disabled' : ''}>
${content}
</button>
`
}
105 changes: 105 additions & 0 deletions src/js/app/components/renderSwitch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { icon_lock } from './icons'

function renderSwitchOption({ inputId, isChecked = false, icon, textTitle, textSubtitle }) {
const sanitizedInputId = sanitizeString(inputId)
const sanitizedTextTitle = sanitizeString(textTitle)
const sanitizedTextSubtitle = sanitizeString(textSubtitle)

return `
<label class="gpth-switch" for="${sanitizedInputId}">
<div class="gpth-switch__icon" aria-hidden="true">
${icon}
</div>

<div class="gpth-switch__text">
<div class="title">${sanitizedTextTitle}</div>
<div class="subtitle">${sanitizedTextSubtitle}</div>
</div>

<div class="gpth-switch__checkbox">
<input
type="checkbox"
id="${sanitizedInputId}"
${isChecked ? 'checked' : ''}
aria-labelledby="${sanitizedInputId}-label"
>
<span class="slider" aria-hidden="true"></span>
</div>
</label>`
}

function renderSmallCardOption({
name,
inputId,
inputType,
inputValue,
inputPlaceholder,
min = 10,
max = 100,
unit = '%',
isLocked = false,
}) {
const sanitizedName = sanitizeString(name)
const sanitizedInputId = sanitizeString(inputId)
const sanitizedInputValue = sanitizeString(inputValue)
const sanitizedInputPlaceholder = sanitizeString(inputPlaceholder)

const lockIcon = isLocked ? icon_lock : ''

return `
<div
class="card card--range ${isLocked ? 'is-locked' : ''}"
data-gpth-err="${min}${inputPlaceholder === '100%' ? '%' : unit} &hArr; ${max}${
inputPlaceholder === '100%' ? '%' : unit
}"
>
<label
for="${sanitizedInputId}"
class="flex flex-col justify-center p-2 gap-4 h-full w-full rounded-xl"
>
<div class="flex items-center gap-2 w-full">
<div
class="card__output flex-none h-10 w-10 font-semibold rounded-full grid items-center justify-center"
id="range-output-${sanitizedInputId}"
aria-live="polite"
>
${sanitizedInputValue}
</div>
<div class="card__unitname-wrapper grid">
<p
class="card__unit rounded-full flex items-center justify-center mb-2 font-semibold"
id="unit-${sanitizedInputId}"
>
${unit}
</p>
<p class="card__name uppercase font-semibold w-full break-words">
${sanitizedName}
</p>
</div>
</div>

<input
type="${inputType}"
id="${sanitizedInputId}"
value="${sanitizedInputValue}"
placeholder="${sanitizedInputPlaceholder}"
class="outline-none border-none"
min="${min}"
max="${max}"
aria-valuemin="${min}"
aria-valuemax="${max}"
aria-valuenow="${sanitizedInputValue}"
${isLocked ? 'disabled' : ''}
>
</label>
${lockIcon}
</div>`
}

function sanitizeString(str) {
const div = document.createElement('div')
div.textContent = str
return div.innerHTML
}

export { renderSwitchOption, renderSmallCardOption }
7 changes: 3 additions & 4 deletions src/js/app/floatingBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import browser from 'webextension-polyfill'
import { icon_sun, icon_moon, icon_moon_full, icon_settings, icon_paint } from './components/icons.js'
import { hexToHSL } from '../utils/hexToHSL'

// import { fontHtmlCode, addFontsEventHandlers } from './customFonts'
import { fontHtmlCode, handleFontsListeners } from './mainFonts'
import { assetsHtmlCode, handleAssetsListeners } from './mainAssets'
// console.log(fontHtmlCode)

// let isOptionsShown = false
Expand Down Expand Up @@ -203,8 +203,7 @@ function renderSettings() {
</div>

<div class="tab-pane hidden" id="tab-assets">
<p class="text-center text-token-text-tertiary text-sm mb-2 font-weight-200">ooops, such empty</p>
<p class="text-center text-token-text-secondary text-md font-semibold">Coming Soon</p>
${assetsHtmlCode}
</div>
</div>
</div>
Expand All @@ -225,8 +224,8 @@ function renderSettings() {

$settings.querySelector('#resetAllSettings').addEventListener('click', resetAllSettings)

// addFontsEventHandlers()
handleFontsListeners()
handleAssetsListeners()
}

function openSettings() {
Expand Down
Loading