Skip to content

Commit 37e9bbd

Browse files
author
kubraturan
committed
Icon property has been added to Dropdown Component
1 parent 66ce3b8 commit 37e9bbd

3 files changed

Lines changed: 51 additions & 4 deletions

File tree

example/App.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import FaSearch from 'react-icons/lib/fa/search';
1818
import FaComments from 'react-icons/lib/fa/comments';
1919
import FaClose from 'react-icons/lib/fa/close';
2020
import FaMenu from 'react-icons/lib/md/more-vert';
21+
import FaSquare from 'react-icons/lib/md/crop-square';
22+
2123
import {
2224
format,
2325
} from 'timeago.js';
@@ -133,6 +135,7 @@ export class App extends Component {
133135
dropdownMenu: (
134136
<Dropdown
135137
animationPosition="norteast"
138+
title='Dropdown Title'
136139
buttonProps={{
137140
type: "transparent",
138141
color: "#cecece",
@@ -142,9 +145,33 @@ export class App extends Component {
142145
}
143146
}}
144147
items={[
145-
'Menu Item1',
146-
'Menu Item2',
147-
'Menu Item3',
148+
{
149+
icon: {
150+
component: <FaSquare />,
151+
float: 'left',
152+
color: 'red',
153+
size: 22,
154+
},
155+
text: 'Menu Item'
156+
},
157+
{
158+
icon: {
159+
component: <FaSquare/>,
160+
float: 'left',
161+
color: 'purple',
162+
size: 22,
163+
},
164+
text: 'Menu Item'
165+
},
166+
{
167+
icon: {
168+
component: <FaSquare/>,
169+
float: 'left',
170+
color: 'yellow',
171+
size: 22,
172+
},
173+
text: 'Menu Item'
174+
},
148175
]} />
149176
),
150177
};

src/Dropdown/Dropdown.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
z-index: 99999;
1919
}
2020

21+
.rce-dropdown-title {
22+
font-size: 14px;
23+
color: '#000';
24+
font-weight: 500;
25+
}
26+
2127
.rce-dropdown.dropdown-show{
2228
animation: dropdown-scaling 0.2s ease forwards;
2329
display: flex;

src/Dropdown/Dropdown.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,24 @@ export class Dropdown extends Component {
3636
{ 'dropdown-show': this.state.show === true })}>
3737

3838
<ul>
39+
{
40+
this.props.title &&
41+
<span className='rce-dropdown-title'>{this.props.title}</span>
42+
}
3943
{
4044
this.props.items.map((x, i) => (
4145
<li key={i} onMouseDown={(e) => this.props.onSelect(i)}>
42-
<a>{x}</a>
46+
{
47+
x.icon ?
48+
<span className='rce-button-icon--container'>
49+
{(x.icon.float === 'right' || !x.icon.float) && <a>{x.text}</a>}
50+
51+
<span style={{ float: x.icon.float, color: x.icon.color, fontSize: x.icon.size || 12 }} className={classNames('rce-button-icon', x.icon.className)}>{x.icon.component}</span>
52+
53+
{x.icon.float === 'left' && <a>{x.text}</a>}
54+
</span>
55+
: <a>{x.text}</a>
56+
}
4357
</li>
4458
))
4559
}

0 commit comments

Comments
 (0)