Giter VIP home page Giter VIP logo

fusion-plugin-material-ui's Introduction

fusion-plugin-material-ui

This plugin will provide drop in support for "just works" server side rendering material-ui components.


Table of contents


Installation

yarn add fusion-plugin-material-ui

Usage

// ButtonWrap.js
import React from 'react';
import Button from '@material-ui/styles/Button';

export ButtonWrap = () => (
  <Button
    variant="contained"
    color="primary"
  >
    with bacon
  </Button>
)

Setup

The Basic

// main.js
import React from 'react';
import App from 'fusion-react';

import MuiThemeProvider, {MuiThemeProviderToken} from 'fusion-plugin-material-ui';

export default () => {
  const app = new App(root);
  // will use the default theme
  app.register(MuiThemeProviderToken, MuiThemeProvider);
  return app;
}

Custom Theme

https://material-ui.com/customization/themes/

// main.js
import React from 'react';
import App from 'fusion-react';

import MuiThemeProvider, {MuiThemeProviderToken, MuiThemeToken} from 'fusion-plugin-material-ui';
import {createMuiTheme} from '@material-ui/styles/createMuiTheme';

export default () => {
  const app = new App(root);
  app.register(MuiThemeToken, createMuiTheme({ fooColor: '#ba4' }));
  app.register(MuiThemeProviderToken, MuiThemeProvider);
  return app;
}

API

Registration API

MuiThemeProvider
import MuiThemeProvider from 'fusion-plugin-material-ui';

Adds the MuiThemeProvider from @material-ui/core and handles server side rendering. Typically registered with MuiThemeProviderToken

MuiThemeProviderToken
import {MuiThemeProviderToken} from 'fusion-plugin-material-ui';

Typicall registered with MuiThemeProvider

Dependencies

MuiThemeToken
import {MuiThemeToken} from 'fusion-plugin-material-ui';

Register with your own custom material-ui theme. Optional

JssToken
import {JssToken} from 'fusion-plugin-material-ui';

Register with your own custom jss instance. Optional  

 

 

 

 

Advanced Usage

Custom JSS instance

This requires management of a custom jss instance.

https://material-ui.com/customization/css-in-js/

// main.js
import React from 'react';
import App from 'fusion-react';

import {create} from 'jss';
import MuiThemeProvider, {JssToken, MuiThemeProviderToken} from 'fusion-plugin-material-ui';

export default () => {
  const app = new App(root);

  app.register(JssToken, create());
  app.register(MuiThemeProviderToken, MuiThemeProvider);
  return app;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.