Skip to content

Commit 208f7a4

Browse files
committed
Modify component loading style.
1 parent 6124fba commit 208f7a4

File tree

5 files changed

+39
-27
lines changed

5 files changed

+39
-27
lines changed

templates/default/home/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ body, html { background: #fff; }
1010
.jumbotron {
1111
position: absolute;
1212
background-color: #383838;
13+
top: 56px;
1314
left: 0;
1415
right: 0;
1516
padding-top: 80px;

theme/default/component/Header/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
position: relative;
2323
position: fixed;
2424
width: 100%;
25+
top: 0;
2526
z-index: 9;
2627
.wapper {
2728
max-width: 1200px;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.loading {
22
text-align: center;
33
min-height: 450px;
4+
padding: 30px 0;
45
}

theme/default/layout/IndexLayout.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
background-color: transparent;
33
box-shadow: 0 0 0 #fff;
44
border-bottom: 0;
5+
background-color: rgba(255, 255, 255, 0.9);
6+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
57
}
68
.wapper {
79
min-height: 500px;
10+
padding: 57px 0 0 0;
811
}

theme/default/lib/markdown/index.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import hljs from 'highlight.js';
66
import styles from './style/index.less';
77
import InlineCode from './InlineCode';
88
import Link from './Link';
9+
import Loading from '../../component/Loading/';
910

1011
hljs.configure({
1112
tabReplace: ' ', // 2 spaces
@@ -23,7 +24,7 @@ export default class Markdown extends React.Component {
2324
constructor(props) {
2425
super(props);
2526
this.state = {
26-
markdownStr: 'loading ... ',
27+
markdownStr: '',
2728
};
2829
}
2930
componentWillMount() {
@@ -53,36 +54,41 @@ export default class Markdown extends React.Component {
5354
}
5455
render() {
5556
const { mdconf: { title, layout } } = this.props;
57+
const { markdownStr } = this.state;
5658
return (
5759
<div className={styles.markdownWapper}>
5860
{title && layout !== 'IndexLayout' && <h1 id={title} className={styles.pageTitle}>{title}</h1>}
59-
<ReactMarkdown
60-
className={classNames('markdown', styles.markdown)}
61-
source={this.state.markdownStr}
62-
escapeHtml={false}
63-
renderers={{
64-
code: InlineCode,
65-
link: Link,
66-
linkReference: Link,
67-
}}
68-
allowNode={(node, index, parent) => {
69-
if (node.type === 'html') {
70-
// if (/<!--([^]+?)-->/.test(node.value)) return false;
71-
// const scriptValue = node.value.match(/<script.*?>(.*?)<\/script>/ig);
72-
// node.value.replace(/<script.*?>(.*?)<\/script>/, (te) => {
73-
// console.log('te:', te);
74-
// });
75-
}
76-
// 判断 上一个节点是否为 <!--DemoStart -->
77-
if (node.type === 'code' && parent.children && parent.children.length > 0 && parent.children[index - 1]) {
78-
const parentNode = parent.children[index - 1];
79-
if (parentNode.type === 'html' && /<!--\s?DemoStart\s?-->/.test(parentNode.value)) {
80-
node.value = `__dome__${node.value}`;
61+
{markdownStr ? (
62+
<ReactMarkdown
63+
className={classNames('markdown', styles.markdown)}
64+
source={markdownStr}
65+
escapeHtml={false}
66+
renderers={{
67+
code: InlineCode,
68+
link: Link,
69+
linkReference: Link,
70+
}}
71+
allowNode={(node, index, parent) => {
72+
if (node.type === 'html') {
73+
// if (/<!--([^]+?)-->/.test(node.value)) return false;
74+
// const scriptValue = node.value.match(/<script.*?>(.*?)<\/script>/ig);
75+
// node.value.replace(/<script.*?>(.*?)<\/script>/, (te) => {
76+
// console.log('te:', te);
77+
// });
8178
}
82-
}
83-
return node;
84-
}}
85-
/>
79+
// 判断 上一个节点是否为 <!--DemoStart -->
80+
if (node.type === 'code' && parent.children && parent.children.length > 0 && parent.children[index - 1]) {
81+
const parentNode = parent.children[index - 1];
82+
if (parentNode.type === 'html' && /<!--\s?DemoStart\s?-->/.test(parentNode.value)) {
83+
node.value = `__dome__${node.value}`;
84+
}
85+
}
86+
return node;
87+
}}
88+
/>
89+
) : (
90+
<Loading />
91+
)}
8692
</div>
8793
);
8894
}

0 commit comments

Comments
 (0)