From 379e72c5672fa5b275faa055fe2969924e3b1163 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Tue, 3 Oct 2023 17:26:42 +0530 Subject: [PATCH] theming.md Signed-off-by: Abhinav Kumar --- packages/react/docs/theming.md | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 packages/react/docs/theming.md diff --git a/packages/react/docs/theming.md b/packages/react/docs/theming.md new file mode 100644 index 000000000..aeca9eda1 --- /dev/null +++ b/packages/react/docs/theming.md @@ -0,0 +1,70 @@ +# Theming + +Hello everyone, + +After setting up the project, you can explore the project's components to understand how theming is implemented. + +## Using Emotion for Styling + +We use [Emotion](https://emotion.sh/) for styling our components. Theming is implemented by providing a theme object that includes a `components` field. + +For example: + +```json +"components": { + "ChatInput": { + "styleOverrides": { + "fontWeight": 400, + "color": "gray", + "border": "1px solid black" + }, + "classNames": "myCustomClassForChatInput" + }, + "Message": { + "classNames": "myCustomClass" + } +} +``` + +In the above example: + - theme.components.ChatInput.styleOverrides would be applied to the style of the ChatInput component. + - theme.components.ChatInput.classNames would be applied to the className of the ChatInput component. + +## Using the useComponentsOverrides Hook +We provide a `useComponentsOverrides` hook that returns the necessary data for component customization. + +```jsx +import { useComponentOverrides } from '../../theme/useComponentOverrides'; + +export const MessageBody = ({ + children, + className = '', + style = {}, + ...props +}) => { + const { styleOverrides, classNames } = useComponentOverrides( + 'MessageBody', + className, + style + ); + + return ( + +

{children}

+
+ ); +}; +``` +## Adding Classes to Components +We also add a class to each component. For example, `ec-message-body` for the MessageBody component. + +Feel free to explore and customize these components according to your project's needs. + +If you have any questions or need further assistance, please don't hesitate to ask. + +Happy theming! \ No newline at end of file