Skip to content

Commit

Permalink
feat: upgrade emotion (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cain Watson committed Jul 28, 2020
1 parent b47ab3d commit df74190
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 157 deletions.
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
"@babel/preset-react",
"@emotion/babel-preset-css-prop"
],
"plugins": [
"emotion"
]
}
2 changes: 1 addition & 1 deletion client/components/CreateGameForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { useHistory } from 'react-router-dom';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import axios from '../axios';
import Button from './Utils/Button';
import Input from './Utils/Input';
Expand Down
2 changes: 1 addition & 1 deletion client/components/Game/Canvas/SketchPad.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SketchPad = (props) => {
return (
<canvas
ref={canvas}
className={BorderStyles}
css={BorderStyles}
width={CANVAS_WIDTH}
height={CANVAS_HEIGHT}
onMouseDown={handleMouseDown}
Expand Down
10 changes: 3 additions & 7 deletions client/components/Game/Canvas/options/Fill/Fill.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { connect, useSelector } from 'react-redux';
import { css } from 'react-emotion';
import styled from '@emotion/styled';
import ToolButton from '../../../../Utils/ToolButton';
import FullInput from '../../../../Utils/FullInput';
import { setFillAction, setFillColorAction } from '../../../../../store/actions/game.actions';

const relativeStyle = css`
position: relative;
`;

const FillOption = (props) => {
const { dispatchFill, dispatchFillColor } = props;
const fill = useSelector(state => state.game.canvas.options.fill);
Expand All @@ -27,11 +23,11 @@ const FillOption = (props) => {

return (
<div>
<ToolButton onClick={handleToggleFill} active={fill} className={relativeStyle}>
<ToolButton onClick={handleToggleFill} active={fill}>
<i className="fas fa-adjust" />
</ToolButton>
{fill ? (
<ToolButton color={fillColor} className={relativeStyle}>
<ToolButton color={fillColor}>
<i className="fas fa-adjust" />
<FullInput type="color" onChange={handleChangeFillColor} />
</ToolButton>
Expand Down
7 changes: 1 addition & 6 deletions client/components/Game/Canvas/options/Stroke/Stroke.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { connect, useSelector } from 'react-redux';
import { css } from 'react-emotion';
import ToolButton from '../../../../Utils/ToolButton';
import FullInput from '../../../../Utils/FullInput';
import { setSizeAction, setStrokeColorAction } from '../../../../../store/actions/game.actions';

const relativeStyle = css`
position: relative;
`;

const MIN_SIZE = 2;
const MAX_SIZE = 18;
const STEP = 2;
Expand All @@ -31,7 +26,7 @@ const StrokeOption = (props) => {

return (
<div>
<ToolButton color={strokeColor} activeColor={strokeColor} className={relativeStyle}>
<ToolButton color={strokeColor} activeColor={strokeColor}>
<i className="fas fa-tint" />
<FullInput onChange={handleChangeColor} type="color" />
</ToolButton>
Expand Down
2 changes: 1 addition & 1 deletion client/components/Game/Chat/Box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ChatBox = (props) => {

return (
<Container>
<div ref={chatWindow} className={WindowStyles}>
<div ref={chatWindow} css={WindowStyles}>
{messages.map((message, index) => (
<ChatMessage
key={index}
Expand Down
2 changes: 1 addition & 1 deletion client/components/Game/Chat/Message.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import PropTypes from 'prop-types';

const Message = styled('div')`
Expand Down
3 changes: 2 additions & 1 deletion client/components/Game/Chat/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { css } from 'react-emotion';
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import { BorderStyles } from '../../../styles';
import Input from '../../Utils/Input';
import Button from '../../Utils/Button';
Expand Down
3 changes: 2 additions & 1 deletion client/components/Game/ScoreBoard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import styled, { css } from 'react-emotion';
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import Flex from '../Utils/Flex';
import Button from '../Utils/Button';

Expand Down
2 changes: 1 addition & 1 deletion client/components/Game/StartGame.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import Button from '../Utils/Button';
import { startAction } from '../../store/actions/game.actions';

Expand Down
2 changes: 1 addition & 1 deletion client/components/Game/TopBar.jsx
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 from 'react-emotion';
import styled from '@emotion/styled';
import StartGame from './StartGame';
import Flex from '../Utils/Flex';
import Button from '../Utils/Button';
Expand Down
2 changes: 1 addition & 1 deletion client/components/GoogleLogin.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import Centered from './Utils/Centered';
import Button from './Utils/Button';

Expand Down
2 changes: 1 addition & 1 deletion client/components/Play/CreateGame.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import { Link } from 'react-router-dom';
import Button from '../Utils/Button';

Expand Down
3 changes: 2 additions & 1 deletion client/components/Utils/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { css } from 'react-emotion';
import { css } from '@emotion/core';
import styled from '@emotion/styled';

const width = '180px';
const fontSize = '20px';
Expand Down
2 changes: 1 addition & 1 deletion client/components/Utils/Centered.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';

const Centered = styled('div')`
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion client/components/Utils/Flex.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';

const Inline = styled('div')`
display: flex;
Expand Down
8 changes: 4 additions & 4 deletions client/components/Utils/FullInput.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';

const FullInput = styled('input')`
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
`;
Expand Down
2 changes: 1 addition & 1 deletion client/components/Utils/Input.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';
import { BorderStyles } from '../../styles';

const width = '180px';
Expand Down
4 changes: 3 additions & 1 deletion client/components/Utils/ToolButton.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled, { css } from 'react-emotion';
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import withProps from 'recompose/withProps';
import Button from './Button';

Expand All @@ -8,6 +9,7 @@ const activeToolButtonStyles = (activeColor = '#f8f8f8') => css`
`;

const ToolButton = withProps({ circle: true })(styled(Button)`
position: relative;
transition: background 300ms ease-in-out, color 300ms ease-in-out;
width: 50px;
height: 50px;
Expand Down
2 changes: 1 addition & 1 deletion client/screens/ScreenGame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom';
import { connect, useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import NotificationSystem from 'react-notification-system';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import Flex from '../components/Utils/Flex';
import NicknameForm from '../components/Game/NicknameForm';
Expand Down
2 changes: 1 addition & 1 deletion client/screens/ScreenPlay.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import JoinGame from '../components/Play/Join';
import CreateGame from '../components/Play/CreateGame';
import Centered from '../components/Utils/Centered';
Expand Down
3 changes: 2 additions & 1 deletion client/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { injectGlobal, css } from 'react-emotion';
import { injectGlobal } from 'emotion';
import { css } from '@emotion/core';

export const injectGlobalStyles = () => injectGlobal`
html, body, #app {
Expand Down
Loading

0 comments on commit df74190

Please sign in to comment.