From 1d245dbbc11a91e6c2a903909449ac9e68b0905a Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 5 Dec 2022 23:13:55 -0800 Subject: [PATCH] Fix user settings dropdown story not rendering. Closes #2350 --- .../UserDropdown/UserDropdown.stories.tsx | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/web/components/common/UserDropdown/UserDropdown.stories.tsx b/web/components/common/UserDropdown/UserDropdown.stories.tsx index f4543d798..df714363c 100644 --- a/web/components/common/UserDropdown/UserDropdown.stories.tsx +++ b/web/components/common/UserDropdown/UserDropdown.stories.tsx @@ -1,7 +1,9 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { ComponentStory, ComponentMeta } from '@storybook/react'; -import { RecoilRoot } from 'recoil'; +import { RecoilRoot, useSetRecoilState } from 'recoil'; import { UserDropdown } from './UserDropdown'; +import { CurrentUser } from '../../../interfaces/current-user'; +import { currentUserAtom } from '../../stores/ClientConfigStore'; export default { title: 'owncast/Components/User settings menu', @@ -10,20 +12,30 @@ export default { } as ComponentMeta; // This component uses Recoil internally so wrap it in a RecoilRoot. -const Example = args => ( +const Example = args => { + const setCurrentUser = useSetRecoilState(currentUserAtom); + + useEffect( + () => + setCurrentUser({ + id: '1', + displayName: 'Test User', + displayColor: 3, + isModerator: false, + }), + [], + ); + + return ; +}; + +const Template: ComponentStory = args => ( - + ); -const Template: ComponentStory = args => ; - export const ChatEnabled = Template.bind({}); ChatEnabled.args = { username: 'test-user', }; - -export const ChatDisabled = Template.bind({}); -ChatDisabled.args = { - username: 'test-user', -};