Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Updates from mdl-list to flexbox for display of variable controls. Closes #86. #87

Merged
merged 8 commits into from
Mar 30, 2017

Conversation

chriscox
Copy link
Member

No description provided.

@codecov-io
Copy link

codecov-io commented Mar 28, 2017

Codecov Report

Merging #87 into develop will increase coverage by 0.24%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #87      +/-   ##
==========================================
+ Coverage    81.95%   82.2%   +0.24%     
==========================================
  Files           18      19       +1     
  Lines          643     652       +9     
  Branches        79      80       +1     
==========================================
+ Hits           527     536       +9     
  Misses          85      85              
  Partials        31      31
Impacted Files Coverage Δ
src/lib/Constants.ts 100% <ø> (ø) ⬆️
src/ui/controls/ColorSwatchControl.tsx 77.77% <ø> (ø) ⬆️
src/ui/controls/SliderControl.tsx 80.95% <ø> (+0.95%) ⬆️
src/ui/controls/TextFieldControl.tsx 75% <ø> (+1.08%) ⬆️
src/ui/controls/DropdownControl.tsx 82.6% <ø> (+0.79%) ⬆️
src/ui/controls/SwitchControl.tsx 74.07% <0%> (+0.99%) ⬆️
src/ui/controls/RadioListControl.tsx 71.42% <0%> (ø) ⬆️
src/ui/ListItem.tsx 100% <100%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 673bc71...0b55301. Read the comment docs.

@chriscox chriscox requested review from chuga and appsforartists and removed request for chuga March 28, 2017 15:29
@chriscox
Copy link
Member Author

Hiya @appsforartists looking for sanity check here. No new functionality added, but really just a UI refactor. Essentially this creates a new ListItem component with params used for placement of child properties. This is first of a few cleanup changes I'm making to rid of mdl-list and mdl-list-item in favor of a more structured and reusable representation.

@@ -64,6 +64,7 @@ export const DataType = {

/** CSS class and id constants. */
export const CSS = {
// TODO(cjcox): Refactor out these MDL classes in favor of flexbox.
MDL_LIST: "mdl-list",
Copy link
Member

Choose a reason for hiding this comment

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

It's Google Style to prefer single quotes.

I was in the habit of doing doubles before working here, but have switched to singles after reading that. Ultimately, it's more important to be consistent within your project than adhere to that style guide, but being consistent (both within Material and with Google as a whole) is worth some consideration too. 😃

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I filed an issue where I'll handle this for entire app.

* Interface for the properties assigned to the ListItem component.
* @interface
*/
interface IListItemProps {
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, I think Google Style (and TypeScript convention) is to omit the I prefix. If you've done it other places, you can do it here, but it may be worth doing a pass where you move this project's conventions closer to Google Style.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I filed an issue where I'll handle this for entire app.

export function ListItem(props: IListItemProps) {
let inline = props.inlineControl ? "inline" : "";
return (
<div className={`${CSS.RMX_LIST_ITEM} ${props.controlClass} ${inline}`}>
Copy link
Member

Choose a reason for hiding this comment

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

Your spacing within braces doesn't seem consistent: some pairs have them and some don't. I usually include it, but consistency is the most important.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take a pass with linter in subsequent PR to fix here and throughout.

<ColorSwatch
color={ColorUtils.toRgbaString(value)}
key={value}
isSelected={ColorUtils.areEqual(selectedValue, value)}
Copy link
Member

Choose a reason for hiding this comment

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

I hope areEqual is a reasonably fast comparison - since it's in render, it will be called for every swatch on every render.

If it's at all expensive, it may be worth calculating it when the values change and caching the result.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a cheap string comparison.

subtitle?: string;
inlineControl: boolean;
controlClass?: string;
control: any;
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to use children instead of control. Then, your markup would look like this:

<ListItem
  title = { title }
  subtitle = { title }
>
  <ColorSwatch />
</ListItem>

instead of

<ListItem
  title = { title }
  subtitle = { title }
  control = {
    <ColorSwatch />
  }
/>

Ultimately, doesn't matter - it's just style. It just looks a bit weird to see markup passed as a prop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here and throughout. Now setting the control code a child.

Copy link
Member Author

@chriscox chriscox left a comment

Choose a reason for hiding this comment

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

Made updates per review.

@@ -64,6 +64,7 @@ export const DataType = {

/** CSS class and id constants. */
export const CSS = {
// TODO(cjcox): Refactor out these MDL classes in favor of flexbox.
MDL_LIST: "mdl-list",
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I filed an issue where I'll handle this for entire app.

* Interface for the properties assigned to the ListItem component.
* @interface
*/
interface IListItemProps {
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I filed an issue where I'll handle this for entire app.

subtitle?: string;
inlineControl: boolean;
controlClass?: string;
control: any;
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here and throughout. Now setting the control code a child.

export function ListItem(props: IListItemProps) {
let inline = props.inlineControl ? "inline" : "";
return (
<div className={`${CSS.RMX_LIST_ITEM} ${props.controlClass} ${inline}`}>
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take a pass with linter in subsequent PR to fix here and throughout.

<ColorSwatch
color={ColorUtils.toRgbaString(value)}
key={value}
isSelected={ColorUtils.areEqual(selectedValue, value)}
Copy link
Member Author

Choose a reason for hiding this comment

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

It is a cheap string comparison.

@chriscox chriscox merged commit 540a1a6 into develop Mar 30, 2017
@appsforartists
Copy link
Member

I have a tslint.json in Material Motion. Feel free to copy it. 😃

https://github.com/material-motion/material-motion-js/blob/develop/tslint.json

Though it doesn't enforce spacing in braces.

@chriscox chriscox deleted the feature/ui_refactor branch March 30, 2017 01:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants