Skip to content

Commit 052f3d2

Browse files
committed
fix: use emotion's jsx in favor of createElement
1 parent ee736c0 commit 052f3d2

File tree

11 files changed

+44
-36
lines changed

11 files changed

+44
-36
lines changed

src/BlockQuote.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import { FunctionComponent } from 'react';
35

@@ -26,13 +28,10 @@ export const blockQuoteStyles = ({ isSelected }: IBlockQuoteProps) => {
2628
const theme = useTheme();
2729

2830
return [
29-
/* todo:
30-
{
31-
pl="@xl"
32-
borderLeft="@sm"
33-
}
34-
*/
3531
{
32+
padding: '15px 25px',
33+
borderLeft: '5px solid',
34+
maxWidth: '80%',
3635
color: theme.blockQuote.fg,
3736
borderColor: theme.blockQuote.borderColor,
3837
},

src/Checkbox.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import { Omit } from '@stoplight/types';
35
import noop = require('lodash/noop');
4-
import { createElement, FunctionComponent, ReactEventHandler, useState } from 'react';
6+
import { FunctionComponent, ReactEventHandler, useState } from 'react';
57

68
import { Box, Flex, IBox, Icon, useTheme } from './';
79

@@ -42,7 +44,7 @@ const CheckboxInner: FunctionComponent<ICheckboxInner> = props => {
4244
as: 'span',
4345
css,
4446
},
45-
props.isChecked && [createElement(Icon, { icon: 'check' })]
47+
props.isChecked && [jsx(Icon, { icon: 'check' })]
4648
);
4749
};
4850

