2022-12-06 10:13:55 +03:00
|
|
|
import React, { useEffect } from 'react';
|
2022-04-28 09:19:20 +03:00
|
|
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
2022-12-06 10:13:55 +03:00
|
|
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { UserDropdown } from './UserDropdown';
|
2022-12-06 10:13:55 +03:00
|
|
|
import { CurrentUser } from '../../../interfaces/current-user';
|
|
|
|
import { currentUserAtom } from '../../stores/ClientConfigStore';
|
2022-04-28 09:19:20 +03:00
|
|
|
|
|
|
|
export default {
|
2022-05-18 00:24:48 +03:00
|
|
|
title: 'owncast/Components/User settings menu',
|
2022-05-08 10:41:47 +03:00
|
|
|
component: UserDropdown,
|
2022-04-28 09:19:20 +03:00
|
|
|
parameters: {},
|
2022-05-08 10:41:47 +03:00
|
|
|
} as ComponentMeta<typeof UserDropdown>;
|
2022-04-28 09:19:20 +03:00
|
|
|
|
2022-04-30 01:09:53 +03:00
|
|
|
// This component uses Recoil internally so wrap it in a RecoilRoot.
|
2022-12-06 10:13:55 +03:00
|
|
|
const Example = args => {
|
|
|
|
const setCurrentUser = useSetRecoilState<CurrentUser>(currentUserAtom);
|
|
|
|
|
|
|
|
useEffect(
|
|
|
|
() =>
|
|
|
|
setCurrentUser({
|
|
|
|
id: '1',
|
|
|
|
displayName: 'Test User',
|
|
|
|
displayColor: 3,
|
|
|
|
isModerator: false,
|
|
|
|
}),
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
|
2023-05-23 04:56:44 +03:00
|
|
|
return <UserDropdown id="user-menu" {...args} />;
|
2022-12-06 10:13:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const Template: ComponentStory<typeof UserDropdown> = args => (
|
2022-04-30 01:09:53 +03:00
|
|
|
<RecoilRoot>
|
2022-12-06 10:13:55 +03:00
|
|
|
<Example {...args} />
|
2022-04-30 01:09:53 +03:00
|
|
|
</RecoilRoot>
|
|
|
|
);
|
2022-04-28 09:19:20 +03:00
|
|
|
|
2022-04-30 01:09:53 +03:00
|
|
|
export const ChatEnabled = Template.bind({});
|
|
|
|
ChatEnabled.args = {
|
|
|
|
username: 'test-user',
|
|
|
|
};
|