Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCD-1309 Fix/css refactor 2 #326

Merged
merged 12 commits into from
Aug 6, 2018
20 changes: 8 additions & 12 deletions src/DataModelGraph/DataModelGraph.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';

import { createNodesAndEdges } from './utils';
import SvgGraph from './SvgGraph';
import ToggleButton from './ToggleButton';

import './DataModelGraph.less';

/**
* Wraps SVG graph in a toggle button that toggles between 'full' and 'compact' view
Expand Down Expand Up @@ -36,15 +34,13 @@ class DataModelGraph extends React.Component {

if (graph.nodes.length !== 0 && 'count' in graph.nodes[graph.nodes.length - 1]) {
return (
<div style={{ position: 'relative' }}>
<ToggleButton>
<button
id="cd-dmg__toggle"
className="button-primary-white"
onClick={this.handleToggleClick}
>Toggle view
</button>
</ToggleButton>
<div className="data-model-graph">
<button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add the styles from ToggleButton?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToggleButton only has 2 css attribute top and left, They don't have any effect for the button in this page so I directly remove them

id="cd-dmg__toggle"
className="button-primary-white"
onClick={this.handleToggleClick}
>Toggle view
</button>
<SvgGraph nodes={graph.nodes} edges={graph.edges} />
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions src/DataModelGraph/DataModelGraph.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.data-model-graph {
position: relative;
}
7 changes: 2 additions & 5 deletions src/Explorer/ExplorerComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { computeLastPageSizes } from '../utils';
import { GQLHelper } from '../gqlHelper';
import getReduxStore from '../reduxStore';
import { ReduxExplorerTabPanel, ReduxSideBar } from './ReduxExplorer';
import './ExplorerComponent.less';

const gqlHelper = GQLHelper.getGQLHelper();

Expand Down Expand Up @@ -146,12 +147,8 @@ class ExplorerComponent extends Component {

render() {
this.updateFilesMap();
const style = {
display: 'flex',
padding: '40px 0px',
};
return (
<div style={style}>
<div className="explorer-component">
<ReduxSideBar />
<ReduxExplorerTabPanel />
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/Explorer/ExplorerComponent.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.explorer-component {
display: flex;
padding: 40px 0;
background-color: #ecebeb;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did this color come from?

}
13 changes: 4 additions & 9 deletions src/Index/page.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import React from 'react';
import styled from 'styled-components';
import Introduction from '../components/Introduction';
import { ReduxIndexButtonBar, ReduxIndexBarChart } from './reduxer';
import dictIcons from '../img/icons';
import { components } from '../params';
import getProjectsList from './relayer';

const IndexTop = styled.div`
width: 100%;
display: inline-flex;
`;
import './page.less';

class IndexPageComponent extends React.Component {
constructor(props) {
Expand All @@ -19,11 +14,11 @@ class IndexPageComponent extends React.Component {

render() {
return (
<div style={{ width: '1220px', padding: '75px 0px 40px 0px' }}>
<IndexTop>
<div className="index-page">
<div className="index-page__top">
<Introduction data={components.index.introduction} dictIcons={dictIcons} />
<ReduxIndexBarChart />
</IndexTop>
</div>
<ReduxIndexButtonBar />
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions src/Index/page.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.index-page {
width: 1220px;
padding: 75px 0px 40px 0px;
}

.index-page__top {
width: 100%;
display: inline-flex;
}
79 changes: 19 additions & 60 deletions src/Login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,9 @@
import React from 'react';
import styled from 'styled-components';
import querystring from 'querystring';
import PropTypes from 'prop-types'; // see https://github.com/facebook/prop-types#prop-types

import { basename, appname } from '../localconf';
import SlidingWindow from '../components/SlidingWindow';

const CentralBox = styled.div`
text-align: center;
width: 756px;
margin: auto 0px;
padding: 0px 100px;
vertical-align: middle;
display: table-cell;
color: #000000;
`;

const LoginFrame = styled.div`
display: table;
`;

const LeftBox = styled.div`
width: 257px;
text-align: center;
padding: 0px;
float: left;
min-height: 100%;
`;

const RightBox = styled.div`
width: 257px;
text-align: center;
padding: 0px;
float: right;
min-height: 100%;
`;

const Line = styled.hr`
width: 30px;
height: 5px;
text-align: center;
color: #9b9b9b;
background-color: #9b9b9b;
text-align: center;
margin: 17px auto;
`;

export const LoginButton = styled.a`
font-size: 1em;
`;
import './Login.less';

const getInitialState = height => ({ height });

Expand Down Expand Up @@ -93,29 +48,33 @@ class Login extends React.Component {
next = basename === '/' ? queryParams.next : basename + queryParams.next;
}
return (
<LoginFrame>
<LeftBox style={{ height: `${this.state.height}px` }}>
<div className="login-page">
<div className="login-page__side-box">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the height that was being passed to LeftBox?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height is not used, so removed.

<SlidingWindow
iconName={'gene'}
dictIcons={this.props.dictIcons}
height={this.state.height}
scrollY={window.scrollY}
/>
</LeftBox>
<CentralBox>
<div className="h1-typo" style={{ marginBottom: '11px', lineHeight: '40px' }}>{this.props.data.title}</div>
<div className="high-light" style={{ textTransform: 'uppercase' }}>{this.props.data.subTitle}</div>
<Line />
</div>
<div className="login-page__central-content">
<div className="h1-typo login-page__title">
{this.props.data.title}
</div>
<div className="high-light login-page__sub-title">
{this.props.data.subTitle}
</div>
<hr className="login-page__separator" />
<div className="body-typo">{this.props.data.text}</div>
{
this.props.providers.map(
p => (
<div key={p.id} style={{ margin: '25px 0px' }}>
<LoginButton href={`${p.url}?redirect=${window.location.origin}${next}`}>
<div key={p.id} className="login-page__entries">
<a href={`${p.url}?redirect=${window.location.origin}${next}`}>
<button className="button-primary-orange">
{p.name}
</button>
</LoginButton>
</a>
</div>
),
)
Expand All @@ -126,16 +85,16 @@ class Login extends React.Component {
{this.props.data.email}
</a>{'.'}
</div>
</CentralBox>
<RightBox style={{ height: `${this.state.height}px` }}>
</div>
<div className="login-page__side-box">
<SlidingWindow
iconName={'gene'}
dictIcons={this.props.dictIcons}
height={this.state.height}
scrollY={window.scrollY}
/>
</RightBox>
</LoginFrame>
</div>
</div>
);
}
}
Expand Down
45 changes: 45 additions & 0 deletions src/Login/Login.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.login-page {
display: flex;
justify-content: space-between;
}

.login-page__side-box {
width: 257px;
min-width: 257px;
text-align: center;
display: flex;
justify-content: center;
}

.login-page__side-box svg {
display: block;
}

.login-page__central-content {
text-align: center;
width: 756px;
margin: auto;
padding: 0 100px;
color: #000000;
}

.login-page__title {
margin-bottom: 11px;
line-height: 40px;
}

.login-page__sub-title {
text-transform: uppercase;
}

.login-page__separator {
width: 30px;
height: 5px;
text-align: center;
background-color: #9b9b9b;
margin: 17px auto;
}

.login-page__entries {
margin: 25px 0;
}
2 changes: 1 addition & 1 deletion src/Login/Login.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ describe('the Login component', () => {
/>
</StaticRouter>,
);
expect($vdom.find(LoginButton)).toHaveLength(testProps.providers.length);
expect($vdom.find('.login-page__entries')).toHaveLength(testProps.providers.length);
});
});
29 changes: 7 additions & 22 deletions src/Login/ProtectedContent.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { Redirect } from 'react-router-dom';
import styled from 'styled-components';
import PropTypes from 'prop-types';

import { fetchUser, fetchOAuthURL, fetchWithCreds, fetchProjects } from '../actions';
import Spinner from '../components/Spinner';
import getReduxStore from '../reduxStore';
Expand All @@ -12,13 +10,6 @@ import ReduxAuthTimeoutPopup from '../Popup/ReduxAuthTimeoutPopup';
let lastAuthMs = 0;
let lastTokenRefreshMs = 0;

const Body = styled.div`
background: ${props => props.background};
margin-left: auto;
margin-right: auto;
width: 1220px;
`;

/**
* Redux listener - just clears auth-cache on logout
*/
Expand Down Expand Up @@ -61,7 +52,6 @@ export function intersection(aList, bList) {
* @param history from react-router
* @param match from react-router.match
* @param public default false - set true to disable auth-guard
* @param background passed through to <Box background> wrapper for page.jsx-level background
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this param for anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some global searching, and found that background-color is only different for ExplorerComponent and was passed via background variable. So to make code cleaner I set background-color inside ExplorerComponent.less, and remove this background parameter from ProtectedContent component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, makes sense to me

* @param filter {() => Promise} optional filter to apply before rendering the child component
*/
class ProtectedContent extends React.Component {
Expand All @@ -76,13 +66,11 @@ class ProtectedContent extends React.Component {
},
).isRequired,
public: PropTypes.bool,
background: PropTypes.string,
filter: PropTypes.func,
};

static defaultProps = {
public: false,
background: null,
filter: null,
};

Expand Down Expand Up @@ -302,32 +290,29 @@ class ProtectedContent extends React.Component {
params = this.props.match.params || {};
}
window.scrollTo(0, 0);
const styleProps = {
background: this.props.background,
};
if (this.state.redirectTo) {
return (<Redirect to={this.state.redirectTo} />);
} else if (this.props.public && (!this.props.filter || typeof this.props.filter !== 'function')) {
return (
<Body {...styleProps}>
<div>
<Component params={params} location={this.props.location} history={this.props.history} />
</Body>
</div>
);
} else if (!this.props.public && this.state.authenticated) {
return (
<Body {...styleProps}>
<div>
<ReduxAuthTimeoutPopup />
<Component params={params} location={this.props.location} history={this.props.history} />
</Body>
</div>
);
} else if (this.props.public && this.state.dataLoaded) {
return (
<Body {...styleProps}>
<div>
<Component params={params} location={this.props.location} history={this.props.history} />
</Body>
</div>
);
}
return (<Body {...styleProps}><Spinner /></Body>);
return (<div><Spinner /></div>);
}
}

Expand Down
Loading