Skip to content

Commit

Permalink
fix(chat-settings): fix multiple imports
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamTraoreee committed Sep 10, 2022
1 parent 5081258 commit a09ad67
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
18 changes: 18 additions & 0 deletions apps/app/src/app/pages/chatbox/embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ function EmbedChatbox() {
[theme]
);

useEffect(() => {
if (theme) {
(async () => {
const WebFont = await import('webfontloader');
WebFont.load({
google: {
families: [
theme.name.fontFamily +
':100,200,300,400,500,600,700,800,900,950',
theme.message.fontFamily +
':100,200,300,400,500,600,700,800,900,950',
],
},
});
})();
}
}, [theme]);

useEffect(() => {
if (theme) {
void client.connect();
Expand Down
18 changes: 18 additions & 0 deletions libs/shared/ui/src/lib/components/chat/chat-demo/chat-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ export function ChatDemo(props: ChatDemoProps) {
pushMessage();
}, []);

useEffect(() => {
if (settings) {
(async () => {
const WebFont = await import('webfontloader');
WebFont.load({
google: {
families: [
settings.name.fontFamily +
':100,200,300,400,500,600,700,800,900,950',
settings.message.fontFamily +
':100,200,300,400,500,600,700,800,900,950',
],
},
});
})();
}
}, [settings.name.fontFamily, settings.message.fontFamily]);

return (
<>
{demo.map((message, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,6 @@ export function ChatMessage(props: ChatMessageProps) {
}
}, [settings]);

useEffect(() => {
if (nameStyle.fontFamily && messageStyle.fontFamily) {
(async () => {
const WebFont = await import('webfontloader');
WebFont.load({
google: {
families: [
nameStyle.fontFamily as string,
messageStyle.fontFamily as string,
],
},
});
})();
}
}, [nameStyle.fontFamily, messageStyle.fontFamily]);

return (
<div style={containerStyle} className="flex w-full">
<div style={nameStyle} className="shrink-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export function ChatSettings(props: ChatSettingsProps) {
});

useEffect(() => {
onSettingsChange(getValues());
const subscription = watch((value) => console.log(value));
const subscription = watch((value) => onSettingsChange(value));
return () => subscription.unsubscribe();
}, [watch, onSettingsChange, getValues]);

Expand Down
6 changes: 3 additions & 3 deletions libs/shared/ui/src/lib/components/forms/spacing/spacing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import Input from '../input/input';
import Label from '../label/label';

interface Spacing {
interface SpacingValue {
top?: number;
left?: number;
right?: number;
Expand All @@ -17,8 +17,8 @@ interface Radius {
}

export interface SpacingProps {
value?: Spacing & Radius;
onValueChange?: (value: Spacing | Radius) => void;
value?: SpacingValue & Radius;
onValueChange?: (value: SpacingValue | Radius) => void;
label?: string;
className?: string;
type?: 'spacing' | 'radius';
Expand Down

0 comments on commit a09ad67

Please sign in to comment.