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

CSS cleanups, fixes, and reimplementations #1780

Merged
merged 37 commits into from
Oct 15, 2019
Merged

CSS cleanups, fixes, and reimplementations #1780

merged 37 commits into from
Oct 15, 2019

Conversation

nstepien
Copy link
Contributor

@nstepien nstepien commented Oct 9, 2019

Some things to note:

  • cells are now centered vertically by setting the line-height === row height.
    • This fixes header cells text not being vertically centered
    • We were previously using position: absolute; top: 50%; transform: translateY(-50%) which may hurt text rendering or layout times.
  • The generic editors should now be perfectly aligned with the formatters
  • Selected rows now have a hover style
  • cell actions icons are missing, should we add a dependency on some icons?

@nstepien nstepien requested a review from amanmahajan7 October 9, 2019 13:00
@nstepien nstepien self-assigned this Oct 9, 2019
@nstepien nstepien changed the title CSS cleanup CSS cleanups, fixes, and reimplementations Oct 9, 2019
isScrolling={isScrolling}
isRowSelected={isRowSelected}
onRowSelectionChange={onRowSelectionChange}
/>
{cellControls}
</div>
{tooltip && <span className="cell-tooltip-text">{tooltip}</span>}
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/adazzle/react-data-grid/pull/1773/files/cba04c56c295e32fa3f036cb6cd9dbd5f8d5ec60#r333000852

Thoughts about removing this here? Since the style is touched, if we want to remove, I bet it's better in this PR. Or we keep it for revisiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's do it in a separate PR.

@@ -22,6 +22,13 @@
width: 10px;
}

@supports (position: sticky) or (position: -webkit-sticky) {
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? Currently we render all the header cells and adjust the scrolleft on scroll

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also iterate through all the columns to set/unset the scroll position of each header row cells.

I figure we should optimize this for browsers that support sticky position, no?

@nstepien nstepien marked this pull request as ready for review October 11, 2019 18:18
Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

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

A few cleanup comments. Cell actions example does not work, I think we need to replace the icons. May be we can import material icon for examples?

@@ -39,10 +39,6 @@ export default class EditorContainer<R> extends React.Component<Props<R>, State>
const inputNode = this.getInputNode();
if (inputNode instanceof HTMLElement) {
inputNode.focus();
if (!this.getEditor().disableContainerStyles) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


const className = classNames('react-grid-HeaderCell', {
const className = classNames('react-grid-Cell', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename it to rdg-cell?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, there's still a lot of opportunities to clean up the existing stylesheets, and rename classes, but I've mostly focused on replacing bootstrap in this PR.


const className = classNames('react-grid-HeaderCell', {
const className = classNames('react-grid-Cell', {
'rdg-header-cell-resizable': column.resizable,
'react-grid-HeaderCell--frozen': isFrozen(column)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with react-grid-HeaderCell

}}
className="react-grid-HeaderRow"
className="rdg-header-row"
style={{ height: this.props.height }}
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 height (500) was needed to show the Dropdown filters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, imo we should just reuse the editor container for such custom filters, otherwise it makes it hard to work with overflow: hidden.

background-color: #66afe930;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.react-grid-Cell--frozen {
/* Should have a higher value than 1 to show in front of cell masks */
z-index: 2;
}
.rdg-last--frozen {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably rename it to rdg-cell-last

overflow: hidden;
height: inherit;
}

.react-grid-Cell.readonly {
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 all the styles?

react-grid-Cell.readonly
react-grid-cell .form-control-feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not, I haven't fully cleaned up this file.

}

.react-grid-checkbox:checked + .react-grid-checkbox-label:before {
.rdg-checkbox-label {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

.react-grid-HeaderCell--frozen:last-of-type {
box-shadow: 2px 0 5px -2px rgba(136, 136, 136, .3);
@supports (position: sticky) or (position: -webkit-sticky) {
.react-grid-HeaderCell--frozen {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can raname these classes as well

{content}
<span className="rdg-header-sort">{SORT_TEXT[sortDirection]}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we changed to MUI in this PR, should we change this as well to be an icon?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave it like this for now.

@@ -69,9 +69,9 @@ class CustomDragLayer extends Component {
if (c.formatter) {
const Formatter = c.formatter;
const dependentValues = typeof c.getRowMetaData === 'function' ? c.getRowMetaData(item, c) : {};
cells.push(<td key={`dragged-cell-${rowIdx}-${c.key}`} className="react-grid-Cell" style={{ padding: '5px' }}><Formatter dependentValues={dependentValues} value={item[c.key]} /></td>);
cells.push(<td key={`dragged-cell-${rowIdx}-${c.key}`} className="rdg-cell" style={{ padding: '5px' }}><Formatter dependentValues={dependentValues} value={item[c.key]} /></td>);
Copy link
Contributor

@qili26 qili26 Oct 15, 2019

Choose a reason for hiding this comment

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

{ padding: 5 }? Any insights why this is not moved to css?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR doesn't aim to fix every styling issues in the repo, it's just trying to address issues that arose after removing the bootstrap styles. There are too many things to fix or cleanup otherwise.

-webkit-appearance: none;
appearance: none;

box-sizing: border-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 to specify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's too big otherwise.

@@ -124,17 +122,12 @@ export default forwardRef(function Header<R>(props: HeaderProps<R>, ref: React.R
props.cellMetaData.onCellClick({ rowIdx: -1, idx: -1 });
}

const className = classNames('react-grid-Header', {
'react-grid-Header--resizing': resizing !== null
Copy link
Contributor

Choose a reason for hiding this comment

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

no more this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like we need it no.

color: #555555;
}

.rdg-sortable-header-cell {
cursor: pointer;
}

.rdg-header-sort {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe using flex and put 2 divs inside rather than just float: right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just works though?

Copy link
Contributor

Choose a reason for hiding this comment

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

My concern is that when the columns width is 100px while the header text width is like 200px, will the sort icon being pushed to next line or keep in the view. I believe using float: right will push it to next line. I am trying to run this PR in my local but having some packages installing issue.

@nstepien nstepien merged commit a007e17 into canary Oct 15, 2019
@nstepien nstepien deleted the ns-css branch October 15, 2019 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants