// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import { storiesOf } from '@storybook/react'; import { text } from '@storybook/addon-knobs'; import { action } from '@storybook/addon-actions'; import { ProfileEditor, PropsType } from './ProfileEditor'; import { setup as setupI18n } from '../../js/modules/i18n'; import enMessages from '../../_locales/en/messages.json'; import { getFirstName, getLastName, } from '../test-both/helpers/getDefaultConversation'; import { getRandomColor } from '../test-both/helpers/getRandomColor'; const i18n = setupI18n('en', enMessages); const stories = storiesOf('Components/ProfileEditor', module); const createProps = (overrideProps: Partial = {}): PropsType => ({ aboutEmoji: overrideProps.aboutEmoji, aboutText: text('about', overrideProps.aboutText || ''), avatarPath: overrideProps.avatarPath, conversationId: '123', color: overrideProps.color || getRandomColor(), deleteAvatarFromDisk: action('deleteAvatarFromDisk'), familyName: overrideProps.familyName, firstName: text('firstName', overrideProps.firstName || getFirstName()), i18n, onEditStateChanged: action('onEditStateChanged'), onProfileChanged: action('onProfileChanged'), onSetSkinTone: overrideProps.onSetSkinTone || action('onSetSkinTone'), recentEmojis: [], replaceAvatar: action('replaceAvatar'), saveAvatarToDisk: action('saveAvatarToDisk'), skinTone: overrideProps.skinTone || 0, userAvatarData: [], }); stories.add('Full Set', () => { const [skinTone, setSkinTone] = useState(0); return ( ); }); stories.add('with Full Name', () => ( )); stories.add('with Custom About', () => ( ));