From f14b8ea8ba5c6ee964bffd97bbae076d680ca376 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Fri, 13 May 2022 15:07:49 -0700 Subject: [PATCH] Wire up placeholder name change modal --- .../common/UserDropdown/UserDropdown.tsx | 19 +++++++++++++- web/components/modals/NameChangeModal.tsx | 25 +++++++++++++++++++ web/stories/NameChangeModal.stories.tsx | 15 +++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 web/components/modals/NameChangeModal.tsx create mode 100644 web/stories/NameChangeModal.stories.tsx diff --git a/web/components/common/UserDropdown/UserDropdown.tsx b/web/components/common/UserDropdown/UserDropdown.tsx index 28391a1fe..a86cfb2fa 100644 --- a/web/components/common/UserDropdown/UserDropdown.tsx +++ b/web/components/common/UserDropdown/UserDropdown.tsx @@ -1,9 +1,12 @@ import { Menu, Dropdown, Button, Space } from 'antd'; import { DownOutlined } from '@ant-design/icons'; import { useRecoilState, useRecoilValue } from 'recoil'; +import { useState } from 'react'; +import Modal from '../../ui/Modal/Modal'; import { chatVisibilityAtom, chatDisplayNameAtom } from '../../stores/ClientConfigStore'; import { ChatState, ChatVisibilityState } from '../../../interfaces/application-state'; import s from './UserDropdown.module.scss'; +import NameChangeModal from '../../modals/NameChangeModal'; interface Props { username?: string; @@ -14,6 +17,7 @@ export default function UserDropdown({ username: defaultUsername, chatState }: P const [chatVisibility, setChatVisibility] = useRecoilState(chatVisibilityAtom); const username = defaultUsername || useRecoilValue(chatDisplayNameAtom); + const [showNameChangeModal, setShowNameChangeModal] = useState(false); const toggleChatVisibility = () => { if (chatVisibility === ChatVisibilityState.Hidden) { @@ -23,9 +27,15 @@ export default function UserDropdown({ username: defaultUsername, chatState }: P } }; + const handleChangeName = () => { + setShowNameChangeModal(true); + }; + const menu = ( - Change name + handleChangeName()}> + Change name + Authenticate {chatState === ChatState.Available && ( toggleChatVisibility()}> @@ -45,6 +55,13 @@ export default function UserDropdown({ username: defaultUsername, chatState }: P + setShowNameChangeModal(false)} + > + + ); } diff --git a/web/components/modals/NameChangeModal.tsx b/web/components/modals/NameChangeModal.tsx new file mode 100644 index 000000000..5d4d3aeb2 --- /dev/null +++ b/web/components/modals/NameChangeModal.tsx @@ -0,0 +1,25 @@ +import { useRecoilValue } from 'recoil'; +import WebsocketService from '../../services/websocket-service'; +// import { setLocalStorage } from '../../utils/helpers'; +import { websocketServiceAtom } from '../stores/ClientConfigStore'; + +/* eslint-disable @typescript-eslint/no-unused-vars */ +interface Props {} + +export default function NameChangeModal(props: Props) { + const websocketService = useRecoilValue(websocketServiceAtom); + + // const handleNameChange = () => { + // // Send name change + // const nameChange = { + // type: SOCKET_MESSAGE_TYPES.NAME_CHANGE, + // newName, + // }; + // websocketService.send(nameChange); + + // // Store it locally + // setLocalStorage(KEY_USERNAME, newName); + // }; + + return
Name change modal component goes here
; +} diff --git a/web/stories/NameChangeModal.stories.tsx b/web/stories/NameChangeModal.stories.tsx new file mode 100644 index 000000000..a8033183d --- /dev/null +++ b/web/stories/NameChangeModal.stories.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import NameChangeModal from '../components/modals/NameChangeModal'; + +export default { + title: 'owncast/Modals/Name change', + component: NameChangeModal, + parameters: {}, +} as ComponentMeta; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const Template: ComponentStory = args => ; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const Basic = Template.bind({});