-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support secondary text in ListItem widget #1700
Support secondary text in ListItem widget #1700
Conversation
This pull request is being automatically deployed with Vercel (learn more). dojo.widgets – ./🔍 Inspect: https://vercel.com/dojo/dojo.widgets/FadnaiZbuQhsF6VbdjNu51epM36C widget-test-docs – ./🔍 Inspect: https://vercel.com/dojo/widget-test-docs/CeeWryaQ88wFXjMAttferCTAfFxy |
Codecov Report
@@ Coverage Diff @@
## master #1700 +/- ##
==========================================
+ Coverage 90.07% 90.08% +0.01%
==========================================
Files 94 94
Lines 5046 5052 +6
Branches 1374 1379 +5
==========================================
+ Hits 4545 4551 +6
Misses 249 249
Partials 252 252
Continue to review full report at Codecov.
|
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.
@aciccarello It seems to me that this would be better implemented as different List Item types. ie. Avatar Item, Two Line Item etc. Otherwise we're just going to end up with a large number of different properties when we could have had easy to use / reason with widgets.
It would also be good to have an example of each of these item types.
1d10354
to
2e1f374
Compare
@tomdye I reworked this to remove the height property that was added. Instead it depends on a mix of min-height and padding to ensure things fit well. The leading content is also given a min-width of 40px so even if you have a 24px icon it still aligns to the material spec. I did not do anything special for the two line list to float a 24px icon to the top since that would seem unexpected for users and would need another 8px of padding which wouldn't be needed if you have a 56px high leading image. I also renamed the Updated screenshotsI've split the example into two, one for single line and a second for two line however they both are pretty simplistic. In the committed code I'm using the location icon example for the single line example and the avatar for the two line example but a variety is shown for the sake of the PR. In case I (or anyone else) want this manual testing example code later later: export function differentListItemTypes({value, label = ''}: MenuOption, secondary?: string) {
const graphicStyles = {height: '56px', color: 'white', display: 'flex', alignItems: 'center', justifyContent: 'center'};
switch (label[0]) {
case 'A':
return {
primary: label,
secondary
}
case 'C':
return {
leading: <Icon type="locationIcon" />,
primary: label,
secondary,
trailing: value
}
case 'D':
case 'E':
case 'F':
case 'G':
return {
leading: <Avatar>{label[0]}</Avatar>,
primary: label,
secondary,
trailing: <Icon type="starIcon" />
}
case 'W':
return {
leading: <div styles={{...graphicStyles, width: '100px', background: 'purple'}}>56 x 100</div>,
primary: label,
secondary,
trailing: <Icon type="starIcon" />
}
default:
return {
leading: <div styles={{...graphicStyles, width: '56px', background: 'blue', 'fontSize': '0.875rem'}}>56 x 56</div>,
primary: label,
secondary,
trailing: value
}
}
} |
this makes the height more flexible also rename main content wrapper class to .text since it wraps primary and secondary. The leading content is given a min-width of 40px For 24px leading icons, they will align to the front This does not align leading icons to the top right on two-line list items This is because the top/bottom padding is set to 8px instead of 16px
2e1f374
to
abd8a9c
Compare
Type: bug / feature
The following has been addressed in the PR:
.dojorc
theme.variant()
is added to the root domnodetheme.compose
like thisDescription:
This adds secondary text to the ListItem widget. Because secondar text often requires more height, I've replaced the single height css class with a range of sizes. This also allows different size leading/trailing content. It's a breaking change for anyone overriding that CSS class but should allow greater flexibility.
Resolves #1688