Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
74f0a0aa
Commit
74f0a0aa
authored
7 years ago
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow menu icon config as img url or ReactNode
parent
84dd304e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
src/components/SiderMenu/SiderMenu.js
src/components/SiderMenu/SiderMenu.js
+16
-2
src/components/SiderMenu/index.less
src/components/SiderMenu/index.less
+7
-0
No files found.
src/components/SiderMenu/SiderMenu.js
View file @
74f0a0aa
...
@@ -6,6 +6,20 @@ import styles from './index.less';
...
@@ -6,6 +6,20 @@ import styles from './index.less';
const
{
Sider
}
=
Layout
;
const
{
Sider
}
=
Layout
;
const
{
SubMenu
}
=
Menu
;
const
{
SubMenu
}
=
Menu
;
// Allow menu.js config icon as string or ReactNode
// icon: 'setting',
// icon: 'http://demo.com/icon.png',
// icon: <Icon type="setting" />,
const
getIcon
=
(
icon
)
=>
{
if
(
typeof
icon
===
'
string
'
&&
icon
.
indexOf
(
'
http
'
)
===
0
)
{
return
<
img
src
=
{
icon
}
alt
=
"
icon
"
className
=
{
styles
.
icon
}
/>
;
}
if
(
typeof
icon
===
'
string
'
)
{
return
<
Icon
type
=
{
icon
}
/>
;
}
return
icon
;
};
export
default
class
SiderMenu
extends
PureComponent
{
export
default
class
SiderMenu
extends
PureComponent
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
...
@@ -84,7 +98,7 @@ export default class SiderMenu extends PureComponent {
...
@@ -84,7 +98,7 @@ export default class SiderMenu extends PureComponent {
title
=
{
title
=
{
item
.
icon
?
(
item
.
icon
?
(
<
span
>
<
span
>
<
Icon
type
=
{
item
.
icon
}
/
>
{
getIcon
(
item
.
icon
)}
<
span
>
{
item
.
name
}
<
/span
>
<
span
>
{
item
.
name
}
<
/span
>
<
/span
>
<
/span
>
)
:
item
.
name
)
:
item
.
name
...
@@ -95,7 +109,7 @@ export default class SiderMenu extends PureComponent {
...
@@ -95,7 +109,7 @@ export default class SiderMenu extends PureComponent {
<
/SubMenu
>
<
/SubMenu
>
);
);
}
}
const
icon
=
item
.
icon
&&
<
Icon
type
=
{
item
.
icon
}
/>
;
const
icon
=
getIcon
(
item
.
icon
)
;
return
item
.
hideInMenu
?
null
:
return
item
.
hideInMenu
?
null
:
(
(
<
Menu
.
Item
key
=
{
item
.
key
||
item
.
path
}
>
<
Menu
.
Item
key
=
{
item
.
key
||
item
.
path
}
>
...
...
This diff is collapsed.
Click to expand it.
src/components/SiderMenu/index.less
View file @
74f0a0aa
...
@@ -23,12 +23,19 @@
...
@@ -23,12 +23,19 @@
font-weight: 600;
font-weight: 600;
}
}
}
}
.sider {
.sider {
min-height: 100vh;
min-height: 100vh;
box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
position: relative;
position: relative;
z-index: 10;
z-index: 10;
}
}
.icon {
width: 14px;
margin-right: 10px;
}
:global {
:global {
.drawer .drawer-content {
.drawer .drawer-content {
background: #001529;
background: #001529;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment