2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-08-20 18:23:09 +00:00
|
|
|
import * as React from 'react';
|
2023-10-11 19:06:43 +00:00
|
|
|
import type { Meta } from '@storybook/react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Props } from './AddNewLines';
|
|
|
|
import { AddNewLines } from './AddNewLines';
|
2020-08-20 18:23:09 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/Conversation/AddNewLines',
|
2023-10-11 19:06:43 +00:00
|
|
|
} satisfies Meta<Props>;
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2020-08-20 18:23:09 +00:00
|
|
|
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
|
|
|
renderNonNewLine: overrideProps.renderNonNewLine,
|
2023-04-12 23:17:56 +00:00
|
|
|
text: overrideProps.text || '',
|
2020-08-20 18:23:09 +00:00
|
|
|
});
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AllNewlines(): JSX.Element {
|
2020-08-20 18:23:09 +00:00
|
|
|
const props = createProps({
|
|
|
|
text: '\n\n\n',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AddNewLines {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function StartingEndingWithNewlines(): JSX.Element {
|
2020-08-20 18:23:09 +00:00
|
|
|
const props = createProps({
|
|
|
|
text: '\nSome text\n',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AddNewLines {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function NewlinesInTheMiddle(): JSX.Element {
|
2020-08-20 18:23:09 +00:00
|
|
|
const props = createProps({
|
|
|
|
text: 'Some\ntext',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AddNewLines {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function NoNewlines(): JSX.Element {
|
2020-08-20 18:23:09 +00:00
|
|
|
const props = createProps({
|
|
|
|
text: 'Some text',
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AddNewLines {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2020-08-20 18:23:09 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function CustomRenderFunction(): JSX.Element {
|
2020-08-20 18:23:09 +00:00
|
|
|
const props = createProps({
|
|
|
|
text: 'Some text',
|
|
|
|
renderNonNewLine: ({ text: theText, key }) => (
|
|
|
|
<div key={key} style={{ color: 'aquamarine' }}>
|
|
|
|
{theText}
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
});
|
|
|
|
|
|
|
|
return <AddNewLines {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|