Skip to content

Commit

Permalink
style: update chat UI colors and input styling
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Oct 8, 2024
1 parent d6ad3aa commit e2ba58e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion catalog/app/components/Assistant/UI/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const useMessageContainerStyles = M.makeStyles((t) => ({
borderRadius: `${t.spacing(1)}px`,
'$color_intense &': {
background: BG.intense,
color: t.palette.common.white,
color: M.fade(t.palette.common.white, 0.8),
},
'$color_bright &': {
background: BG.bright,
Expand Down
102 changes: 74 additions & 28 deletions catalog/app/components/Assistant/UI/Chat/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import cx from 'classnames'
import * as React from 'react'
import * as M from '@material-ui/core'

Check warning on line 3 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L1-L3

Added lines #L1 - L3 were not covered by tests

import { createCustomAppTheme } from 'constants/style'

Check warning on line 5 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L5

Added line #L5 was not covered by tests

const useStyles = M.makeStyles((t) => ({

Check warning on line 7 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L7

Added line #L7 was not covered by tests
input: {
alignItems: 'center',
Expand All @@ -12,8 +14,49 @@ const useStyles = M.makeStyles((t) => ({
textField: {
marginTop: 0,
},
hint: {
color: t.palette.text.hint,
},
}))

const backgroundColor = M.colors.indigo[900]
const backgroundColorLt = M.lighten(backgroundColor, 0.1)

Check warning on line 23 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L22-L23

Added lines #L22 - L23 were not covered by tests

const useInputStyles = M.makeStyles({

Check warning on line 25 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L25

Added line #L25 was not covered by tests
focused: {},
disabled: {},
root: {
backgroundColor,
borderRadius: '8px',
color: M.fade(M.colors.common.white, 0.8),
'&:hover': {
backgroundColor: backgroundColorLt,
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor,
},
},
'&$focused': {
backgroundColor,
},
'&$disabled': {
backgroundColor: backgroundColorLt,
},
},
})

const useLabelStyles = M.makeStyles({

Check warning on line 48 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L48

Added line #L48 was not covered by tests
focused: {},
root: {
color: M.fade(M.colors.common.white, 0.6),
'&$focused': {
color: M.fade(M.colors.common.white, 0.6),
},
},
})

const darkTheme = createCustomAppTheme({ palette: { type: 'dark' } } as any)

Check warning on line 58 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L58

Added line #L58 was not covered by tests

interface ChatInputProps {
className?: string
disabled?: boolean
Expand All @@ -35,36 +78,39 @@ export default function ChatInput({ className, disabled, onSubmit }: ChatInputPr
[disabled, onSubmit, value],
)

// TODO: customize colors
return (

Check warning on line 81 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L81

Added line #L81 was not covered by tests
<form className={cx(classes.input, className)} onSubmit={handleSubmit}>
<M.TextField
className={classes.textField}
onChange={(e) => setValue(e.target.value)}
value={value}
variant="filled"
autoFocus
fullWidth
margin="normal"
label="Ask Qurator"
helperText="Qurator may make errors. Verify important information."
InputProps={{
endAdornment: (
<M.InputAdornment position="end" variant="filled">
<M.IconButton
disabled={disabled || !value}
onClick={handleSubmit}
type="submit"
color="primary"
edge="end"
>
<M.Icon>send</M.Icon>
</M.IconButton>
</M.InputAdornment>
),
}}
InputLabelProps={{}}
/>
<M.ThemeProvider theme={darkTheme}>
<M.TextField
className={classes.textField}
onChange={(e) => setValue(e.target.value)}

Check warning on line 86 in catalog/app/components/Assistant/UI/Chat/Input.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/UI/Chat/Input.tsx#L86

Added line #L86 was not covered by tests
value={value}
variant="filled"
autoFocus
fullWidth
margin="normal"
label="Ask Qurator"
helperText="Qurator may make errors. Verify important information."
InputProps={{
disableUnderline: true,
classes: useInputStyles(),
endAdornment: (
<M.InputAdornment position="end">
<M.IconButton
disabled={disabled || !value}
onClick={handleSubmit}
type="submit"
edge="end"
>
<M.Icon style={{ opacity: 0.7 }}>send</M.Icon>
</M.IconButton>
</M.InputAdornment>
),
}}
InputLabelProps={{ classes: useLabelStyles() }}
FormHelperTextProps={{ classes: { root: classes.hint } }}
/>
</M.ThemeProvider>
</form>
)
}

0 comments on commit e2ba58e

Please sign in to comment.