Skip to content

Commit

Permalink
Remove injectGlobal, introduce global component(s), add colors and gl…
Browse files Browse the repository at this point in the history
…obal style exports, raise styled-components dependency to 4+
  • Loading branch information
myovchev committed Aug 28, 2019
1 parent 63d3c2e commit e5d4599
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ node_modules
src
dev
.storybook
.babelrc
.editorconfig
.eslintignore
.eslintrc
.nojekyl
.eslintrc.js
.nojekyll
stories
scripts
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corllete/material-styled",
"version": "0.1.1",
"version": "0.1.2",
"description": "Styled Components implementation of Material Design",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -63,6 +63,6 @@
"prop-types": ">= 15",
"react": ">= 16.8",
"react-dom": ">= 16.8",
"styled-components": ">= 3"
"styled-components": ">= 4"
}
}
32 changes: 17 additions & 15 deletions src/Drawer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled, { injectGlobal, css } from 'styled-components';
import styled, { createGlobalStyle, css } from 'styled-components';
import classNames from 'classnames';
import elevation from './mixins/elevation';
import Portal from './Portal';
Expand All @@ -9,8 +9,7 @@ const drawerSizing = css`
width: 240px;
`;

// eslint-disable-next-line no-unused-expressions
injectGlobal`
const GlobalStyle = createGlobalStyle`
body {
&.shift {
&.right {
Expand Down Expand Up @@ -111,19 +110,22 @@ const Drawer = ({
temporary,
attachment,
}) => (
<Portal
open={open}
shift={!temporary}
attachment={attachment}
onRequestClose={handleRequestClose}
renderContents={() => (
<StyledDrawer
attachment={attachment}
open={open}
temporary={temporary}>
{children}
</StyledDrawer>
<React.Fragment>
<GlobalStyle />
<Portal
open={open}
shift={!temporary}
attachment={attachment}
onRequestClose={handleRequestClose}
renderContents={() => (
<StyledDrawer
attachment={attachment}
open={open}
temporary={temporary}>
{children}
</StyledDrawer>
)} />
</React.Fragment>
);

Drawer.propTypes = {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export { default as withRipple } from './mixins/ripple';

export { default as ThemeProvider } from './theme/ThemeProvider';
export { default as defaultTheme } from './theme/defaultTheme';
export { default as GlobalStyle } from './theme/injectGlobal';
export * from './theme/colors';
1 change: 1 addition & 0 deletions src/theme/colors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Color from 'color';

export { Color };
export const black = Color('#000');
export const white = Color('#fff');
7 changes: 5 additions & 2 deletions src/theme/injectGlobal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectGlobal } from 'styled-components';
import { createGlobalStyle } from 'styled-components';

/* eslint-disable no-unused-expressions */
injectGlobal`
const GlobalStyle = createGlobalStyle`
body {
margin: 0;
padding: 0;
Expand All @@ -11,3 +11,6 @@ injectGlobal`
font-family: Roboto,sans-serif;
}
`;

export default GlobalStyle;

0 comments on commit e5d4599

Please sign in to comment.