Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Commit f821301

Browse files
switched to emotion
1 parent 57834d7 commit f821301

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

src/components/Loading/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import css from 'styled-jsx/css';
2+
import { css } from '@emotion/core';
33
import { rem } from '../../utils/styleUtils';
44

55
interface Props {
@@ -17,13 +17,13 @@ const Loading: React.FC<Props> = ({
1717
numBox = 3,
1818
boxColor = 'skyblue',
1919
}) => {
20-
const animationDelayStyles = (position: number) => css.resolve`
20+
const animationDelayStyles = (position: number) => css`
2121
animation-delay: ${animationTime * (position / numBox)}ms;
2222
`;
2323

2424
const boxStyles = Array.from(Array(numBox), (_, position) => animationDelayStyles(position));
2525

26-
const containerStyles = css.resolve`
26+
const containerStyles = css`
2727
box-sizing: border-box;
2828
margin-top: ${rem(40)};
2929
margin-bottom: ${rem(40)};
@@ -60,7 +60,7 @@ const Loading: React.FC<Props> = ({
6060
}
6161
}
6262
63-
:global(${boxStyles.map(styles => `.${styles.className}`).join(', ')}) {
63+
& > div {
6464
width: ${rem(boxSize)};
6565
height: ${rem(boxSize)};
6666
opacity: 0.5;
@@ -72,13 +72,10 @@ const Loading: React.FC<Props> = ({
7272
`;
7373

7474
return (
75-
<div className={containerStyles.className}>
75+
<div css={containerStyles}>
7676
{boxStyles.map(styles => (
77-
<div key={styles.className} className={styles.className}>
78-
{styles.styles}
79-
</div>
77+
<div key={styles.name} css={styles} />
8078
))}
81-
{containerStyles.styles}
8279
</div>
8380
);
8481
};

src/utils/styleUtils.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import css from 'styled-jsx/css';
1+
import { css } from '@emotion/core';
22

33
export const rem = (num: number) => {
44
const remVal = num / 16;
55
return `${remVal}rem`;
66
};
77

8-
export const buttonReset = css.global`
9-
button {
10-
border: none;
11-
border-radius: 0;
12-
margin: 0;
13-
padding: 0;
14-
width: auto;
15-
overflow: visible;
16-
background: transparent;
17-
}
8+
export const buttonReset = css`
9+
border: none;
10+
border-radius: 0;
11+
margin: 0;
12+
padding: 0;
13+
width: auto;
14+
overflow: visible;
15+
background: transparent;
1816
19-
button:focus {
17+
&:focus {
2018
outline: none;
2119
box-shadow: none;
2220
}
@@ -45,7 +43,7 @@ export const transition = (duration: number = 250, easing: string = 'ease-in-out
4543
const transitions = [...properties];
4644
const makeTransition = (property: string, index: number) =>
4745
`${index !== 0 ? ', ' : ''}${property} ${duration}ms ${easing}`;
48-
return css.resolve`
46+
return css`
4947
transition: ${transitions.map(makeTransition)};
5048
`;
5149
};

0 commit comments

Comments
 (0)