-
Notifications
You must be signed in to change notification settings - Fork 30
Updates from mdl-list to flexbox for display of variable controls. Closes #86. #87
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Hiya @appsforartists looking for sanity check here. No new functionality added, but really just a UI refactor. Essentially this creates a new |
@@ -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", |
There was a problem hiding this comment.
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. 😃
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}`}> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/ui/ListItem.tsx
Outdated
subtitle?: string; | ||
inlineControl: boolean; | ||
controlClass?: string; | ||
control: any; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
src/ui/ListItem.tsx
Outdated
subtitle?: string; | ||
inlineControl: boolean; | ||
controlClass?: string; | ||
control: any; |
There was a problem hiding this comment.
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}`}> |
There was a problem hiding this comment.
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)} |
There was a problem hiding this comment.
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.
I have a https://github.com/material-motion/material-motion-js/blob/develop/tslint.json Though it doesn't enforce spacing in braces. |
No description provided.