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