Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

feat(menu): add component #786

Merged
merged 38 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cae6b6d
WIP: menu
Mar 14, 2019
e237d30
WIP: Menu
Mar 15, 2019
f6cadef
fix: menu with seenshot
Mar 20, 2019
14a1183
WIP: selection menu
Mar 21, 2019
e80d458
WIP: menu
Mar 27, 2019
8d0b52a
WIP: getting menulistitem to be interpretted as a listitem
Mar 28, 2019
cb1694b
fix: menu list handleActionitem
Mar 28, 2019
aafb2d1
fix: add readme
Mar 28, 2019
4900f4d
feat: add tests
Mar 29, 2019
3abb5f4
fix: lint and test
Mar 29, 2019
61b076b
fix: add golden
Mar 29, 2019
05c48dd
fix: Pr changes
Apr 1, 2019
8a2196f
Merge branch 'feat/mdcweb-typescript-update' into feat/menu/addcompon…
Apr 2, 2019
6ee5ad7
WIP: using context to pass list item
Apr 2, 2019
85c0b93
Merge branch 'feat/mdcweb-typescript-update' into feat/menu/addcompon…
Apr 2, 2019
93bf167
Merge branch 'feat/menu/addcomponent_try3' into experiemental/menu/co…
Apr 2, 2019
c605cef
fix: using context instead
Apr 3, 2019
bb4c79b
fix: context is working
Apr 3, 2019
06e2ba6
fix: remove context from state
Apr 3, 2019
8ff2d9f
WIP: tests
Apr 4, 2019
667ed80
fix: tests
Apr 5, 2019
f2c0805
Merge branch 'feat/mdcweb-typescript-update' into feat/menu/addcompon…
Apr 5, 2019
9ded538
Merge branch 'experiemental/menu/context' into feat/menu/addcomponent…
Apr 5, 2019
7521f67
fix: commented tests
Apr 5, 2019
b10563c
fix: drawer test
Apr 5, 2019
395520d
Merge branch 'feat/mdcweb-typescript-update' into feat/menu/addcompon…
Apr 17, 2019
1b9b7a1
fix: memoize listProps
Apr 19, 2019
8ac8668
fix: revert esmoduleinterop
Apr 19, 2019
a5fe91e
Update index.tsx
Apr 19, 2019
cb75d24
fix: esmoduleinterop
Apr 23, 2019
949fd9e
fix: remove * as
Apr 23, 2019
e70dee4
fix: screenshots
Apr 23, 2019
3a8a01e
fix: move memoizeone
Apr 23, 2019
c6930a4
Merge branch 'feat/mdcweb-typescript-update' into feat/menu/addcompon…
Apr 26, 2019
ed4054f
fix: packagelock
Apr 26, 2019
d074619
fix: remove menu/index.scss
Apr 26, 2019
9c50842
fix: add a postinstall to fix react adapter
Apr 26, 2019
f93bcdf
fix: add -f so postinstall doesn't fail
Apr 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions packages/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import classnames from 'classnames';
import {MDCListFoundation} from '@material/list/foundation';
import {MDCListIndex} from '@material/list/types';
import {MDCListAdapter} from '@material/list/adapter';
import * as memoizeOne from 'memoize-one';
import memoizeOne from 'memoize-one';

import ListItem, {ListItemProps} from './ListItem'; // eslint-disable-line no-unused-vars
import ListItemGraphic from './ListItemGraphic';
Expand Down Expand Up @@ -364,6 +364,19 @@ export default class List extends React.Component<ListProps, ListState> {
this.setState({listItemClassNames});
};


getListProps = (checkboxList?: boolean, radioList?: boolean) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you should place the call to memoizeOne directly here. If it's in render, the cache will still be reseted.

(sorry for commenting so much 😅)

Copy link
Contributor

@lucasecdb lucasecdb Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my last comment wasn't clear enough, sorry

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you're right again sir!

(please keep the comments coming)

checkboxList: Boolean(checkboxList),
radioList: Boolean(radioList),
handleKeyDown: this.handleKeyDown,
handleClick: this.handleClick,
handleFocus: this.handleFocus,
handleBlur: this.handleBlur,
onDestroy: this.onDestroy,
getClassNamesFromList: this.getListItemClassNames,
getListItemInitialTabIndex: this.getListItemInitialTabIndex,
});

render() {
const {
/* eslint-disable no-unused-vars */
Expand All @@ -385,21 +398,9 @@ export default class List extends React.Component<ListProps, ListState> {
...otherProps
} = this.props;

const getListProps = (checkboxList?: boolean, radioList?: boolean) => ({
checkboxList: Boolean(checkboxList),
radioList: Boolean(radioList),
handleKeyDown: this.handleKeyDown,
handleClick: this.handleClick,
handleFocus: this.handleFocus,
handleBlur: this.handleBlur,
onDestroy: this.onDestroy,
getClassNamesFromList: this.getListItemClassNames,
getListItemInitialTabIndex: this.getListItemInitialTabIndex,
});

// decreases rerenders
// https://overreacted.io/writing-resilient-components/#dont-stop-the-data-flow-in-rendering
const getMemoizedListProps = memoizeOne(getListProps);
const getMemoizedListProps = memoizeOne(this.getListProps);

return (
// https://github.com/Microsoft/TypeScript/issues/28892
Expand Down
2 changes: 1 addition & 1 deletion test/screenshot/chips/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './index.scss';
import '../../../packages/chips/index.scss';
import MaterialIcon from '../../../packages/material-icon';
import {ChipProps, Chip, ChipSet} from '../../../packages/chips/index'; // eslint-disable-line no-unused-vars
import * as uuidv1 from 'uuid/v1';
import uuidv1 from 'uuid/v1';

interface ChipsTestProps {
selectedChipIds: string[];
Expand Down
2 changes: 1 addition & 1 deletion test/screenshot/screenshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as puppeteer from 'puppeteer';
import * as compareImages from 'resemblejs/compareImages';
import {test} from 'mocha';
import {assert} from 'chai';
import * as Storage from '@google-cloud/storage';
import Storage from '@google-cloud/storage';
import comparisonOptions from './screenshot-comparison-options';
import axios from 'axios';
import * as path from 'path';
Expand Down
4 changes: 2 additions & 2 deletions test/unit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Enzyme from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({adapter: new Adapter()});
const context = require.context('.', true, /\.test\.(j|t)sx?$/);
context.keys().forEach(context);
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"jsx": "react",
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noUnusedParameters": true,
"esModuleInterop": true,
},
"compileOnSave": true,
"exclude": [
Expand Down