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

Migrate to plain CSS (remove CSS modules) #659

Merged
merged 12 commits into from
Oct 18, 2017
Merged

Conversation

Benaiah
Copy link
Contributor

@Benaiah Benaiah commented Oct 6, 2017

- Summary

Migrate to plain CSS and remove CSS modules. Closes #418.

- Test plan

Manually tested visual elements; I would really appreciate help checking all the nooks and crannies of the UI. Most CSS should be exactly equivalent but there's always the chance I missed something.

- Description for the changelog

Migrate to plain CSS and remove CSS modules.

- A picture of a cute animal (not mandatory but encouraged)

image

@@ -0,0 +1 @@
export const prefixer = prefix => className => `ncms-${ prefix }-${ className }`;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document the prefixer.

Is there a runtime impact of this implementation? Is my browser going to be building these strings every time it renders a component? If we're writing the style name in the css file, why not use a static name in the templates?

@tech4him1
Copy link
Contributor

tech4him1 commented Oct 10, 2017

Did we decide to explicitly write ncms- in all the CMS files? or should we just add that when we run PostCSS?

@Benaiah
Copy link
Contributor Author

Benaiah commented Oct 10, 2017

@tech4him1 we haven’t found any good way to do that, other than remaining on CSS modules. We have some global class styles as well for various reasons, so simply prefixing every class wouldn’t work, even if I knew of a tool that did that for us.

@erquhart
Copy link
Contributor

erquhart commented Oct 11, 2017

@Benaiah I'm thinking:

  1. Use nc as the prefix.
  2. Drop the prefixer.

If anyone really feels this is the wrong direction, please comment, but otherwise we need to get this ready and merged ahead of UI implementations.

@Benaiah
Copy link
Contributor Author

Benaiah commented Oct 11, 2017

@erquhart sounds good to me; I'll try to get that done & pushed today.

@Benaiah Benaiah changed the title Migrate to plain CSS (remove CSS modules) (WIP) Migrate to plain CSS (remove CSS modules) Oct 11, 2017
@Benaiah
Copy link
Contributor Author

Benaiah commented Oct 11, 2017

Note that this is currently WIP - while the styles should be working, I may need to clean up the output of the script I used to replace prefixer calls, and I still need to actually remove the prefixer and the lines which import it.

@@ -1,16 +1,16 @@
@import "../UI/theme.css";

