Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
/ material-ui-sass Public archive

The Sass counterpart of the material-ui framework for React

License

Notifications You must be signed in to change notification settings

gpbl/material-ui-sass

Repository files navigation

material-ui-sass (discontinued)

As material-ui 0.8 moved to inline styles, this project has been discontinued.

If you still want to use material-ui, but don't want to use inline-styles, check out material-ui-with-sass



This is the Sass counterpart of the material-ui React/CSS framework, which originally uses Less for the styles.

Working with material-ui v0.7.5.

Join the chat at https://gitter.im/gpbl/material-ui-sass npm version

Installation and first setup

Using npm

npm install material-ui-sass

In your SCSS file you need to import directly from node_modules:

// when style.scss is in your project's root
@import "./node_modules/material-ui-sass/material-ui";

/* Your style here */
h1 { text-decoration: blink; }

Manual download

If you don't want to dig into node_modules in your .scss files, you can download the sources:

  • Download 0.7.5 version - working with material-ui v0.7.2
  • Unzip and copy the material-ui directory into your project, usually where you put your styles.
  • Import material-ui/main into your main .scss file:
@import "material-ui/main";

/* Your style here */
h1 { text-decoration: blink; }

Usage

The Sass files work with the original material-ui React components.

You can customize the default values overriding those in _custom-variables.scss. Include them before importing material-ui:

@import "my-custom-variables";
@import "material-ui/main";

/* Your style here */

Compiling

You must use autoprefixer when compiling your own CSS. The gulp sass task is an example on how to do it.

Extending typography classes

Material-ui includes a set of typography classes that you can use with SASS @extend in your own CSS:

.my-custom-headline {
  @extend %mui-font-style-headline;
}

Differences from the original version

The framework does not change HTML tags

The original version included a set of HTML tags: h1, h2... h6, p and hr. Those definitions are moved in _html.scss, which is not imported by default. You need to import that file manually if you still need them.

Contribute

I will try to keep the two frameworks in sync, but you can also help :-) If you find bugs or idea for improvements, feel free to add a new issue.

If you'd like to send pull requests, please try to adopt the current styles and conventions. For now, they need to be close to the original less code.

Development

When converting to Sass, I've found the material-ui docs site useful to preview my changes. After starting the doc site server, a watching gulp task overwrites the site's main.css with the Sass-compiled version. (This means you may need to sassify also the documentation site)

Clone with submodules

git clone --recursive https://github.com/gpbl/material-ui-sass.git
cd material-ui-sass

Start the dev environment

npm install    # will install material-ui-sass dep
npm run setup  # will install material-ui docs and deps
npm run dev    # run the dev environment

npm run dev should open automatically the documentation site. While editing the .scss files, you will see a live preview of the changes.

PS. You need to make a change in a .scss file to overwrite the original css.

Start migrating the .less files

I start from the github's compare view showing the diff from the previous version (e.g. the v0.4.0 tag) to the current release (e.g. the v0.5.0 tag – not master!). This view shows which .less files have been changed.

Then I keep opened 2 browser's windows: one displaying the the Sass version I'm working on (that running with npm run dev) and the other one showing http://www.material-ui.com, to help spotting the differences between the two versions.