-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(umi-plugin): support to render side menu in layout (#10)
- Loading branch information
1 parent
f2bf4b7
commit bb9c881
Showing
8 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 18 additions & 8 deletions
26
...lugin-father-doc/src/fixtures/layout.less → ...father-doc/src/themes/default/layout.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
@import 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism.css'; | ||
@import 'https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css'; | ||
|
||
@menu-width: 300px; | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
:global { | ||
#root { | ||
margin: 0 auto; | ||
max-width: 800px; | ||
min-height: 100vh; | ||
padding: 20px 40px; | ||
background-color: #fff; | ||
} | ||
|
||
.markdown-body .anchor .octicon { | ||
font-size: 20px; | ||
} | ||
} | ||
|
||
.wrapper { | ||
min-height: 100vh; | ||
padding-left: @menu-width + 32px; | ||
padding-right: 32px; | ||
|
||
.menu { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
width: @menu-width; | ||
border-right: 1px solid #eee; | ||
box-sizing: border-box; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/umi-plugin-father-doc/src/themes/default/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Todo: fix definition files cannot be identified problem | ||
/// <reference path="../types/global.d.ts" /> | ||
/// <reference path="../types/typings.d.ts" /> | ||
|
||
import React, { Component, MouseEvent } from 'react'; | ||
import { IMenuItem } from '../../routes/getMenuFromRoutes'; | ||
import styles from './layout.less'; | ||
|
||
export interface ILayoutProps { | ||
menu: { | ||
items: IMenuItem[]; | ||
}; | ||
} | ||
|
||
export default class Layout extends Component<ILayoutProps> { | ||
handleMenuItemClick = (e: MouseEvent, path: string) => { | ||
window.g_history.push(path); | ||
e.preventDefault(); | ||
} | ||
|
||
render () { | ||
const { children, menu } = this.props; | ||
|
||
return ( | ||
<div className={styles.wrapper}> | ||
<div className={styles.menu}> | ||
<ul> | ||
{menu.items.map((item) => ( | ||
<li> | ||
<a | ||
href={item.path} | ||
onClick={e => this.handleMenuItemClick(e, item.path)} | ||
> | ||
{item.title} | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
{children} | ||
</div> | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/umi-plugin-father-doc/src/themes/typings/global.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { History } from 'history'; | ||
|
||
declare global { | ||
interface Window { | ||
g_history: History; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '*.less'; |