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: basic chat UI #8

Merged
merged 21 commits into from
Dec 3, 2024
Merged

feat: basic chat UI #8

merged 21 commits into from
Dec 3, 2024

Conversation

emcelroy
Copy link
Contributor

@emcelroy emcelroy commented Nov 22, 2024

These changes set up the basic UI for the chat interface.

  • #188491602 Read-aloud textbox inclusive technologies
  • #188528148 Submit button with inclusive technologies
  • #188528220 Chat thread with inclusive technologies
  • #188528234 Readaloud Switch button with inclusive technologies -- NOTE: UI elements exist but actual functionality will be added later.

@lublagg lublagg changed the base branch from 188528234-readaloud-switch to main November 26, 2024 18:45
@emcelroy emcelroy marked this pull request as ready for review December 2, 2024 19:30
@emcelroy emcelroy requested a review from bgoldowsky December 2, 2024 19:48
Copy link

@bgoldowsky bgoldowsky left a comment

Choose a reason for hiding this comment

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

This looks good to me!

A couple of notes but they shouldn't prevent you from merging.

src/components/App.scss Outdated Show resolved Hide resolved
Comment on lines 37 to 39
&.send {
order: 2;
}

Choose a reason for hiding this comment

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

I'm sure UI will be handled later, but it's odd that the 'send' button is different styling from the other 3 buttons (grey & square rather than blue & rounded).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. It will be changed later, but since it's easy, I've updated the CSS so it matches the others.

// const [browserSupportsDictation, setBrowserSupportsDictation] = useState(false);
// const [dictationEnabled, setDictationEnabled] = useState(false);
const [inputValue, setInputValue] = useState("");
const [showPlaceholder, setShowPlaceholder] = useState(true);

Choose a reason for hiding this comment

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

Why do you need to track this? Placeholder should automatically be shown only when the input is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mistakenly thought we didn't want the placeholder text to reappear when the input was cleared after submitting a message. Looking at the specs again, I see that is not the case. So I've dropped that in the latest commit.

Comment on lines +18 to +20
&:nth-child(odd) {
background: $light-teal-2;
}

Choose a reason for hiding this comment

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

Maybe it doesn't matter, but it seems like the background color should be based on the speaker, not just message order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that's right. Lucy is working on making it that way in the debug logging branch she's currently working on.

const form = event.target as HTMLInputElement;
const shortcut = form.querySelector("input")?.value;
if (shortcut) {
onCustomizeShortcut?.(shortcut);

Choose a reason for hiding this comment

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

You should probably do a trim on the input. I thought I broke it when I just had a space after the shortcut.

"Equal": { shifted: "+", unshifted: "=" }
};

export const isShortcutPressed = (pressedKeys: Set<string>, shortcutKeys: string): boolean => {

Choose a reason for hiding this comment

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

I wonder if you could avoid some of this complexity by using a hotkeys library like CLUE does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bgoldowsky Thanks. I did try some libraries previously, but the ones I tried didn't play nicely with the need to set the shortcut listener in both the plugin and in the main CODAP window. I think maybe the one CLUE uses may not have that problem, though. I'll give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried out is-hotkey. It was promising in that it did work for both adding a listener to the plugin and the main CODAP window. I ran into another issue, though, with the shift key which I couldn't get around. I think there must be a solution to that, but it's not obvious to me at this point. I'm going to leave the existing shortcut-handling code for now. I do think using a library would be better, though, and will make sure we revisit the idea after the UI gets refined.

@emcelroy emcelroy merged commit 67d677e into main Dec 3, 2024
5 checks passed
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.

3 participants