Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
chore(components): remove deprecated components (#1606)
Browse files Browse the repository at this point in the history
* chore(components): remove deprecated components

Refs carbon-design-system/carbon#1501.

* chore(test): move describeBreakingChangesXFeatures() to setup

* chore: some cleanup

* chore: resolve merge conflict
  • Loading branch information
asudoh authored Feb 21, 2019
1 parent 7323f86 commit 64f81a5
Show file tree
Hide file tree
Showing 31 changed files with 232 additions and 186 deletions.
4 changes: 4 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const TerserPlugin = require('terser-webpack-plugin');
const useExperimentalFeatures =
process.env.CARBON_USE_EXPERIMENTAL_FEATURES === 'true';

const useBreakingChanges = process.env.CARBON_USE_BREAKING_CHANGES === 'true';

const useExternalCss =
process.env.CARBON_REACT_STORYBOOK_USE_EXTERNAL_CSS === 'true';

Expand All @@ -13,6 +15,7 @@ const useStyleSourceMap =

const replaceTable = {
componentsX: useExperimentalFeatures,
breakingChangesX: useBreakingChanges,
};

const styleLoaders = [
Expand Down Expand Up @@ -41,6 +44,7 @@ const styleLoaders = [
data: `
$feature-flags: (
components-x: ${useExperimentalFeatures},
breaking-changes-x: ${useBreakingChanges},
grid: ${useExperimentalFeatures},
ui-shell: true,
);
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ We recommend the use of [React Storybook](https://github.com/storybooks/react-st

1. (Optional) Set environment variables:

- `true` to `CARBON_USE_EXPERIMENTAL_FEATURES` environment variable to test some of the experimental features:
- `true` to `CARBON_USE_BREAKING_CHANGES` environment variable to test some of the breaking changes for the next release:

```
$ export CARBON_USE_EXPERIMENTAL_FEATURES=true
$ export CARBON_USE_BREAKING_CHANGES=true
```

- `true` to `CARBON_REACT_STORYBOOK_USE_EXTERNAL_CSS` environment variable to use external CSS, making style source link usable in DOM inspector:
Expand Down
12 changes: 12 additions & 0 deletions config/jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ jest.unmock('promise');
jest.unmock('whatwg-fetch');
jest.unmock('object-assign');

import { breakingChangesX } from '../../src/internal/FeatureFlags';

global.__DEV__ = true;

global.describeBreakingChangesXFeatures = (name, callback) => {
if (!breakingChangesX) {
describe(name, callback);
} else {
describe(name, () => {
it('dummy', () => {});
});
}
};

require('../polyfills');

const enzyme = require.requireActual('enzyme');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
"jasmine": true
},
"globals": {
"__DEV__": true
"__DEV__": true,
"describeBreakingChangesXFeatures": true
},
"settings": {
"jsdoc": {
Expand Down
93 changes: 48 additions & 45 deletions src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { breakingChangesX } from '../../internal/FeatureFlags';

import {
withKnobs,
Expand Down Expand Up @@ -77,49 +78,51 @@ const props = {
}),
};

storiesOf('Dropdown', module)
.addDecorator(withKnobs)
.addDecorator(story => <div style={{ minWidth: '20em' }}>{story()}</div>)
.add(
'Default',
() => {
const dropdownItemProps = props.dropdownItem();
return (
<Dropdown {...props.dropdown()}>
<DropdownItem
itemText="Option 1"
value="option1"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 2"
value="option2"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 3"
value="option3"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 4"
value="option4"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 5"
value="option5"
{...dropdownItemProps}
/>
</Dropdown>
);
},
{
info: {
text: `
The Dropdown component is used for navigating or filtering existing content.
Create Dropdown Item components for each option in the dropdown menu.
`,
if (!breakingChangesX) {
storiesOf('Dropdown', module)
.addDecorator(withKnobs)
.addDecorator(story => <div style={{ minWidth: '20em' }}>{story()}</div>)
.add(
'Default',
() => {
const dropdownItemProps = props.dropdownItem();
return (
<Dropdown {...props.dropdown()}>
<DropdownItem
itemText="Option 1"
value="option1"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 2"
value="option2"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 3"
value="option3"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 4"
value="option4"
{...dropdownItemProps}
/>
<DropdownItem
itemText="Option 5"
value="option5"
{...dropdownItemProps}
/>
</Dropdown>
);
},
}
);
{
info: {
text: `
The Dropdown component is used for navigating or filtering existing content.
Create Dropdown Item components for each option in the dropdown menu.
`,
},
}
);
}
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Icon from '../Icon';
import ClickListener from '../../internal/ClickListener';
import { shallow, mount } from 'enzyme';

describe('Dropdown', () => {
describeBreakingChangesXFeatures('Dropdown', () => {
describe('Renders as expected', () => {
const wrapper = shallow(
<Dropdown className="extra-class" defaultText="Choose something.." />
Expand Down
5 changes: 4 additions & 1 deletion src/components/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import classNames from 'classnames';
import warning from 'warning';
import { iconCaretDown } from 'carbon-icons';
import { settings } from 'carbon-components';
import { breakingChangesX } from '../../internal/FeatureFlags';
import ClickListener from '../../internal/ClickListener';
import Icon from '../Icon';

const { prefix } = settings;

let didWarnAboutDeprecation = false;

export default class Dropdown extends PureComponent {
class Dropdown extends PureComponent {
static propTypes = {
/**
* Specify a label to be read by screen readers on the container node
Expand Down Expand Up @@ -267,3 +268,5 @@ export default class Dropdown extends PureComponent {
return dropdown;
}
}

export default (!breakingChangesX ? Dropdown : null);
2 changes: 1 addition & 1 deletion src/components/DropdownItem/DropdownItem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import DropdownItem from '../DropdownItem';
import { mount } from 'enzyme';

describe('DropdownItem', () => {
describeBreakingChangesXFeatures('DropdownItem', () => {
describe('Renders as expected', () => {
const wrapper = mount(
<DropdownItem className="extra-class" itemText="test" value="test" />
Expand Down
3 changes: 2 additions & 1 deletion src/components/DropdownItem/DropdownItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';
import classNames from 'classnames';
import warning from 'warning';
import { settings } from 'carbon-components';
import { breakingChangesX } from '../../internal/FeatureFlags';

const { prefix } = settings;

Expand Down Expand Up @@ -123,4 +124,4 @@ DropdownItem.defaultProps = {
selected: false,
};

export default DropdownItem;
export default (!breakingChangesX ? DropdownItem : null);
49 changes: 27 additions & 22 deletions src/components/Pagination/Pagination-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { breakingChangesX } from '../../internal/FeatureFlags';

import {
withKnobs,
Expand Down Expand Up @@ -46,7 +47,7 @@ const props = () => ({
onChange: action('onChange'),
});

storiesOf('Pagination', module)
const story = storiesOf('Pagination', module)
.addDecorator(withKnobs)
.addDecorator(story => <div style={{ width: '800px' }}>{story()}</div>)
.add('v2', () => <PaginationV2 {...props()} />, {
Expand All @@ -55,27 +56,31 @@ storiesOf('Pagination', module)
V2 version of the Pagination
`,
},
})
.add('v1', () => <Pagination {...props()} />, {
info: {
text: `
});

if (!breakingChangesX) {
story
.add('v1', () => <Pagination {...props()} />, {
info: {
text: `
The pagination component is used to paginate through items.
`,
},
})
.add(
'multipe pagination components',
() => {
return (
<div>
<Pagination {...props()} />
<Pagination {...props()} />
</div>
);
},
{
info: {
text: `Showcasing unique ids for each pagination component`,
},
}
);
})
.add(
'multipe pagination components',
() => {
return (
<div>
<Pagination {...props()} />
<Pagination {...props()} />
</div>
);
},
{
info: {
text: `Showcasing unique ids for each pagination component`,
},
}
);
}
2 changes: 1 addition & 1 deletion src/components/Pagination/Pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { shallow, mount } from 'enzyme';

jest.useFakeTimers();

describe('Pagination', () => {
describeBreakingChangesXFeatures('Pagination', () => {
describe('renders as expected', () => {
const pagination = shallow(
<Pagination className="extra-class" pageSizes={[5, 10]} totalItems={50} />
Expand Down
5 changes: 4 additions & 1 deletion src/components/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import debounce from 'lodash.debounce';
import warning from 'warning';
import { iconChevronLeft, iconChevronRight } from 'carbon-icons';
import { settings } from 'carbon-components';
import { breakingChangesX } from '../../internal/FeatureFlags';
import Icon from '../Icon';
import Select from '../Select';
import SelectItem from '../SelectItem';
Expand All @@ -22,7 +23,7 @@ const { prefix } = settings;

let didWarnAboutDeprecation = false;

export default class Pagination extends Component {
class Pagination extends Component {
static propTypes = {
/**
* The description for the backward icon.
Expand Down Expand Up @@ -373,3 +374,5 @@ export default class Pagination extends Component {
);
}
}

export default (!breakingChangesX ? Pagination : null);
Loading

0 comments on commit 64f81a5

Please sign in to comment.