@@ -88,11 +90,11 @@ export const Checkbox: FunctionComponent<ICheckbox> = props => {
8890
css,
8991
},
9092
[
91-
createElement(CheckboxInput, {
93+
jsx(CheckboxInput, {
9294
id,
9395
onChange: handleChange,
9496
}),
95-
createElement(CheckboxInner, {
97+
jsx(CheckboxInner, {
9698
isChecked,
9799
isDisabled,
98100
height,

src/CodeEditor.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { css, jsx } from '@emotion/core';
44

55
import noop = require('lodash/noop');
66
import 'prismjs/components/';
7-
import * as React from 'react';
8-
import { CSSProperties, useCallback } from 'react';
7+
import { CSSProperties, forwardRef, useCallback } from 'react';
98
import ReactSimpleCodeEditor from 'react-simple-code-editor';
109
import { Box } from './Box';
1110
import { useTheme } from './theme';
@@ -56,7 +55,7 @@ export const supportedLanguages = {
5655

5756
export type ReactSimpleCodeEditorRef = ReactSimpleCodeEditor;
5857

59-
export const CodeEditor = React.forwardRef<ReactSimpleCodeEditorRef, ICodeEditor>((props, ref) => {
58+
export const CodeEditor = forwardRef<ReactSimpleCodeEditorRef, ICodeEditor>((props, ref) => {
6059
const { language, onChange = noop, style, value } = props;
6160
const highlightCodeCallback = useCallback(() => highlightCode(value, language), [value, language]);
6261
const editorCSS = [...codeEditorStyles()];
@@ -68,13 +67,13 @@ export const CodeEditor = React.forwardRef<ReactSimpleCodeEditorRef, ICodeEditor
6867
css: editorCSS,
6968
},
7069
[
71-
<ReactSimpleCodeEditor
72-
ref={ref}
73-
value={value}
74-
onValueChange={onChange}
75-
highlight={highlightCodeCallback}
76-
padding={10}
77-
/>,
70+
jsx(ReactSimpleCodeEditor, {
71+
ref,
72+
value,
73+
onValueChange: onChange,
74+
highlight: highlightCodeCallback,
75+
padding: 10,
76+
}),
7877
]
7978
);
8079
});

src/ContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @jsx jsx */
1+
/* @jsx jsx */
22

33
import { jsx } from '@emotion/core';
44
import {

src/Input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import noop = require('lodash/noop');
35
import { FunctionComponent, SyntheticEvent, useState } from 'react';

src/List.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import { Omit } from '@stoplight/types';
35
import { FunctionComponent } from 'react';

src/Mark.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import * as React from 'react';
1+
/* @jsx jsx */
2+
3+
import { jsx } from '@emotion/core';
24

35
import { Box, IBox } from './Box';
46

src/Menu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/** @jsx jsx */
1+
/* @jsx jsx */
22

33
import { css, jsx } from '@emotion/core';
4-
import { createElement, FunctionComponent, ReactNode } from 'react';
4+
import { FunctionComponent, ReactNode } from 'react';
55

66
import { Box } from './Box';
77
import { Flex, IFlex } from './Flex';
@@ -21,7 +21,7 @@ export declare type RenderMenuFunc = (
2121
) => ReactNode;
2222

2323
const defaultRenderMenuItem: RenderMenuItemFunc = (item: IMenuItemProps, index: number) =>
24-
createElement(MenuItem, { key: index, ...item });
24+
jsx(MenuItem, { key: index, ...item });
2525

2626
const defaultRenderMenu: RenderMenuFunc = ({ renderTrigger, ...rest }, menuItems, renderMenuItem) => {
2727
const theme = useTheme();

src/Table.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { jsx } from '@emotion/core';
44
import { Omit } from '@stoplight/types';
5-
import { createElement, FunctionComponent } from 'react';
5+
import { FunctionComponent } from 'react';
66

77
import { Box, IBox } from './Box';
88
import { useTheme } from './theme';
@@ -19,7 +19,7 @@ export const Table: FunctionComponent<ITable> = props => {
1919
as: 'table',
2020
css,
2121
},
22-
[createElement('tbody', null, children)]
22+
[jsx('tbody', null, children)]
2323
);
2424
};
2525

@@ -83,9 +83,7 @@ export const TableCell: FunctionComponent<ITableCell> = props => {
8383
});
8484
};
8585

86-
export interface ITableCell
87-
extends ITableCellProps,
88-
Omit<IBox<HTMLTableDataCellElement>, 'as'> {}
86+
export interface ITableCell extends ITableCellProps, Omit<IBox<HTMLTableDataCellElement>, 'as'> {}
8987

9088
export interface ITableCellProps extends ITableProps {
9189
as?: 'th' | 'td';

src/Textarea.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import noop = require('lodash/noop');
35
import { FunctionComponent, SyntheticEvent, useState } from 'react';
@@ -7,7 +9,7 @@ import { Box, IBox } from './Box';
79
import { useTheme } from './theme';
810

911
export const Textarea: FunctionComponent<ITextarea> = props => {
10-
const { as = props.autosize ? AutosizeTextarea : 'textarea', autosize, onChange = noop, ...rest } = props;
12+
const { autosize, as = autosize ? AutosizeTextarea : 'textarea', onChange = noop, ...rest } = props;
1113

1214
const css = textareaStyles(props);
1315

src/Toggle.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
/* @jsx jsx */
2+
13
import { jsx } from '@emotion/core';
24
import { Omit } from '@stoplight/types';
35
import noop = require('lodash/noop');
4-
import { createElement, FunctionComponent, ReactEventHandler, SyntheticEvent, useState } from 'react';
6+
import { FunctionComponent, ReactEventHandler, SyntheticEvent, useState } from 'react';
57

68
import { Box, Flex, IBox, useTheme } from './';
79
import { Icon } from './Icon';
@@ -35,7 +37,7 @@ interface IToggleInnerProps {
3537
const ToggleInnerIcon: FunctionComponent<IToggleInnerProps> = props => {
3638
const css = toggleInnerIconStyles(props);
3739

38-
return createElement(Icon, {
40+
return jsx(Icon, {
3941
icon: 'circle',
4042
css,
4143
});
@@ -60,7 +62,7 @@ const ToggleInner: FunctionComponent<IToggleInnerProps> = props => {
6062
as: 'span',
6163
css,
6264
},
63-
[createElement(ToggleInnerIcon, props)]
65+
[jsx(ToggleInnerIcon, props)]
6466
);
6567
};
6668

@@ -104,11 +106,11 @@ export const Toggle: FunctionComponent<IToggle> = props => {
104106
css,
105107
},
106108
[
107-
createElement(ToggleInput, {
109+
jsx(ToggleInput, {
108110
id,
109111
onChange: handleChange,
110112
}),
111-
createElement(ToggleInner, {
113+
jsx(ToggleInner, {
112114
isChecked,
113115
isDisabled: !!disabled,
114116
height,

0 commit comments

Comments
 (0)