Git Product home page Git Product logo

create-react-toolbox-emotion-app's People

Contributors

hawkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

create-react-toolbox-emotion-app's Issues

Document exact steps in process to configure project

This needs to go somewhere in the readme but I'm away so adding this as a TODO:

  1. Eject from Create React App (yarn run eject)
  2. Install react toolbox, emotion (yarn add react-toolbox emotion)
  3. Add emotion to babel config
  "babel": {
    "presets": [
      "react-app"
-   ]
+   ],
+   "plugins": [
+     "emotion/babel"
+   ]
  },
  1. Prevent CSS rules from being applied to *.emotion.css files in both Webpack configs
{
  test: /\.css$/,
+ exclude: /\.emotion\.css$/,
  use" [
    /* ... */
  ]
}
  1. Use React Toolbox's configuration for css-loader in dev config
          require.resolve('style-loader'),
-         {
-          loader: require.resolve('css-loader'),
-          options: {
-            importLoaders: 1,
-          },
-         },
+        "css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]"

... and in prod config

-               {
-                 loader: require.resolve('css-loader'),
-                 options: {
-                   importLoaders: 1,
-                   minimize: true,
-                   sourceMap: true,
-                 },
-               },
+               "css-loader?minimize&sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]",

TODO: Are string configs deprecated?

  1. Add config for *.emotion.css files in dev config
  {
    test: /\.css$\,
    /* ... */
  },
+ {
+   test: /\.emotion\.css$/,
+   use: [
+     "style-loader",
+     "css-loader"
+   ]
+ }

... and in prod config

  {
    test: /\.css$\,
    /* ... */
  },
+ {
+   test: /emotion\.css$/,
+   use: ExtractTextPlugin.extract({
+     fallback: "style-loader",
+     use: {
+       loader: "css-loader",
+       options: {
+         sourceMap: true
+       }
+     }
+   })
+ }
  1. Use CSS Modules instead of vanilla CSS insrc/App.css
+.app {
   text-align: center;
 }

+.appLogo {
+  animation: appLogoSpin infinite 20s linear;
   height: 80px;
 }

+.appHeader {
   background-color: #222;
   height: 150px;
   padding: 20px;
   color: white;
 }

+.appIntro {
   font-size: large;
 }

+@keyframes appLogoSpin {
   from { transform: rotate(0deg); }
   to { transform: rotate(360deg); }
 }

... and in src/App.js:

 import React, { Component } from "react";
 import logo from "./logo.svg";
+import styles from "./App.css";

 class App extends Component {
   render() {
     return (
+      <div className={styles.app}>
+        <div className={styles.appHeader}>
+          <img src={logo} className={styles.appLogo} alt="logo" />
           <h2>Welcome to React</h2>
         </div>
+        <p className={styles.appIntro}>
           To get started, edit <code>src/App.js</code> and save to reload.
         </p>
       </div>
     );
   }
 }

 export default App;
  1. Add demonstration files

src/css/theme.css:

$color-primary: $palette-pink-700;

src/reactToolboxExample.js:

import React from "react";
import { Button } from "react-toolbox/lib/button";

export default () => (
  <Button accent raised>
    Themed with `react-toolbox`
  </Button>
);

src/emotionExample.js:

import React from "react";
import styled from "emotion/react";

const H1 = styled.h1`
  color: #ff4081;
`;

const Code = styled.code`
  color: rgb(35, 93, 230);
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 4px;

  &:after { content: "\`" };
  &:before { content: "\`" };
`;

export default () => <H1>This was styled with <Code>emotion</Code>!</H1>;

include them in src/App.js:

 import React, { Component } from "react";
+import ThemeProvider from "react-toolbox/lib/ThemeProvider";
+import ReactToolboxExample from "./reactToolboxExample";
+import EmotionExample from "./emotionExample";
+import theme from "./css/theme.css";
 import logo from "./logo.svg";
 import styles from "./App.css";

 class App extends Component {
   render() {
     return (
+      <ThemeProvider theme={theme}>
         <div className={styles.app}>
           <div className={styles.appHeader}>
             <img src={logo} className={styles.appLogo} alt="logo" />
             <h2>Welcome to React</h2>
           </div>
           <p className={styles.appIntro}>
             To get started, edit <code>src/App.js</code> and save to reload.
           </p>

+         <ReactToolboxExample />
+         <EmotionExample />
         </div>
       </ThemeProvider>
     );
   }
 }

 export default App;
  1. You may also want to add this line to your .gitignore
*.emotion.css

Compose RT and E

Just show an example of composing styles somehow between the two libs, or decide this is not useful and explain why somewhere

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.