Modulize component for home page

This commit is contained in:
Chun-MingChen
2018-09-16 16:57:14 +08:00
parent b68a63fed1
commit 8b3fc4a662
8 changed files with 125 additions and 157 deletions

19
website/core/button.js Normal file
View File

@@ -0,0 +1,19 @@
const React = require('react');
class Button extends React.Component {
render() {
return (
<div className="pluginWrapper buttonWrapper">
<a className="button" href={this.props.href} target={this.props.target}>
{this.props.children}
</a>
</div>
);
}
}
Button.defaultProps = {
target: '_self',
};
module.exports = Button;

View File

@@ -0,0 +1,50 @@
const React = require('react');
const Button = require('./button');
const utils = require('./utils');
const siteConfig = require(process.cwd() + '/siteConfig.js');
const SplashContainer = props => (
<div className="homeContainer">
<div className="homeSplashFade">
<div className="wrapper homeWrapper">{props.children}</div>
</div>
</div>
);
const ProjectTitle = () => (
<h2 className="projectTitle">
{siteConfig.title}
<small>{siteConfig.tagline}</small>
</h2>
);
const PromoSection = props => (
<div className="section promoSection">
<div className="promoRow">
<div className="pluginRowBlock">{props.children}</div>
</div>
</div>
);
class HomeSplash extends React.Component {
render() {
let language = this.props.language || '';
return (
<SplashContainer>
{/* <Logo img_src={imgUrl('docusaurus.svg')} /> */}
<div className="inner">
<ProjectTitle />
<PromoSection>
<Button href={utils.docUrl('getting-started.html', language)}>Try It Out</Button>
<Button href='./storybook/index.html'>Live Demo</Button>
<Button href={utils.docUrl('table-props.html', language)}>Docs</Button>
</PromoSection>
</div>
</SplashContainer>
);
}
}
module.exports = HomeSplash;

View File

@@ -0,0 +1,19 @@
const siteConfig = require(process.cwd() + '/siteConfig.js');
const imgUrl = (img) => {
return siteConfig.baseUrl + 'img/' + img;
}
const docUrl = (doc, language) => {
return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc;
}
const pageUrl = (page, language) => {
return siteConfig.baseUrl + (language ? language + '/' : '') + page;
}
module.exports = {
imgUrl,
docUrl,
pageUrl
}

View File

