2021-05-11 10:25:22 -04:00
|
|
|
import useFetchMock from './hooks/use-fetch-mock'
|
2021-09-14 04:54:08 -04:00
|
|
|
import WordCountModal from '../js/features/word-count-modal/components/word-count-modal'
|
2022-05-16 05:38:20 -04:00
|
|
|
import { ScopeDecorator } from './decorators/scope'
|
2024-10-10 03:26:18 -04:00
|
|
|
import { bsVersionDecorator } from '../../.storybook/utils/with-bootstrap-switcher'
|
2021-09-14 04:54:08 -04:00
|
|
|
|
|
|
|
const counts = {
|
|
|
|
headers: 4,
|
|
|
|
mathDisplay: 40,
|
|
|
|
mathInline: 400,
|
|
|
|
textWords: 4000,
|
|
|
|
}
|
|
|
|
|
|
|
|
const messages = [
|
|
|
|
'Lorem ipsum dolor sit amet.',
|
|
|
|
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
|
|
|
|
].join('\n')
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
export const WordCount = args => {
|
2021-05-11 10:25:22 -04:00
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
2021-09-14 04:54:08 -04:00
|
|
|
{ status: 200, body: { texcount: counts } },
|
|
|
|
{ delay: 500 }
|
|
|
|
)
|
|
|
|
})
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <WordCountModal {...args} />
|
2021-09-14 04:54:08 -04:00
|
|
|
}
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2021-09-14 04:54:08 -04:00
|
|
|
export const WordCountWithMessages = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
|
|
|
{ status: 200, body: { texcount: { ...counts, messages } } },
|
|
|
|
{ delay: 500 }
|
2021-05-11 10:25:22 -04:00
|
|
|
)
|
|
|
|
})
|
2021-01-06 05:38:25 -05:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <WordCountModal {...args} />
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|
2021-09-14 04:54:08 -04:00
|
|
|
|
|
|
|
export const ErrorResponse = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
fetchMock.get(
|
|
|
|
'express:/project/:projectId/wordcount',
|
|
|
|
{ status: 500 },
|
|
|
|
{ delay: 500 }
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
return <WordCountModal {...args} />
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2022-03-28 06:23:21 -04:00
|
|
|
title: 'Editor / Modals / Word Count',
|
2021-03-05 08:00:21 -05:00
|
|
|
component: WordCountModal,
|
|
|
|
args: {
|
2021-04-27 03:52:58 -04:00
|
|
|
show: true,
|
2021-03-05 08:00:21 -05:00
|
|
|
},
|
2022-05-16 05:38:20 -04:00
|
|
|
argTypes: {
|
|
|
|
handleHide: { action: 'close modal' },
|
2024-10-10 03:26:18 -04:00
|
|
|
...bsVersionDecorator.argTypes,
|
2022-05-16 05:38:20 -04:00
|
|
|
},
|
|
|
|
decorators: [ScopeDecorator],
|
2021-01-06 05:38:25 -05:00
|
|
|
}
|