.input {
.nc-fileControlinput {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing - after fileControl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll get this fixed.

@@ -37,6 +37,6 @@ storiesOf('Card', module)
<img src="http://www.top13.net/wp-content/uploads/2015/10/perfectly-timed-funny-cat-pictures-5.jpg" />
<h1>Now with footer.</h1>
<p>header and footer elements are also not subject to margin</p>
<footer style={styles.footer}>&copy; Thousand Cats Corp</footer>
<footer style={styles("footer")}>&copy; Thousand Cats Corp</footer>
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be a class in place of style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this should stay the way it was before, and it got changed to this when changing the prefixer to a function. In this case the styles object is a manually constructed object earlier in the file, and has nothing to do with the prefixer or CSS modules. I'll change this back.

@@ -31,12 +31,12 @@ export default class ControlPane extends Component {
const value = entry.getIn(['data', fieldName]);
const metadata = fieldsMetaData.get(fieldName);
const errors = fieldsErrors.get(fieldName);
const labelClass = errors ? styles.labelWithError : styles.label;
const labelClass = errors ? `nc-controlPane-label nc-controlPane-labelWithError` : 'nc-controlPane-label';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Quotes here should be fixed.

import stickyStyles from '../UI/Sticky/Sticky.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.

Remove extra blank lines from edited JS files.

@@ -4,7 +4,7 @@ import { Map, fromJS } from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { resolveWidget } from '../Widgets';
import ControlHOC from '../Widgets/ControlHOC';
import styles from './ControlPane.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.

Remove extra blank lines from edited JS files.

@@ -8,7 +8,7 @@ import AppBar from "react-toolbox/lib/app_bar";
import FontIcon from "react-toolbox/lib/font_icon";
import FindBar from "../FindBar/FindBar";
import { stringToRGB } from "../../lib/textHelper";
import styles from "./AppHeader.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.

Remove extra blank lines from edited JS files.

@@ -4,7 +4,7 @@ import Input from "react-toolbox/lib/input";
import Button from "react-toolbox/lib/button";
import { Card, Icon } from "../../components/UI";
import logo from "../git-gateway/netlify_logo.svg";
import styles from "../git-gateway/AuthenticationPage.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.

Remove extra blank lines from edited JS files.

@@ -11,7 +11,7 @@ import { MARK_COMPONENTS, NODE_COMPONENTS } from './components';
import RULES from './rules';
import plugins, { EditListConfigured } from './plugins';
import onKeyDown from './keys';
import styles from './index.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.

Remove extra blank lines from edited JS files.

@@ -2,8 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Map } from 'immutable';
import { resolveWidget } from '../Widgets';
import controlStyles from '../ControlPanel/ControlPane.css';
import styles from './ObjectControl.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.

Remove extra blank lines from edited JS files.

@@ -21,8 +21,7 @@ import AppHeader from '../components/AppHeader/AppHeader';
import { Loader, Toast } from '../components/UI/index';
import { getCollectionUrl, getNewEntryUrl } from '../lib/urlHelper';
import { SIMPLE, EDITORIAL_WORKFLOW } from '../constants/publishModes';
import styles from './App.css';
import sidebarStyles from './Sidebar.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.

Remove extra blank lines from edited JS files.

@@ -6,7 +6,7 @@ import { loadEntries } from '../actions/entries';
import { selectEntries } from '../reducers';
import { Loader } from '../components/UI';
import EntryListing from '../components/EntryListing/EntryListing';
import styles from "./CollectionPage.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.

Remove extra blank lines from edited JS files.

@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import ReactSidebar from 'react-sidebar';
import _ from 'lodash';
import { openSidebar } from '../actions/globalUI';
import styles from './Sidebar.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.

Remove extra blank lines from edited JS files.

@Benaiah Benaiah changed the title (WIP) Migrate to plain CSS (remove CSS modules) Migrate to plain CSS (remove CSS modules) Oct 13, 2017
Copy link
Contributor

@erquhart erquhart left a comment

Choose a reason for hiding this comment

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

Partial review just to get it out, more coming.

@@ -1,31 +1,31 @@
.root {
.nc-gitGatewayAuthenticationPage-root {
Copy link
Contributor

Choose a reason for hiding this comment

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

After this is merged, we need to follow up and condense duplicate styles, such as those shared between the git gateway and github auth pages. Also, classnames need to be structured subject-first, so we'd have nc-auth styles that apply to all auth page implementations, and then nc-auth-git-gateway or nc-auth-github for specifics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Those were my thoughts as well, I just figured they were out of scope for this PR.

margin-left: 2%;
}

.homeLink .icon {
.nc-appHeader-homeLink &icon {
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -1,61 +1,62 @@
@import "../UI/theme";
@import '../UI/theme.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed, theme.css should simply be imported in the master file before this.

@@ -1,6 +1,6 @@
@import '../UI/theme';
@import '../UI/theme.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't import here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, for some reason I had thought this was necessary to get the theme variables in this file. Reading the docs on it that's clearly not the case - not sure where I got that idea,

@@ -1,39 +1,39 @@
@import '../UI/theme';
@import '../UI/theme.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -9,7 +9,6 @@ import ControlPane from '../ControlPanel/ControlPane';
import PreviewPane from '../PreviewPane/PreviewPane';
import Toolbar from './EntryEditorToolbar';
import { StickyContext } from '../UI/Sticky/Sticky';
import styles from './EntryEditor.css';
import stickyStyles from '../UI/Sticky/Sticky.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

css import

@erquhart erquhart merged commit 7dd8ca1 into master Oct 18, 2017
@tech4him1 tech4him1 deleted the migrate-to-plain-css branch October 18, 2017 18:34
talves pushed a commit that referenced this pull request Oct 26, 2017
* Migrate to plain CSS (remove CSS modules)

Change `prefixer` to a function instead of a proxy

* Switch prefix to `nc`

* Replace prefixer with literal class names

* Remove prefixer

* Fix migration errors

* fix compose migrations

* Remove unnecessary theme imports

* Remove old CSS import

* fix sticky toolbar positioning

* update to cssnano v4 so preset is used

* fix css pseudo selectors

* update lockfile
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.

Migrate to plain (post-processed) CSS
4 participants