@@ -7,116 +7,49 @@
const React = require('react');
// Built-in library
const CompLibrary = require('../../core/CompLibrary.js');
const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;
const siteConfig = require(process.cwd() + '/siteConfig.js');
function imgUrl(img) {
return siteConfig.baseUrl + 'img/' + img;
}
function docUrl(doc, language) {
return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc;
}
function pageUrl(page, language) {
return siteConfig.baseUrl + (language ? language + '/' : '') + page;
}
class Button extends React.Component {
render() {
return (
<div className="pluginWrapper buttonWrapper">
<a className="button" href={this.props.href} target={this.props.target}>
{this.props.children}
</a>
</div>
);
}
}
Button.defaultProps = {
target: '_self',
};
const SplashContainer = props => (
<div className="homeContainer">
<div className="homeSplashFade">
<div className="wrapper homeWrapper">{props.children}</div>
</div>
</div>
);
const Logo = props => (
<div className="projectLogo">
<img src={props.img_src} />
</div>
);
const ProjectTitle = props => (
<h2 className="projectTitle">
{siteConfig.title}
<small>{siteConfig.tagline}</small>
</h2>
);
const PromoSection = props => (
<div className="section promoSection">
<div className="promoRow">
<div className="pluginRowBlock">{props.children}</div>
</div>
</div>
);
class HomeSplash extends React.Component {
render() {
let language = this.props.language || '';
return (
<SplashContainer>
{/* <Logo img_src={imgUrl('docusaurus.svg')} /> */}
<div className="inner">
<ProjectTitle />
<PromoSection>
<Button href={docUrl('getting-started.html', language)}>Try It Out</Button>
<Button href='./storybook/index.html'>Live Demo</Button>
<Button href={docUrl('table-props.html', language)}>Docs</Button>
</PromoSection>
</div>
</SplashContainer>
);
}
}
// Customized component and utils
const HomeSplash = require(process.cwd() + '/core/homeSplash.js');
const utils = require(process.cwd() + '/core/utils');
const imgUrl = utils.imgUrl;
const Block = props => (
<Container
padding={['bottom', 'top']}
id={props.id}
background={props.background}>
<GridBlock align={ props.align || 'center' } contents={props.children} layout={props.layout} />
background={props.background}
>
<GridBlock
align={ props.align || 'center' }
layout={props.layout}
className={props.className}
contents={props.children}
/>
</Container>
);
const Features = props => (
<Block layout="fourColumn">
const Features = () => (
<Block layout="threeColumn" className="feature-block">
{[
{
content: 'Sortable, Row Selection, Cell Editor, Row Expand, Column Filter Pagination etc.',
// image: imgUrl('docusaurus.svg'),
image: imgUrl('icon/bulb.svg'),
imageAlign: 'top',
title: 'Rich Functionality',
},
{
content: 'Configurable and customizable table',
// image: imgUrl('docusaurus.svg'),
image: imgUrl('icon/tool.svg'),
imageAlign: 'top',
title: 'Customization',
},
{
content: 'Satisfy for Redux/Mobx or any other state management tool.',
// image: imgUrl('docusaurus.svg'),
image: imgUrl('icon/store.svg'),
imageAlign: 'top',
title: 'Remote',
},
@@ -124,20 +57,11 @@ const Features = props => (
</Block>
);
// const FeatureCallout = props => (
// <div
// className="productShowcaseSection paddingBottom"
// style={{textAlign: 'center'}}>
// <h2>Feature Callout</h2>
// <MarkdownBlock>These are features of this project</MarkdownBlock>
// </div>
// );
const LearnHow = props => (
const LearnHow = () => (
<Block background="light" align="left">
{[
{
content: 'Intuitive to use. <br/>Compatitable for Bootstrap 3 and 4. <br/>Better than legacy react-bootstrap-table2!!<br/>',
content: 'Intuitive to use. <br/>Compatible for Bootstrap 3 and 4. <br/>Better than legacy react-bootstrap-table2!!<br/>',
image: imgUrl('react-bootstrap-table2-sample.png'),
imageAlign: 'right',
title: 'react-bootstrap-table2',
@@ -146,62 +70,6 @@ const LearnHow = props => (
</Block>
);
const TryOut = props => (
<Block id="try">
{[
{
content: 'Talk about trying this out',
image: imgUrl('docusaurus.svg'),
imageAlign: 'left',
title: 'Try it Out',
},
]}
</Block>
);
const Description = props => (
<Block background="dark">
{[
{
content: 'This is another description of how this project is useful',
image: imgUrl('docusaurus.svg'),
imageAlign: 'right',
title: 'Description',
},
]}
</Block>
);
const Showcase = props => {
if ((siteConfig.users || []).length === 0) {
return null;
}
const showcase = siteConfig.users
.filter(user => {
return user.pinned;
})
.map((user, i) => {
return (
<a href={user.infoLink} key={i}>
<img src={user.image} title={user.caption} />
</a>
);
});
return (
<div className="productShowcaseSection paddingBottom">
<h2>{"Who's Using This?"}</h2>
<p>This project is used by all these people</p>
<div className="logos">{showcase}</div>
<div className="more-users">
<a className="button" href={pageUrl('users.html', props.language)}>
More {siteConfig.title} Users
</a>
</div>
</div>
);
};
class Index extends React.Component {
render() {
let language = this.props.language || '';
@@ -211,11 +79,7 @@ class Index extends React.Component {
<HomeSplash language={language} />
<div className="mainContainer">
<Features />
{/* <FeatureCallout /> */}
<LearnHow />
{/* <TryOut />
<Description />
<Showcase language={language} /> */}
</div>
</div>
);

View File

@@ -13,4 +13,8 @@
}
@media only screen and (min-width: 1500px) {
}
}
.feature-block .blockImage img {
width: 48px;
}

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3.55 18.54l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8zM11 22.45h2V19.5h-2v2.95zM4 10.5H1v2h3v-2zm11-4.19V1.5H9v4.81C7.21 7.35 6 9.28 6 11.5c0 3.31 2.69 6 6 6s6-2.69 6-6c0-2.22-1.21-4.15-3-5.19zm5 4.19v2h3v-2h-3zm-2.76 7.66l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4z"/>
</svg>

After

Width:  |  Height:  |  Size: 405 B

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M20 4H4v2h16V4zm1 10v-2l-1-5H4l-1 5v2h1v6h10v-6h4v6h2v-6h1zm-9 4H6v-4h6v4z"/>
</svg>

After

Width:  |  Height:  |  Size: 224 B

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path clip-rule="evenodd" fill="none" d="M0 0h24v24H0z"/>
<path d="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"/>
</svg>

After

Width:  |  Height:  |  Size: 338 B