This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaccordion.tsx
More file actions
66 lines (62 loc) · 3.24 KB
/
accordion.tsx
File metadata and controls
66 lines (62 loc) · 3.24 KB
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
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SampleBase } from '../common/sample-base';
import { createElement } from '@syncfusion/ej2-base';
import { AccordionComponent, AccordionItemDirective, AccordionItemsDirective } from '@syncfusion/ej2-react-navigations';
import './accordion.css';
export class Accordion extends SampleBase<{}, {}> {
// Assigning badge data
public badgeContent: string[] = ['7 New', '27 New', '2 New', '14 New'];
public accordionTemplate(): JSX.Element {
return (
<div style={{ display: 'none' }}>
<li className='msg'>
<span className='e-acrdn-icons e-content-icon people'></span>
Message Thread
</li>
<li className='msg'>
<span className='e-acrdn-icons e-content-icon people'></span>
Message Thread
</li>
</div>
);
}
public onCreated() {
// Appending Badge component after the accordion rendered in created event
let element: HTMLElement = document.getElementById('accordion');
let iconElement: HTMLElement[] = Array.prototype.slice.call((element as HTMLElement).querySelectorAll('.e-toggle-icon'));
for (let i: number = 0; i < iconElement.length; i++) {
// Success Badge Element
let badge: HTMLSpanElement = createElement('span', { className: 'e-badge e-badge-success' });
badge.textContent = this.badgeContent[i];
iconElement[i].appendChild(badge);
}
}
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<div className="sample_container badge-accordion">
<AccordionComponent id="accordion" created={this.onCreated.bind(this)}>
<AccordionItemsDirective>
<AccordionItemDirective header='Robert' iconCss='e-people e-acrdn-icons' expanded={true} content={this.accordionTemplate} />
<AccordionItemDirective header='Kevin' iconCss='e-people e-acrdn-icons' content={this.accordionTemplate} />
<AccordionItemDirective header='Eric' iconCss='e-people e-acrdn-icons' content={this.accordionTemplate} />
<AccordionItemDirective header='Peter' iconCss='e-people e-acrdn-icons' content={this.accordionTemplate} />
</AccordionItemsDirective>
</AccordionComponent>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates the integration of badges into the accordion component to display the thread notification count.</p>
</div>
<div id="description">
<p>The badge can be integrated into the accordion with the help of templates to display the count of new messages in the
message thread. Here, the success badge is used in the accordion. To add success badge, add the
<code>.e-badge-success</code> class.
</p>
</div>
</div>
)
}
}