Skip to content

Commit

Permalink
New/message component+avatar (#5)
Browse files Browse the repository at this point in the history
* Box replacement (#224)

* added ActionButton, Icon, Input

Signed-off-by: Abhinav Kumar <[email protected]>

improve auth

Signed-off-by: Abhinav Kumar <[email protected]>

added apis for slash, ui-iteractions, action-trigger

Signed-off-by: Abhinav Kumar <[email protected]>

slash-commands+ui-kit+theming

Signed-off-by: Abhinav Kumar <[email protected]>

slash-commands+ui-kit+theming

* html-embedd

Signed-off-by: Abhinav Kumar <[email protected]>

* new/message-component+avatar

Signed-off-by: Abhinav Kumar <[email protected]>

---------

Signed-off-by: Abhinav Kumar <[email protected]>
  • Loading branch information
abhinavkrin authored Sep 13, 2023
1 parent 21d88ac commit d1c70ca
Show file tree
Hide file tree
Showing 23 changed files with 847 additions and 207 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/components/ActionButton/ActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const getSize = ({ small, large }) => {
};

const ActionButton = forwardRef(
({ icon, size = 'medium', children, ...props }, ref) => (
<Button ref={ref} square size={size} {...props}>
({ icon, size = 'medium', color = 'default', children, ...props }, ref) => (
<Button ref={ref} square size={size} color={color} {...props}>
{children}
<Icon name={icon} size={getSize(props)} />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const Ghost = {
ghost: true,
icon: 'cross',
disabled: false,
color: 'primary',
},
render: (args) => (
<ThemeProvider theme={DefaultTheme}>
Expand Down
34 changes: 34 additions & 0 deletions packages/react/src/components/Avatar/Avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { css } from '@emotion/react';
import React from 'react';
import useComponentOverrides from '../../theme/useComponentOverrides';
import { AvatarContainer } from './AvatarContainer';

export const Avatar = ({
size = '2.25rem',
className = '',
style = {},
url,
...props
}) => {
const AvatarCss = css`
border-radius: 0.25rem;
height: ${size};
width: ${size};
`;
const { classNames, styleOverrides } = useComponentOverrides(
'Avatar',
className,
style
);

return (
<AvatarContainer size={size} {...props}>
<img
src={`${url}`}
css={AvatarCss}
className={classNames}
style={styleOverrides}
/>
</AvatarContainer>
);
};
33 changes: 33 additions & 0 deletions packages/react/src/components/Avatar/AvatarContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { css } from '@emotion/react';
import React from 'react';
import { appendClassNames } from '../../lib/appendClassNames';
import useComponentOverrides from '../../theme/useComponentOverrides';
import { Box } from '../Box';

export const AvatarContainer = ({
title,
children,
className = '',
style = {},
...props
}) => {
const AvatarContainerCSS = css`
display: inline-flex;
vertical-align: middle;
cursor: pointer;
`;
const { classNames, styleOverrides } = useComponentOverrides(
'AvatarContainer',
className,
style
);
props.className = appendClassNames('ec-avatar-container', [classNames]);

props.style = styleOverrides;

return (
<Box is="figure" css={AvatarContainerCSS} aria-label={title} {...props}>
{children}
</Box>
);
};
1 change: 1 addition & 0 deletions packages/react/src/components/Avatar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Avatar';
8 changes: 4 additions & 4 deletions packages/react/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const Button = ({
const classNameButton = css`
cursor: pointer;
display: inline-block;
background-color: ${theme.palette[color].main};
color: ${theme.palette[color].contrastText || 'currentColor'};
border-color: ${theme.palette[color].main || 'currentColor'};
background-color: ${theme.palette[color]?.main};
color: ${theme.palette[color]?.contrastText || 'currentColor'};
border-color: ${theme.palette[color]?.main || 'currentColor'};
border-style: solid;
border-width: 1px;
font-size: 0.875rem;
Expand Down Expand Up @@ -96,7 +96,7 @@ const Button = ({
}
&.ghost {
background: none;
color: ${theme?.palette?.text?.primary || '#1A2027'};
color: ${theme?.palette?.[color]?.main || '#1A2027'};
border: none;
}
&.disabled.ghost {
Expand Down
10 changes: 4 additions & 6 deletions packages/react/src/components/ChatBody/ChatBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,10 @@ const ChatBody = ({ height, anonymousMode, showRoles }) => {
useEffect(() => {
RCInstance.auth.onAuthChange((user) => {
if (user) {
RCInstance.connect().then(() => {
RCInstance.addMessageListener(addMessage);
RCInstance.addMessageDeleteListener(removeMessage);
RCInstance.addActionTriggeredListener(onActionTriggerResponse);
RCInstance.addUiInteractionListener(onActionTriggerResponse);
});
RCInstance.addMessageListener(addMessage);
RCInstance.addMessageDeleteListener(removeMessage);
RCInstance.addActionTriggeredListener(onActionTriggerResponse);
RCInstance.addUiInteractionListener(onActionTriggerResponse);
getMessagesAndRoles();
} else {
getMessagesAndRoles(anonymousMode);
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/ChatInput/ChatInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ const ChatInput = () => {
margin-top: 20px;
border: 2px solid #ddd;
`}
className={styles.containerParent}
>
{showMembersList ? (
<MembersList
Expand Down
Loading

0 comments on commit d1c70ca

Please sign in to comment.