Refactor title function to new component

+ Use it in portfolio and pickstocks
This commit is contained in:
2018-04-11 12:15:22 +05:30
parent ae4a7a1605
commit 1b25de8eff
7 changed files with 63 additions and 26 deletions
@@ -0,0 +1,13 @@
.portfolio-manager {
margin: 2em 0;
}
.portfolio-manager .section-title .title-box {
color: #FFFFFF;
background-color: #287DCE;
box-shadow: .35em .35em rgba(0, 0, 0, 0.1);
}
.portfolio-manager .section-title .title-tail {
border-top: 1.5em solid #15569C;
}
@@ -1,8 +1,13 @@
/* eslint-disable react/prefer-stateless-function */ /* eslint-disable react/prefer-stateless-function */
import React, { Component } from 'react'; import React, { Component } from 'react';
import './PortfolioManager.css'; import './PortfolioManager.css';
import { SectionTitle } from '../SectionTitle';
class PortfolioManager extends Component { class PortfolioManager extends Component {
constructor() {
super();
}
render() { render() {
const portfolioScripPrices = this.props.portfolioScripPrices; const portfolioScripPrices = this.props.portfolioScripPrices;
@@ -15,6 +20,8 @@ class PortfolioManager extends Component {
this.props.addScripToPortfolio(scripName); this.props.addScripToPortfolio(scripName);
}} }}
> >
<SectionTitle titleText="Manage Portfolio" />
<div className="drop-block" style={{ width: '100%', height: '500px', border: '1px solid black' }} /> <div className="drop-block" style={{ width: '100%', height: '500px', border: '1px solid black' }} />
Please drop here Please drop here
<ul> <ul>
@@ -0,0 +1,19 @@
.section-title {
position: relative;
}
.section-title .title-box {
display: inline-block;
font-size: 1em;
padding: 1em 1.25em;
}
.section-title .title-tail {
position: absolute;
top: 100%;
left: 0;
width: 1em;
height: 1.5em;
border-top: 1.5em solid transparent;
border-left: 1em solid transparent;
}
@@ -0,0 +1,15 @@
import React, { Component } from 'react';
import './SectionTitle.css';
function SectionTitle(props) {
return (
<div className="section-title">
<div className="title-box">
{props.titleText.toUpperCase()}
</div>
<div className="title-tail" />
</div>
);
}
export { SectionTitle };
+1
View File
@@ -0,0 +1 @@
export { SectionTitle } from './SectionTitle';
+5 -14
View File
@@ -1,24 +1,15 @@
.stock-picker .title { .stock-picker {
position: relative; margin: 2em 0;
font-size: 1em;
color: #FFFFFF;
} }
.stock-picker .title .title-box { .stock-picker .section-title .title-box {
display: inline-block; color: #FFFFFF;
padding: 1em 1.25em;
background-color: #00B3D6; background-color: #00B3D6;
box-shadow: .35em .35em rgba(0, 0, 0, 0.1); box-shadow: .35em .35em rgba(0, 0, 0, 0.1);
} }
.stock-picker .title .title-tail { .stock-picker .section-title .title-tail {
position: absolute;
top: 100%;
left: 0;
width: 1em;
height: 1.5em;
border-top: 1.5em solid #098DAD; border-top: 1.5em solid #098DAD;
border-left: 1em solid transparent;
} }
.stock-picker .body { .stock-picker .body {
+2 -11
View File
@@ -1,6 +1,7 @@
/* eslint-disable react/prefer-stateless-function */ /* eslint-disable react/prefer-stateless-function */
import React, { Component } from 'react'; import React, { Component } from 'react';
import './StockPicker.css'; import './StockPicker.css';
import { SectionTitle } from '../SectionTitle';
class StockPicker extends Component { class StockPicker extends Component {
constructor() { constructor() {
@@ -75,16 +76,6 @@ class StockPicker extends Component {
return currentPageScripPrices; return currentPageScripPrices;
} }
static renderTitle() {
return (
<div className="title">
<div className="title-box">
PICK STOCKS
</div>
<div className="title-tail" />
</div>
);
}
renderScripBoxes() { renderScripBoxes() {
const currentPageScripPrices = this.getCurrentPageScripPrices(); const currentPageScripPrices = this.getCurrentPageScripPrices();
@@ -161,7 +152,7 @@ class StockPicker extends Component {
return ( return (
<div className="stock-picker"> <div className="stock-picker">
{StockPicker.renderTitle()} <SectionTitle titleText="Pick Stocks" />
<div className="body"> <div className="body">
<div className="page-description"> <div className="page-description">
{ {