Skip to content

Commit

Permalink
Fix backgrounds and char archiving (#978)
Browse files Browse the repository at this point in the history
- Fix chat padding
- Fix character archiving deleting some char props
- Fix inputbar background and component rounding
  • Loading branch information
sceuick authored Jul 17, 2024
1 parent 5346218 commit 437227d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion web/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const Layout: Component<{ children?: any }> = (props) => {
<Navigation />
<main class="w-full overflow-y-auto" data-background style={bgStyles()}>
<div
class={`mx-auto h-full min-h-full ${isChat() ? maxW() : 'max-w-8xl'} px-2 sm:px-3`}
class={`mx-auto h-full min-h-full ${isChat() ? maxW() : 'max-w-8xl'}`}
classList={{
'content-background': !isChat(),
}}
Expand Down
29 changes: 18 additions & 11 deletions web/pages/Chat/components/InputBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ const InputBar: Component<{
}

return (
<div class="relative flex items-end justify-center">
<div class="relative flex items-end justify-center rounded-md bg-[var(--bg-800)]">
<Show when={props.showOocToggle}>
<div class="cursor-pointer p-2" onClick={toggleOoc}>
<div class="flex h-[40px] cursor-pointer items-center p-2" onClick={toggleOoc}>
<Show when={!props.ooc}>
<WizardIcon />
</Show>
Expand All @@ -249,7 +249,7 @@ const InputBar: Component<{
</div>
</Show>

<div class="flex items-center sm:hidden">
<div class="flex h-[40px] items-center sm:hidden">
<a
href="#"
role="button"
Expand Down Expand Up @@ -312,7 +312,11 @@ const InputBar: Component<{
},
}}
/>
<Button schema="clear" onClick={onButtonClick} class="h-full px-2 py-2">
<Button
schema="clear"
onClick={onButtonClick}
class="h-full rounded-l-none bg-[var(--bg-800)] px-2 py-2"
>
<MoreHorizontal class="icon-button" />
</Button>

Expand Down Expand Up @@ -394,13 +398,16 @@ const InputBar: Component<{
</DropMenu>
<Switch>
<Match when={user.user?.speechtotext && (text() === '' || listening())}>
<SpeechRecognitionRecorder
culture={props.char?.culture}
onText={(value) => setText(value)}
onSubmit={() => send()}
cleared={cleared}
listening={setListening}
/>
<div class="flex h-full items-center">
<SpeechRecognitionRecorder
culture={props.char?.culture}
onText={(value) => setText(value)}
onSubmit={() => send()}
cleared={cleared}
listening={setListening}
class="h-full bg-[var(--bg-800)]"
/>
</div>
</Match>

<Match when>
Expand Down
3 changes: 2 additions & 1 deletion web/pages/Chat/components/SpeechRecognitionRecorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ export const SpeechRecognitionRecorder: Component<{
<Show when={speechRecognition() && settings.enabled}>
<Button
schema="clear"
class={`${isListening() ? 'text-red-500' : 'text-gray-500'}`}
class={`${isListening() ? 'text-red-500' : 'text-gray-500'} ${props.class || ''} `}
onClick={toggleListening}
>
<Mic
size={18}
class="h-6"
classList={{
'animate-pulse': pendingRecord() || isHearing(),
}}
Expand Down
15 changes: 11 additions & 4 deletions web/shared/Mode/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ export const ModeDetail: Component<{
</Show>

<Show when={!props.loading}>
<section class="mode">
<header class="flex flex-col gap-2" style={{ 'grid-area': 'header' }}>
<section
class="mode pl-2 pr-2 sm:pl-3"
style={bgStyles()}
classList={{
'sm:pr-0': props.showPane,
'sm:pr-3': !props.showPane,
}}
>
<header class="flex flex-col gap-2 pt-2" style={{ 'grid-area': 'header' }}>
<div
class="hidden items-center justify-between rounded-md sm:flex"
classList={{ 'sm:flex': !!props.header }}
Expand All @@ -79,8 +86,8 @@ export const ModeDetail: Component<{
</header>

<section
style={{ 'grid-area': 'content', ...bgStyles() }}
class="content my-2 flex w-full flex-row gap-1 overflow-y-auto px-2 sm:px-3"
style={{ 'grid-area': 'content' }}
class="content my-2 flex w-full flex-row gap-1 overflow-y-auto"
classList={{
'justify-center': !props.showPane || mode() === 'popup',
'justify-end gap-1 justify-self-center flex-row flex':
Expand Down
1 change: 0 additions & 1 deletion web/shared/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export function useCharacterBg(src: 'layout' | 'page') {
const isBg = state.ui.viewMode?.startsWith('background')
const char = chars.chars.map[chat.active?.char?._id!]
if (!isChat() || !isBg || !char || char.visualType === 'sprite' || !char.avatar) {
console.log('bg', mobile)
return {
...base,
'background-image': `url(${state.background})`,
Expand Down
3 changes: 2 additions & 1 deletion web/store/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export const characterStore = createStore<CharacterState>(
onSuccess?: () => void
) {
const previous = map[characterId]
const res = await charsApi.editCharacter(characterId, char, previous)
const update = Object.assign({}, previous, char)
const res = await charsApi.editCharacter(characterId, update)

if (res.error) toastStore.error(`Failed to create character: ${res.error}`)
if (res.result) {
Expand Down

0 comments on commit 437227d

Please sign in to comment.