Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Removes styler code #1250

Merged
merged 3 commits into from
Oct 12, 2017
Merged

Removes styler code #1250

merged 3 commits into from
Oct 12, 2017

Conversation

el-mapache
Copy link
Contributor

@el-mapache el-mapache commented Oct 5, 2017

I think that any place we used the styler we can just leverage the classnames packages directly.

That package also provides the de-dupe functionality that the styler added, and now we don't have to include the styler object in every single component.

@el-mapache el-mapache self-assigned this Oct 5, 2017
@el-mapache el-mapache changed the title Removes style code Removes styler code Oct 5, 2017
import style from 'cloudgov-style/css/cloudgov-style.css';

import createStyler from '../util/create_styler';
import classnames from 'classnames';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the accepted convention is to import classNames from 'classnames'; (i.e. camelCase classNames).

const styleClass = props.styleClass && `panel-row-${this.props.styleClass}`;
const mainClass = props.styleClass !== 'boxed' && 'panel-row';
const { props } = this;
const classes = classnames({
Copy link
Contributor

Choose a reason for hiding this comment

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

Were you also meant to pass this.props.className to this?

render() {
const descClass = this.props.description && 'panel-documentation-desc';

return (
<div className={ this.styler('panel-documentation', descClass) }>
<div className={ `panel-documentation ${descClass}` }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you want to use classNames here to remove the tmp var?

<div className={classNames('panel-documentation', { 'panel-documentation-desc': this.props.description })}>

render() {
const alignClass = `panel-actions-${this.props.align}`;
return (
<span className={ this.styler('panel-actions', alignClass) }>
<span className={ `panel-actions ${alignClass}` }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe remove the alignClass tmp var and just put panel-actions-${this.props.align} straight in the string.

<div className={ this.styler('notification', statusClass, 'test-notification') }>
<div className={ this.styler('notification-wrap') }>
<p className={ this.styler('notification-message', 'test-notification-message') }>
<div className={ `notification ${statusClass} test-notification` }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put statusClass contents straight in string and remove tmp var?

render() {
const props = this.props;
const alignClass = `elastic_line-item-${props.align}`;

return (
<div className={ this.styler('elastic_line-item', alignClass) }>
<div className={ `elastic_line-item ${alignClass}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline alignClass?

this.state = {};
this.styler = createStyler(style);
}

render() {
const props = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related, but if you're here, might want to remove props tmp var - not really conventional to pull out this.props into a var.

render() {
const props = this.props;
const statusClass = `count_status-${props.health.toLowerCase()}`;

return (
<div className={ this.styler('count_status', statusClass) }>
<div className={ this.styler('count_status-icon') }>
<div className={`count_status ${statusClass}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline statusClass?

{ title }
</h4>
</header>
);
}

return (
<div className={ [this.props.className, this.styler('complex_list')].join(' ') }>
<div className={ [this.props.className, 'complex_list'].join(' ') }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use classNames to do the joining? Also because this.props.className might be falsey so this could render undefined complex_list right?

@@ -56,7 +48,7 @@ export default class AppQuicklook extends React.Component {
const statusClass = !isHealthyApp(app) && 'status-error';

return (
<a className={ this.styler(statusClass) } href={ this.appHref() }>
<a className={ statusClass } href={ this.appHref() }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use classNames inline? Makes the semantics of !isHealthyApp(app) && 'status-error' clearer:

<a className={classNames({ 'status-error': !isHealthyApp(app) })} />

@el-mapache
Copy link
Contributor Author

Yep, I was planning on going back in and using the classnames package where appropriate in a follow-up PR, but I suppose I can roll it into this one!

@jonathaningram
Copy link
Contributor

LGTM ⭐️

@jcscottiii jcscottiii merged commit f625bae into master Oct 12, 2017
@jcscottiii jcscottiii deleted the ab-remove-styler branch October 12, 2017 18:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants