-
Notifications
You must be signed in to change notification settings - Fork 126
/
SidePage.stories.tsx
838 lines (772 loc) · 25.9 KB
/
SidePage.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
import React from 'react';
import { CSFStory } from 'creevey';
import { SidePage } from '../SidePage';
import { Button } from '../../Button';
import { Input } from '../../Input';
import { Textarea } from '../../Textarea';
import { Toggle } from '../../Toggle';
import { Modal } from '../../Modal';
import { Gapped } from '../../Gapped';
import { Shape } from '../../../typings/utility-types';
import { delay } from '../../../lib/utils';
const textSample = (
<p>
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound
to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free
hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best,
every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of
duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances
accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures
to secure other greater pleasures, or else he endures pains to avoid worse pains.
</p>
);
interface SampleProps {
children?: React.ReactNode;
total?: number;
current?: number;
ignoreBackgroundClick?: boolean;
blockBackground?: boolean;
withContent?: boolean;
withLongBody?: boolean;
withoutFooter?: boolean;
withoutHeader?: boolean;
}
interface SampleState {
open: boolean;
panel: boolean;
}
class Sample extends React.Component<SampleProps, SampleState> {
public state: SampleState = {
open: false,
panel: false,
};
public open = () => this.setState({ open: true });
public close = () => this.setState({ open: false });
public renderSidePage = (): React.ReactNode => (
<SidePage
width={785}
onClose={this.close}
ignoreBackgroundClick={this.props.ignoreBackgroundClick}
blockBackground={this.props.blockBackground}
>
{!this.props.withoutHeader && (
<SidePage.Header>
Title
{this.props.total && this.props.total > 1 && ` ${this.props.current} / ${this.props.total}`}
</SidePage.Header>
)}
<SidePage.Body>
<div style={{ padding: '0 35px 35px 35px' }}>
{this.props.total && this.props.current && this.props.total > this.props.current && (
<Sample
current={this.props.current + 1}
total={this.props.total}
ignoreBackgroundClick={this.props.ignoreBackgroundClick}
withContent={this.props.withContent}
blockBackground={this.props.blockBackground}
/>
)}
<div>
<Toggle
checked={this.state.panel}
onValueChange={() => this.setState(({ panel }) => ({ panel: !panel }))}
/>{' '}
Panel {this.state.panel ? 'enabled' : 'disabled'}
</div>
{this.props.children}
{this.props.withContent && (
<div
style={
this.props.withLongBody
? {
background: `repeating-linear-gradient(
60deg,
#fafafa,
#fafafa 20px,
#dfdede 20px,
#dfdede 40px
)`,
height: 2000,
}
: undefined
}
>
{textSample}
{textSample}
</div>
)}
</div>
</SidePage.Body>
{!this.props.withoutFooter && (
<SidePage.Footer panel={this.state.panel}>
<Button size="large" onClick={this.close}>
Close
</Button>
</SidePage.Footer>
)}
</SidePage>
);
public render() {
return (
<div>
{this.state.open && this.renderSidePage()}
<Button onClick={this.open}>Open SidePage</Button>
</div>
);
}
}
interface SampleConfiguratorProps {
ignoreBackgroundClick: boolean;
blockBackground: boolean;
withContent: boolean;
onChange: (name: string) => void;
}
class SampleConfigurator extends React.Component<SampleConfiguratorProps> {
public render() {
return (
<div>
<div>
<Toggle
checked={this.props.ignoreBackgroundClick}
onValueChange={() => this.props.onChange('ignoreBackgroundClick')}
/>{' '}
ignoreBackgroundClick {this.props.ignoreBackgroundClick ? 'enabled' : 'disabled'}
</div>
<div>
<Toggle checked={this.props.blockBackground} onValueChange={() => this.props.onChange('blockBackground')} />{' '}
blockBackground {this.props.blockBackground ? 'enabled' : 'disabled'}
</div>
<div>
<Toggle checked={this.props.withContent} onValueChange={() => this.props.onChange('withContent')} />{' '}
withContent {this.props.withContent ? 'enabled' : 'disabled'}
</div>
</div>
);
}
}
class SidePageWithScrollableContent extends React.Component<{}, {}> {
public render() {
return (
<div style={{ width: '300px' }}>
<Sample total={1} current={1} ignoreBackgroundClick withContent />
{textSample}
{textSample}
</div>
);
}
}
interface SidePageWithInputInHeaderState {
opened: boolean;
}
class SidePageWithInputInHeader extends React.Component<{}, SidePageWithInputInHeaderState> {
public state: SidePageWithInputInHeaderState = {
opened: false,
};
public render() {
const sidePage = (
<SidePage onClose={this.close}>
<SidePage.Header>
<Input placeholder="Some input placeholder..." value="" />{' '}
<Input size="large" placeholder="Some large input placeholder..." value="" />
<br />
<Textarea placeholder="Some textarea placeholder" value="" />
</SidePage.Header>
<SidePage.Body>
<p style={{ marginLeft: 30 }}>Use rxjs operators with react hooks</p>
</SidePage.Body>
</SidePage>
);
return (
<div style={{ width: '300px' }}>
{this.state.opened && sidePage}
<Button onClick={this.open}>Open side page</Button>
</div>
);
}
public open = () => {
this.setState({ opened: true });
};
public close = () => {
this.setState({ opened: false });
};
}
class SidePageOverAnotherSidePage extends React.Component<{}> {
public render() {
return <Sample current={1} total={5} ignoreBackgroundClick blockBackground withContent />;
}
}
interface SidePageWithCloseConfigurationState {
ignoreBackgroundClick: boolean;
blockBackground: boolean;
withContent: boolean;
}
class SidePageWithCloseConfiguration extends React.Component<{}, SidePageWithCloseConfigurationState> {
public state: SidePageWithCloseConfigurationState = {
ignoreBackgroundClick: false,
blockBackground: false,
withContent: false,
};
public render() {
return (
<div style={{ width: '300px' }}>
<Sample
total={1}
current={1}
ignoreBackgroundClick={this.state.ignoreBackgroundClick}
blockBackground={this.state.blockBackground}
withContent={this.state.withContent}
/>
<SampleConfigurator
onChange={name => {
const propertyName = name as keyof SidePageWithCloseConfigurationState;
this.setState(
(state: SidePageWithCloseConfigurationState) =>
({ [propertyName]: !state[propertyName] } as Shape<SidePageWithCloseConfigurationState>),
);
}}
ignoreBackgroundClick={this.state.ignoreBackgroundClick}
blockBackground={this.state.blockBackground}
withContent={this.state.withContent}
/>
</div>
);
}
}
interface SidePageWithModalInsideState {
isModalOpened: boolean;
ignoreBackgroundClick: boolean;
blockBackground: boolean;
withContent: boolean;
}
class SidePageWithModalInside extends React.Component<{}, SidePageWithModalInsideState> {
public state: SidePageWithModalInsideState = {
isModalOpened: false,
ignoreBackgroundClick: true,
blockBackground: false,
withContent: false,
};
public render() {
return (
<div>
{this.state.isModalOpened && this.renderModal()}
<Sample current={1} ignoreBackgroundClick={false} blockBackground>
<Button onClick={() => this.setState({ isModalOpened: true })}>Открыть modal</Button>
<div>
{textSample}
{textSample}
</div>
</Sample>
{textSample}
{textSample}
</div>
);
}
private renderModal = () => (
<Modal onClose={() => this.setState({ isModalOpened: false })} ignoreBackgroundClick>
<Modal.Header>Хедер</Modal.Header>
</Modal>
);
}
class SidePageWithLeftPosition extends React.Component<{
disableAnimations?: boolean;
close: () => void;
}> {
public render() {
return (
<SidePage disableAnimations={this.props.disableAnimations} fromLeft={true} onClose={this.props.close}>
<SidePage.Header>test</SidePage.Header>
<SidePage.Body>
<SidePage.Container>
{textSample}
{textSample}
</SidePage.Container>
</SidePage.Body>
<SidePage.Footer panel>
<Gapped>
<Button use="primary">Ok</Button>
<Button onClick={this.props.close}>Cancel</Button>
</Gapped>
</SidePage.Footer>
</SidePage>
);
}
}
class LeftSidePageWithRightSidePage extends React.Component<{
disableAnimations?: boolean;
}> {
public render() {
return (
<>
<SidePage disableAnimations={this.props.disableAnimations} fromLeft={true}>
<SidePage.Header>test</SidePage.Header>
<SidePage.Body>
<SidePage.Container>
{textSample}
{textSample}
</SidePage.Container>
</SidePage.Body>
<SidePage.Footer panel>
<Gapped>
<Button use="primary">Ok</Button>
<Button>Cancel</Button>
</Gapped>
</SidePage.Footer>
</SidePage>
<SidePage disableAnimations={this.props.disableAnimations} fromLeft={false}>
<SidePage.Header>test</SidePage.Header>
<SidePage.Body>
<SidePage.Container>
{textSample}
{textSample}
</SidePage.Container>
</SidePage.Body>
<SidePage.Footer panel>
<Gapped>
<Button use="primary">Ok</Button>
<Button>Cancel</Button>
</Gapped>
</SidePage.Footer>
</SidePage>
</>
);
}
}
class SimpleSidePage extends React.Component<{}, {}> {
public render() {
return (
<div style={{ width: '300px' }}>
<Sample total={1} current={1} ignoreBackgroundClick withContent />
</div>
);
}
}
interface WithVariableContentState {
opened: boolean;
sidePageText: string[];
pageText: string[];
}
class WithVariableContent extends React.Component<{}, WithVariableContentState> {
public state: WithVariableContentState = {
opened: false,
sidePageText: [],
pageText: [],
};
public render() {
return (
<div>
{this.state.opened && this.renderSidePage()}
{this.state.pageText.map((t, i) => (
<div key={i} style={{ height: '400px' }}>
Use rxjs operators with react hooks
</div>
))}
<Button onClick={this.open}>Open</Button>
</div>
);
}
private renderSidePage = () => (
<SidePage onClose={this.close} blockBackground>
<SidePage.Header>Title</SidePage.Header>
<SidePage.Body>
<div
style={{
background: `repeating-linear-gradient(
60deg,
#fafafa,
#fafafa 20px,
#dfdede 20px,
#dfdede 40px
)`,
height: 600,
padding: '20px 0',
}}
>
<SidePage.Container>
<p>Use rxjs operators with react hooks</p>
{this.state.sidePageText.map((_item, index) => (
<div key={index} style={{ height: '400px' }}>
Use rxjs operators with react hooks
</div>
))}
</SidePage.Container>
</div>
</SidePage.Body>
<SidePage.Footer panel>
<Button onClick={this.hendleAddSidePageClick}>Add sidePageText</Button>
<Button onClick={this.handleAddPageClick}>Add pageText</Button>
</SidePage.Footer>
</SidePage>
);
private hendleAddSidePageClick = () => {
this.setState(state => ({ sidePageText: [...state.sidePageText, 'text'] }));
};
private handleAddPageClick = () => {
this.setState(state => ({ pageText: [...state.pageText, 'text'] }));
};
private open = () => {
this.setState({ opened: true });
};
private close = () => {
this.setState({ opened: false });
};
}
class TestUpdateLayoutMethod extends React.Component {
public static ChildComp = class ChildComp extends React.Component {
public state = {
content: false,
};
public toggleContent = () => {
this.setState({ content: !this.state.content });
};
public render() {
return <div>{this.state.content && <TestUpdateLayoutMethod.Content />}</div>;
}
};
public static Content = () => (
<div
style={{
background: `repeating-linear-gradient(
60deg,
#fafafa,
#fafafa 20px,
#dfdede 20px,
#dfdede 40px
)`,
height: 2000,
}}
/>
);
public state = {
content: false,
};
private sidePage: SidePage | null = null;
// @ts-ignore: only refers to a type, but is being used as a namespace here
private childComp: TestUpdateLayoutMethod.ChildComp | null = null;
public updateLayout = () => {
if (this.sidePage) {
this.sidePage.updateLayout();
}
};
public toggleBodyContent = () => {
this.setState({ content: !this.state.content });
};
public toggleChildContent = () => {
if (this.childComp) {
this.childComp.toggleContent();
}
};
public render() {
return (
<SidePage blockBackground ref={ref => (this.sidePage = ref)}>
<SidePage.Header>Title</SidePage.Header>
<SidePage.Body>
<SidePage.Container>
{this.state.content && <TestUpdateLayoutMethod.Content />}
<TestUpdateLayoutMethod.ChildComp ref={ref => (this.childComp = ref)} />
</SidePage.Container>
</SidePage.Body>
<SidePage.Footer>
<div id="buttons">
<Gapped gap={10}>
<Button data-tid="toggle-body-content" onClick={this.toggleBodyContent}>
Toggle Body Content
</Button>
<Button data-tid="toggle-child-component-content" onClick={this.toggleChildContent}>
Toggle Child Component Content
</Button>
<Button data-tid="update" onClick={this.updateLayout}>
Update
</Button>
</Gapped>
</div>
</SidePage.Footer>
</SidePage>
);
}
}
class WithLongTitle extends React.Component {
public state = {
title: `On the other hand, we denounce with righteous indignation and dislike,
who are so beguiled and demoralized by the charms of pleasure of the
moment.`,
};
public render() {
const { title } = this.state;
return (
<SidePage>
<SidePage.Header>{title}</SidePage.Header>
<SidePage.Body>
<div
id="scrollable-content"
style={{
height: 1500,
background: `repeating-linear-gradient(
60deg,
#fafafa,
#fafafa 20px,
#dfdede 20px,
#dfdede 40px
)`,
}}
/>
</SidePage.Body>
<SidePage.Footer>
<Gapped gap={15}>
<Button
onClick={() =>
this.setState({
title: title + title,
})
}
>
Increase Title
</Button>
<Button
onClick={() =>
this.setState({
title: title.slice(title.length / 2),
})
}
>
Decrease Title
</Button>
</Gapped>
</SidePage.Footer>
</SidePage>
);
}
}
export default { title: 'SidePage' };
export const WithScrollableParentContent = () => <SidePageWithScrollableContent />;
WithScrollableParentContent.story = {
name: 'With scrollable parent content',
parameters: { creevey: { skip: [true] } },
};
export const WithInputInHeader = () => <SidePageWithInputInHeader />;
WithInputInHeader.story = { name: 'With Input in header', parameters: { creevey: { skip: [true] } } };
export const SidePageOverAnotherSidePageStory: CSFStory<JSX.Element> = () => <SidePageOverAnotherSidePage />;
SidePageOverAnotherSidePageStory.story = {
name: 'SidePage over another SidePage',
parameters: {
creevey: {
tests: {
async ['open internal side-page']() {
await this.browser
.actions({ bridge: true })
.click(this.browser.findElement({ css: 'button' }))
.perform();
await this.browser
.actions({ bridge: true })
.click(this.browser.findElement({ css: '[data-comp-name~="SidePageBody"] button' }))
.perform();
await this.expect(await this.browser.takeScreenshot()).to.matchImage('open internal side-page');
},
async ['close internal side-page']() {
await this.browser
.actions({ bridge: true })
.click(this.browser.findElement({ css: 'button' }))
.perform();
await this.browser
.actions({ bridge: true })
.click(this.browser.findElement({ css: '[data-comp-name~="SidePageBody"] button' }))
.perform();
await this.browser
.actions({ bridge: true })
.click(this.browser.findElement({ css: '.react-ui:last-child [data-comp-name~="SidePageFooter"] button' }))
.perform();
await this.expect(await this.browser.takeScreenshot()).to.matchImage('close internal side-page');
},
},
},
},
};
export const SidePageWithConfiguration = () => <SidePageWithCloseConfiguration />;
SidePageWithConfiguration.story = { name: 'SidePage with configuration', parameters: { creevey: { skip: [true] } } };
export const SidePageWithModal = () => <SidePageWithModalInside />;
SidePageWithModal.story = { name: 'SidePage with Modal', parameters: { creevey: { skip: [true] } } };
export const DisabledSidePage = () => (
<SidePage disableClose>
<SidePage.Header>Disabled</SidePage.Header>
<SidePage.Body>Content of disabled body</SidePage.Body>
</SidePage>
);
DisabledSidePage.story = { name: 'Disabled SidePage', parameters: { creevey: { skip: [true] } } };
export const SidePageWithLeftPositionStory = () => (
<SidePageWithLeftPosition close={() => undefined} disableAnimations />
);
SidePageWithLeftPositionStory.story = {
name: 'SidePage with left position',
parameters: { creevey: { captureElement: null } },
};
export const LeftSidePageWithRightSidePageStory = () => <LeftSidePageWithRightSidePage disableAnimations />;
LeftSidePageWithRightSidePageStory.story = {
name: 'Left SidePage With Right SidePage',
parameters: { creevey: { captureElement: null } },
};
export const Simple: CSFStory<JSX.Element> = () => <SimpleSidePage />;
Simple.story = {
parameters: {
creevey: {
tests: {
async ['open side-page']() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'button' }))
.perform();
await this.expect(await this.browser.takeScreenshot()).to.matchImage('open side-page');
},
},
},
},
};
export const BodyWithoutFooter: CSFStory<JSX.Element> = () => <Sample withoutFooter withContent withLongBody />;
BodyWithoutFooter.story = {
name: 'Body without Footer',
parameters: {
creevey: {
tests: {
async ['scroll to bottom']() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'button' }))
.perform();
await this.browser.executeScript(function() {
const sidepageContainer = window.document.querySelector('[data-tid="SidePage__container"]');
// @ts-ignore
sidepageContainer.scrollTop = 3000;
});
await delay(1000);
await this.expect(await this.browser.takeScreenshot()).to.matchImage('scroll to bottom');
},
},
},
},
};
export const BodyWithoutHeader: CSFStory<JSX.Element> = () => <Sample withoutHeader withContent withLongBody />;
BodyWithoutHeader.story = {
name: 'Body without Header',
parameters: {
creevey: {
tests: {
async ['open side-page without header']() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'button' }))
.perform();
await delay(100);
await this.expect(await this.browser.takeScreenshot()).to.matchImage('open side-page without header');
},
},
},
},
};
export const SidePageWithVariableContent = () => <WithVariableContent />;
SidePageWithVariableContent.story = {
name: 'SidePage with variable content',
parameters: { creevey: { skip: [true] } },
};
export const TestUpdateLayoutMethodStory: CSFStory<JSX.Element> = () => <TestUpdateLayoutMethod />;
TestUpdateLayoutMethodStory.story = {
name: 'test updateLayout method',
parameters: {
creevey: {
tests: {
async idle() {
await this.expect(await this.browser.takeScreenshot()).to.matchImage('idle');
},
async ['Body content has been changed']() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '[data-tid="toggle-body-content"]' }))
.perform();
await this.expect(await this.browser.takeScreenshot()).to.matchImage('Body content has been changed');
},
async ['child component content has been changed']() {
await delay(1000);
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '[data-tid="toggle-child-component-content"]' }))
.perform();
await this.expect(await this.browser.takeScreenshot()).to.matchImage(
'child component content has been changed',
);
},
async ['update layout']() {
await delay(1000);
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '[data-tid="toggle-child-component-content"]' }))
.pause(1000)
.click(this.browser.findElement({ css: '[data-tid="update"]' }))
.perform();
await delay(1000);
await this.expect(await this.browser.takeScreenshot()).to.matchImage('update layout');
},
},
},
},
};
export const WithScrollableParentContentAndScrollingBeforeOpen = () => (
<div style={{ width: '300px' }}>
{textSample}
{textSample}
{textSample}
{textSample}
<Sample total={1} current={1} ignoreBackgroundClick withContent />
{textSample}
{textSample}
</div>
);
WithScrollableParentContentAndScrollingBeforeOpen.story = {
name: 'With scrollable parent content and scrolling before open',
parameters: { creevey: { skip: [true] } },
};
export const WithLongTitleStory: CSFStory<JSX.Element> = () => <WithLongTitle />;
WithLongTitleStory.story = {
name: 'With long title',
parameters: {
creevey: {
tests: {
async ['not fixed']() {
await this.expect(await this.browser.takeScreenshot()).to.matchImage('not fixed');
},
async ['fixed close element']() {
await this.browser.executeScript(function() {
const sidePageContainer = window.document.querySelector('[data-tid="SidePage__container"]');
const sidePageHeader = window.document.querySelector('[data-comp-name~="SidePageHeader"]');
const fixedHeaderHeight = 50;
// @ts-ignore
sidePageContainer.scrollTop = (sidePageHeader.offsetHeight - fixedHeaderHeight) / 2;
});
await delay(1000);
await this.expect(await this.browser.takeScreenshot()).to.matchImage('fixed close element');
},
async ['fixed header']() {
await this.browser.executeScript(function() {
const sidePageContainer = window.document.querySelector('[data-tid="SidePage__container"]');
const sidePageHeader = window.document.querySelector('[data-comp-name~="SidePageHeader"]');
const fixedHeaderHeight = 50;
// @ts-ignore
sidePageContainer.scrollTop = sidePageHeader.offsetHeight - fixedHeaderHeight;
});
await delay(1000);
await this.expect(await this.browser.takeScreenshot()).to.matchImage('fixed header');
},
},
},
},
};