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

Use CSS Modules for page-list component #414

Merged
merged 10 commits into from
Nov 4, 2019
4 changes: 2 additions & 2 deletions src/components/__tests__/page-list.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env jest */

import PageList from '../page-list';
import PageList from '../page-list/page-list';
import React from 'react';
import {shallow} from 'enzyme';
import simplePages from '../../__mocks__/simple-pages.json';
Expand All @@ -27,7 +27,7 @@ describe('page-list', () => {
pages={simplePages}
/>
);
expect(pageList.find('.page-list tbody tr').first().childAt(1).text())
expect(pageList.find('tbody tr').first().childAt(1).text())
.toBe('NOAA - ncei.noaa.gov, EPA - www3.epa.gov');
});
});
33 changes: 33 additions & 0 deletions src/components/page-list/page-list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* ===== List View ===== */
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 you can remove this comment at the top since the CSS is now scoped at the component level, thanks!

.page-list {
table-layout: fixed;
}

.page-list>tbody>tr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a space between each selector like so? .page-list > tbody > tr

Same for each of the styles below.

cursor: pointer;
}

.page-list>tbody>tr:hover {
background-color: #eee;
}

.page-list>td {
overflow-wrap: break-word;
word-wrap: break-word;
}

.page-list>th[data-name="capture-date"] {
width: 12%;
}

.page-list>th[data-name="site"] {
width: 15%;
}

.page-list>th[data-name="page-name"] {
width: 33%;
}

.page-list>th[data-name="url"] {
width: 40%;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a newline at the end of the file?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can have this formatted for you automatically if you add the EditorConfig plugin to your text editor: https://editorconfig.org

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {dateFormatter, formatSites} from '../scripts/formatters';
import Loading from './loading';
import {dateFormatter, formatSites} from '../../scripts/formatters';
import Loading from '../loading';
import React from 'react';
import SearchBar from './search-bar/search-bar';

import SearchBar from '../search-bar/search-bar';
import './page-list.css';
/**
* These props also inherit from React Router's RouteComponent props
* @typedef {Object} PageListProps
Expand Down Expand Up @@ -47,7 +47,7 @@ export default class PageList extends React.Component {
return (
<div className="row">
<div className="col-md-12">
<table className="page-list table">
<table className="table" styleName="page-list" >
<thead>
{this.renderHeader()}
</thead>
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class PageList extends React.Component {
const onClick = this.didClickRow.bind(this, record);

return (
<tr key={record.uuid} onClick={onClick}>
<tr styleName="page-list" key={record.uuid} onClick={onClick}>
Mr0grog marked this conversation as resolved.
Show resolved Hide resolved
<td>{record.latest ? dateFormatter.format(record.latest.capture_time) : 'No saved versions'}</td>
<td>{formatSites(record.tags)}</td>
<td>{record.title}</td>
Expand Down
2 changes: 1 addition & 1 deletion src/components/web-monitoring-ui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Loading from './loading';
import LoginForm from './login-form';
import NavBar from './nav-bar';
import PageDetails from './page-details';
import PageList from './page-list';
import PageList from './page-list/page-list';
import VersionRedirect from './version-redirect';

const configuration = window.webMonitoringConfig;
Expand Down
34 changes: 0 additions & 34 deletions src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,6 @@ body {
padding: 0;
}

/* ===== List View ===== */
.page-list {
table-layout: fixed;
}

.page-list tbody tr {
cursor: pointer;
}

.page-list tbody tr:hover {
background-color: #eee;
}

.page-list td {
overflow-wrap: break-word;
word-wrap: break-word;
}

.page-list th[data-name="capture-date"] {
width: 12%;
}

.page-list th[data-name="site"] {
width: 15%;
}

.page-list th[data-name="page-name"] {
width: 33%;
}

.page-list th[data-name="url"] {
width: 40%;
}

/* ===== Page Detail View ===== */
.page-title {
font-size: 1.5em;
Expand Down