Browse Source

read demo from demo folder

pull/4/head
afc163 10 years ago
parent
commit
d83608dff4
  1. 14
      components/select/demo/basic.md
  2. 6
      static/code.jsx
  3. 2
      static/style.css
  4. 6
      theme/templates/layout.html
  5. 11
      theme/theme.js

14
components/select/demo/basic.md

@ -0,0 +1,14 @@
# 基本型
- description: 你说什么我还是听不清。
---
````html
<select>
<option>选项一</option>
<option>选项二</option>
<option>选项三</option>
</select>
````

6
static/code.jsx

@ -6,6 +6,7 @@ var CodeBox = React.createClass({
};
},
componentDidMount: function() {
this.props.src = this.props.src.replace(/\.md$/, '.html');
$.get('/' + this.props.src).then(function(data) {
var item = $(data);
item.find('.highlight').appendTo(item);
@ -23,7 +24,10 @@ var CodeBox = React.createClass({
render: function() {
var html = this.state.html;
return (
<div className="code-box" onClick={this.handleClick} dangerouslySetInnerHTML={{__html: html}}></div>
<div className="code-box"
onClick={this.handleClick}
dangerouslySetInnerHTML={{__html: html}}>
</div>
);
}
});

2
static/style.css

@ -379,7 +379,7 @@ footer ul li > a {
.main-container {
width: calc(100% - 240px);
padding: 30px 40px;
padding: 30px 40px 80px;
-webkit-animation: xRightMatrix .5s ease-out .5s backwards;
animation: xRightMatrix .5s ease-out .5s backwards;
}

6
theme/templates/layout.html

@ -97,8 +97,10 @@
<script type="text/jsx">
React.render(
<CodeBoxes>
<CodeBox src="components/button/demo/basic.html"></CodeBox>
<CodeBox src="components/button/demo/basic.html"></CodeBox>
{%- set items = resource.pages|under(post.meta.directory) %}
{%- for item in items %}
<CodeBox src="{{item.meta.filepath}}"></CodeBox>
{%- endfor %}
</CodeBoxes>,
document.getElementById('code-boxes')
);

11
theme/theme.js

@ -48,6 +48,17 @@ module.exports = function(nico) {
}).filter(function(item) {
return item;
}));
},
under: function(pages, directory) {
var ret = [];
Object.keys(pages).forEach(function(key) {
var page = pages[key];
console.log(key, directory);
if (key.indexOf(directory + '/demo/') === 0) {
ret.push(page);
}
});
return ret;
}
};

Loading…
Cancel
Save