Skip to content

Commit

Permalink
chore(Foundation): Removing class adapter handling due to repetitive …
Browse files Browse the repository at this point in the history
…renders #210
  • Loading branch information
jamesmfriedman committed May 1, 2018
1 parent 1c6edfa commit caa23ed
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 75 deletions.
7 changes: 1 addition & 6 deletions src/Checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import * as React from 'react';
import { MDCCheckbox } from '@material/checkbox/dist/mdc.checkbox';
import FormField from '../FormField';
import { simpleTag } from '../Base';
import {
withFoundation,
addClass,
removeClass,
syncFoundationProp
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';
import { randomId } from '../Base/utils/randomId';

export const CheckboxRoot = simpleTag({
Expand Down
13 changes: 5 additions & 8 deletions src/Chip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { IconPropsT } from '../Icon';
import * as React from 'react';
import { Icon } from '../Icon';
import { simpleTag } from '../Base';
import { withFoundation, addClass, removeClass } from '../Base/MDCFoundation';
import { withFoundation } from '../Base/MDCFoundation';

import { MDCChip, MDCChipSet } from '@material/chips/dist/mdc.chips';
import { MDCRipple } from '@material/ripple/dist/mdc.ripple';
Expand Down Expand Up @@ -33,10 +33,7 @@ export type ChipPropsT = {

export class Chip extends withFoundation({
constructor: MDCChip,
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<ChipPropsT> {
static displayName = 'Chip';

Expand Down Expand Up @@ -114,9 +111,9 @@ export const ChipIcon = (props: ChipIconPropsT) => {
p.startsWith('on')
);
const trailingProps =
props.trailing || hasInteractionHandler ?
{ role: 'button', tabIndex: 0 } :
{};
props.trailing || hasInteractionHandler
? { role: 'button', tabIndex: 0 }
: {};

return <ChipIconRoot {...trailingProps} {...props} />;
};
Expand Down
9 changes: 1 addition & 8 deletions src/Dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import {
import Button from '../Button';
import { simpleTag, noop } from '../Base';

import {
withFoundation,
syncFoundationProp,
addClass,
removeClass
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';

export const DialogRoot = simpleTag({
displayName: 'DialogRoot',
Expand Down Expand Up @@ -124,8 +119,6 @@ export type DialogPropsT = {
export class Dialog extends withFoundation({
constructor: MDCDialog,
adapter: {
addClass: addClass(),
removeClass: removeClass(),
notifyAccept: function() {
const evt = this.emit(MDCDialogFoundation.strings.ACCEPT_EVENT);
this.props.onClose && this.props.onClose(evt);
Expand Down
12 changes: 2 additions & 10 deletions src/IconToggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import * as React from 'react';
import { MDCIconToggle } from '@material/icon-toggle/dist/mdc.iconToggle';
import { Icon } from '../Icon';
import { simpleTag, noop } from '../Base';
import {
withFoundation,
syncFoundationProp,
addClass,
removeClass
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';

export type IconTogglePropsT = {
/* prettier-ignore */
Expand Down Expand Up @@ -38,10 +33,7 @@ export const IconToggleRoot = simpleTag({

export class IconToggle extends withFoundation({
constructor: MDCIconToggle,
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<IconTogglePropsT, {}> {
static displayName = 'IconToggle';
static defaultProps = {
Expand Down
22 changes: 7 additions & 15 deletions src/Ripple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import ReactDOM from 'react-dom';
import classNames from 'classnames';
import { MDCRipple } from '@material/ripple/dist/mdc.ripple';

import {
withFoundation,
addClass,
removeClass,
syncFoundationProp
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';

export type RipplePropsT = {
/** Makes the ripple unbounded */
Expand All @@ -24,22 +19,19 @@ export type RipplePropsT = {

export class Ripple extends withFoundation({
constructor: MDCRipple,
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<RipplePropsT> {
static displayName = 'Ripple';

componentDidMount() {
// Ripples can be used with many types of components
// we need to use ReactDOM as an escape hatch to just find the DOMnode
// we need to use ReactDOM as an escape hatch to just find the DOMNode
this.root_ = ReactDOM.findDOMNode(this);
super.componentDidMount();
}

syncWithProps(nextProps: RipplePropsT) {
// We dont know how React might have changed our dom node, Regrab it.
// We dont know how React might have changed our dom node, re-grab it.
this.root_ = ReactDOM.findDOMNode(this);

// unbounded
Expand Down Expand Up @@ -71,9 +63,9 @@ export class Ripple extends withFoundation({

const child = React.Children.only(children);

const unboundedProp = unbounded ?
{ 'data-mdc-ripple-is-unbounded': true } :
{};
const unboundedProp = unbounded
? { 'data-mdc-ripple-is-unbounded': true }
: {};

return React.cloneElement(child, {
...child.props,
Expand Down
9 changes: 1 addition & 8 deletions src/Select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import * as React from 'react';
import { MDCSelect } from '@material/select/dist/mdc.select';
import { simpleTag } from '../Base';
import type { SimpleTagPropsT } from '../Base';
import {
withFoundation,
addClass,
removeClass,
syncFoundationProp
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';

export const SelectRoot = simpleTag({
displayName: 'SelectRoot',
Expand Down Expand Up @@ -100,8 +95,6 @@ const createSelectOptions = (options): Object[] => {
export class Select extends withFoundation({
constructor: MDCSelect,
adapter: {
addClass: addClass(),
removeClass: removeClass(),
getValue: function() {
const value = this.nativeControl_.value;
return value === '' && this.props.placeholder ? ' ' : value;
Expand Down
6 changes: 1 addition & 5 deletions src/Slider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { simpleTag } from '../Base';

import {
withFoundation,
addClass,
removeClass,
syncFoundationProp
} from '../Base/MDCFoundation';
Expand Down Expand Up @@ -94,10 +93,7 @@ export class Slider extends withFoundation({
'pinValueMarker_',
'trackMarkerContainer_'
],
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<SliderPropsT, {}> {
static displayName = 'Slider';

Expand Down
12 changes: 2 additions & 10 deletions src/TextField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import { FloatingLabel } from '../FloatingLabel';

import type { SimpleTagPropsT } from '../Base';
import type { IconPropsT } from '../Icon';
import {
withFoundation,
addClass,
removeClass,
syncFoundationProp
} from '../Base/MDCFoundation';
import { withFoundation, syncFoundationProp } from '../Base/MDCFoundation';

export const TextFieldRoot = simpleTag({
displayName: 'TextFieldRoot',
Expand Down Expand Up @@ -162,10 +157,7 @@ export type TextFieldPropsT = {

export class TextField extends withFoundation({
constructor: MDCTextField,
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<TextFieldPropsT> {
static displayName = 'TextField';

Expand Down
7 changes: 2 additions & 5 deletions src/TopAppBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MDCTopAppBar } from '@material/top-app-bar/dist/mdc.topAppBar';

import { Icon } from '../Icon';
import { simpleTag } from '../Base';
import { addClass, removeClass, withFoundation } from '../Base/MDCFoundation';
import { withFoundation } from '../Base/MDCFoundation';

export const TopAppBarRoot = simpleTag({
displayName: 'TopAppBarRoot',
Expand Down Expand Up @@ -94,10 +94,7 @@ type TopAppAppBarPropsT = {
/** A TopAppBar component */
export class TopAppBar extends withFoundation({
constructor: MDCTopAppBar,
adapter: {
addClass: addClass(),
removeClass: removeClass()
}
adapter: {}
})<TopAppAppBarPropsT, {}> {
static displayName = 'TopAppBar';

Expand Down

0 comments on commit caa23ed

Please sign in to comment.