diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 408286b8..f91f8b96 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -13,7 +13,7 @@ import { routes } from './routes' import './i18n/init' import { queryClient } from '@/api/queryClient' import { AppInitialization } from '@/components/AppInitialization' -import { SdkCreateButton } from './features/rooms/routes/sdk/CreateButton' +import { SdkCreateButton } from './features/sdk/routes/CreateButton' function App() { const { i18n } = useTranslation() diff --git a/src/frontend/src/features/sdk/SdkReverseClient.tsx b/src/frontend/src/features/sdk/SdkReverseClient.tsx new file mode 100644 index 00000000..773c04e7 --- /dev/null +++ b/src/frontend/src/features/sdk/SdkReverseClient.tsx @@ -0,0 +1,25 @@ +export enum ClientMessageType { + ROOM_CREATED = 'ROOM_CREATED', +} + +export class SdkReverseClient { + /** + * TODO: Use API Key. Must be based on some sort of credentials ? + */ + static getAllowTargetOrigin() { + return '*' + } + + static post(type: ClientMessageType, data: unknown = {}) { + console.log('POST !', type, data, window.parent) + // TODO: Make sure to use the correct origin. + window.parent.postMessage( + { + type, + data, + }, + SdkReverseClient.getAllowTargetOrigin() + ) + // TODO: Maybe use this to enforce security. + } +} diff --git a/src/frontend/src/features/rooms/routes/sdk/CreateButton.tsx b/src/frontend/src/features/sdk/routes/CreateButton.tsx similarity index 74% rename from src/frontend/src/features/rooms/routes/sdk/CreateButton.tsx rename to src/frontend/src/features/sdk/routes/CreateButton.tsx index 032a98d4..b391a2ed 100644 --- a/src/frontend/src/features/rooms/routes/sdk/CreateButton.tsx +++ b/src/frontend/src/features/sdk/routes/CreateButton.tsx @@ -1,14 +1,13 @@ import { Button } from '@/primitives/Button' import { useTranslation } from 'react-i18next' -import { generateRoomId } from '../../utils/generateRoomId' -import { useCreateRoom } from '../../api/createRoom' import { usePersistentUserChoices } from '@livekit/components-react' import { useState } from 'react' import { getRouteUrl } from '@/navigation/getRouteUrl' import { css } from '@/styled-system/css' import { RiCheckLine, RiFileCopyLine } from '@remixicon/react' -import { Loader } from '@/primitives/Loader' import { VisioIcon } from '@/assets/VisioIcon' +import { generateRoomId, useCreateRoom } from '../../rooms' +import { ClientMessageType, SdkReverseClient } from '../SdkReverseClient' export const SdkCreateButton = () => { const { t } = useTranslation('sdk', { keyPrefix: 'createButton' }) @@ -30,8 +29,11 @@ export const SdkCreateButton = () => { const roomUrlTmp = getRouteUrl('room', data.slug) setRoomUrl(roomUrlTmp) setIsLoading(false) + SdkReverseClient.post(ClientMessageType.ROOM_CREATED, { + url: roomUrlTmp, + }) }) - }, 2000) + }, 0) } const [isCopied, setIsCopied] = useState(false) @@ -44,33 +46,39 @@ export const SdkCreateButton = () => { } return ( -
+
{roomUrl ? ( ) : ( diff --git a/src/frontend/src/primitives/Button.tsx b/src/frontend/src/primitives/Button.tsx index 1724edd1..9e9cd1a2 100644 --- a/src/frontend/src/primitives/Button.tsx +++ b/src/frontend/src/primitives/Button.tsx @@ -23,12 +23,13 @@ export const Button = ({ ...props }: ButtonProps) => { const [variantProps, componentProps] = buttonRecipe.splitVariantProps(props) + const { className, ...remainingComponentProps } = componentProps return ( {!props.loading && props.icon} {props.loading && } diff --git a/src/frontend/src/primitives/buttonRecipe.ts b/src/frontend/src/primitives/buttonRecipe.ts index aea4deba..434822bb 100644 --- a/src/frontend/src/primitives/buttonRecipe.ts +++ b/src/frontend/src/primitives/buttonRecipe.ts @@ -140,6 +140,18 @@ export const buttonRecipe = cva({ color: 'primaryDark.100', }, }, + quaternaryText: { + backgroundColor: 'transparent', + color: 'greyscale.600', + '&[data-hovered]': { + backgroundColor: 'greyscale.100', + color: 'greyscale.700', + }, + '&[data-pressed]': { + backgroundColor: 'greyscale.100', + color: 'greyscale.700', + }, + }, greyscale: { backgroundColor: 'transparent', color: 'greyscale.400', diff --git a/src/frontend/src/routes.ts b/src/frontend/src/routes.ts index e50d2665..46cc6d37 100644 --- a/src/frontend/src/routes.ts +++ b/src/frontend/src/routes.ts @@ -1,6 +1,5 @@ import { FeedbackRoute, RoomRoute, roomIdPattern } from '@/features/rooms' import { HomeRoute } from '@/features/home' -import { SdkCreateButton } from './features/rooms/routes/sdk/CreateButton' export const routes: Record< 'home' | 'room' | 'feedback' | 'sdkCreateButton', @@ -28,11 +27,6 @@ export const routes: Record< path: '/feedback', Component: FeedbackRoute, }, - // sdkCreateButton: { - // name: 'sdkCreateButton', - // path: '/sdk/create-button', - // Component: SdkCreateButton, - // }, } export type RouteName = keyof typeof routes diff --git a/src/sdk/consumer/src/App.tsx b/src/sdk/consumer/src/App.tsx index 7f1512ec..9535420a 100644 --- a/src/sdk/consumer/src/App.tsx +++ b/src/sdk/consumer/src/App.tsx @@ -1,11 +1,41 @@ import { VisioCreateButton } from "@gouvfr-lasuite/visio-sdk"; import "./App.css"; +import { useState } from "react"; function App() { + const [roomUrl, setRoomUrl] = useState(""); + return ( -
- -
+
+
+

Create event

+ Visio demo app +
+
+ + +
+
+ + +
+
+ + +
+
+ +