Skip to content

Commit 1237d54

Browse files
committed
Remove dependency on 'classnames'
1 parent 1be1eff commit 1237d54

10 files changed

+19
-43
lines changed

demo/IntrospectionModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32

43
import Grid from '@material-ui/core/Grid';
54
import Modal from '@material-ui/core/Modal';
@@ -154,9 +153,7 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
154153
{presetNames.map((name) => (
155154
<div
156155
key={name}
157-
className={classNames('preset-card', {
158-
'-active': name === activePreset,
159-
})}
156+
className={`preset-card ${name === activePreset ? '-active' : ''}`}
160157
onClick={() => this.handlePresetChange(name)}
161158
>
162159
<h2>{name}</h2>

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"dependencies": {
6363
"@f/animate": "^1.0.1",
6464
"@material-ui/core": "^3.9.3",
65-
"classnames": "2.3.1",
6665
"commonmark": "0.30.0",
6766
"lodash": "4.17.21",
6867
"svg-pan-zoom": "^3.6.1",

src/components/doc-explorer/Argument.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32

43
import './Argument.css';
54

@@ -16,7 +15,7 @@ export default class Argument extends React.Component<ArgumentProps> {
1615
render() {
1716
const { arg, expanded, onTypeLink } = this.props;
1817
return (
19-
<span className={classNames('arg-wrap', { '-expanded': expanded })}>
18+
<span className={`arg-wrap ${expanded ? '-expanded' : ''}`}>
2019
<Markdown text={arg.description} className="arg-description" />
2120
<span className="arg">
2221
<span className="arg-name">{arg.name}</span>

src/components/doc-explorer/Description.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32

43
import './Description.css';
54

@@ -16,16 +15,11 @@ export default class Description extends React.Component<DescriptionProps> {
1615

1716
if (text)
1817
return (
19-
<Markdown
20-
text={text}
21-
className={classNames('description-box', className)}
22-
/>
18+
<Markdown text={text} className={`description-box ${className}`} />
2319
);
2420

2521
return (
26-
<div
27-
className={classNames('description-box', className, '-no-description')}
28-
>
22+
<div className={`description-box ${className} -no-description`}>
2923
<p>No Description</p>
3024
</div>
3125
);

src/components/doc-explorer/TypeDoc.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as _ from 'lodash';
22
import * as React from 'react';
3-
import classNames from 'classnames';
43

54
import './TypeDoc.css';
65

@@ -88,18 +87,17 @@ export default class TypeDoc extends React.Component<TypeDocProps> {
8887

8988
if (types.length === 0) return null;
9089

90+
const isSelected = type.id === selectedId;
9191
return (
9292
<div className="doc-category">
9393
<div className="title">{typesTitle}</div>
9494
{_.map(types, (type) => {
9595
let props: any = {
9696
key: type.id,
97-
className: classNames('item', {
98-
'-selected': type.id === selectedId,
99-
}),
97+
className: `item ${isSelected ? '-selected' : ''}`,
10098
onClick: () => onSelectEdge(type.id),
10199
};
102-
if (type.id === selectedId) props.ref = 'selectedItem';
100+
if (isSelected) props.ref = 'selectedItem';
103101
return (
104102
<div {...props}>
105103
<TypeLink
@@ -133,25 +131,23 @@ export default class TypeDoc extends React.Component<TypeDocProps> {
133131
<div className="doc-category">
134132
<div className="title">fields</div>
135133
{fields.map((field) => {
134+
const hasArgs = !_.isEmpty(field.args);
135+
const isSelected = field.id === selectedId;
136+
136137
let props: any = {
137138
key: field.name,
138-
className: classNames('item', {
139-
'-selected': field.id === selectedId,
140-
'-with-args': !_.isEmpty(field.args),
141-
}),
139+
className: `item ${isSelected ? '-selected' : ''} ${
140+
hasArgs ? '-with-args' : ''
141+
}`,
142142
onClick: () => onSelectEdge(field.id),
143143
};
144-
if (field.id === selectedId) props.ref = 'selectedItem';
144+
if (isSelected) props.ref = 'selectedItem';
145145
return (
146146
<div {...props}>
147147
<a className="field-name">
148148
{highlightTerm(field.name, filter)}
149149
</a>
150-
<span
151-
className={classNames('args-wrap', {
152-
'-empty': _.isEmpty(field.args),
153-
})}
154-
>
150+
<span className={`args-wrap ${hasArgs ? '' : '-empty'}`}>
155151
{!_.isEmpty(field.args) && (
156152
<span key="args" className="args">
157153
{_.map(field.args, (arg) => (

src/components/doc-explorer/TypeInfoPopover.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32

43
import './TypeInfoPopover.css';
54

@@ -43,11 +42,7 @@ export default class ScalarDetails extends React.Component<
4342
});
4443
}
4544
return (
46-
<div
47-
className={classNames('type-info-popover', {
48-
'-opened': !!type,
49-
})}
50-
>
45+
<div className={`type-info-popover ${type != null ? '-opened' : ''}`}>
5146
<IconButton className="closeButton" onClick={() => this.close()}>
5247
<CloseIcon />
5348
</IconButton>

src/components/doc-explorer/TypeLink.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32
import {
43
isBuiltInScalarType,
54
isScalarType,
@@ -29,7 +28,7 @@ export default class TypeLink extends React.Component<TypeLinkProps> {
2928

3029
return (
3130
<a
32-
className={classNames('type-name', className)}
31+
className={`type-name ${className}`}
3332
onClick={(event) => {
3433
event.stopPropagation();
3534
onClick(type);

src/components/doc-explorer/TypeList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as _ from 'lodash';
22
import * as React from 'react';
3-
import classNames from 'classnames';
43
import { isMatch } from '../../utils';
54

65
import './TypeList.css';
@@ -42,7 +41,7 @@ export default class TypeList extends React.Component<TypeListProps> {
4241
}
4342

4443
return (
45-
<div key={type.id} className={classNames('typelist-item', className)}>
44+
<div key={type.id} className={`typelist-item ${className}`}>
4645
<TypeLink type={type} onClick={onTypeLink} filter={filter} />
4746
<FocusTypeButton onClick={() => onFocusType(type)} />
4847
<Description className="-doc-type" text={type.description} />

src/components/utils/LoadingAnimation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
32

43
import './LoadingAnimation.css';
54

@@ -13,7 +12,7 @@ export default class LoadingAnimation extends React.Component<LoadingAnimationPr
1312
render() {
1413
const { loading } = this.props;
1514
return (
16-
<div className={classNames({ 'loading-box': true, visible: loading })}>
15+
<div className={`loading-box ${loading ? 'visible' : ''}`}>
1716
<span className="loading-animation">
1817
<VoyagerIcon />
1918
<h1> Transmitting... </h1>

0 commit comments

Comments
 (0)