Skip to content

Commit aed14f8

Browse files
committed
DependencyList::Row: Replace basic feature listing with generated description and tooltip
1 parent a50fa7f commit aed14f8

File tree

3 files changed

+56
-19
lines changed

3 files changed

+56
-19
lines changed

app/components/dependency-list/row.hbs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,34 @@
2828
{{@dependency.crate_id}}
2929
</LinkTo>
3030

31-
<span local-class="metadata" data-test-metadata>
32-
{{#if @dependency.optional}}
31+
{{#if @dependency.optional}}
32+
<span local-class="metadata" data-test-metadata>
3333
optional
34-
{{/if}}
35-
</span>
36-
</div>
34+
</span>
35+
{{/if}}
3736

38-
{{#if (or (not @dependency.default_features) @dependency.features)}}
39-
<div local-class="features" data-test-features>
40-
{{#if (not @dependency.default_features)}}
41-
default-features=false
42-
{{/if}}
43-
{{#if @dependency.features}}
44-
features={{@dependency.features}}
45-
{{/if}}
46-
</div>
47-
{{/if}}
37+
{{#if this.featuresDescription}}
38+
<span local-class="metadata" data-test-metadata>
39+
{{! extra <span> for better tooltip alignment }}
40+
<span>
41+
{{this.featuresDescription}}
42+
43+
<EmberTooltip>
44+
<ul local-class="feature-list">
45+
<li>
46+
{{svg-jar (if @dependency.default_features "checkbox" "checkbox-empty")}} default features
47+
</li>
48+
{{#each @dependency.features as |feature|}}
49+
<li>
50+
{{svg-jar "checkbox"}} {{feature}}
51+
</li>
52+
{{/each}}
53+
</ul>
54+
</EmberTooltip>
55+
</span>
56+
</span>
57+
{{/if}}
58+
</div>
4859

4960
{{#if (or this.description this.loadCrateTask.isRunning)}}
5061
<div local-class="description" data-test-description>

app/components/dependency-list/row.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ export default class VersionRow extends Component {
2626
return this.loadCrateTask.lastSuccessful?.value?.description;
2727
}
2828

29+
get featuresDescription() {
30+
let { default_features: defaultFeatures, features } = this.args.dependency;
31+
let numFeatures = features.length;
32+
33+
if (numFeatures !== 0) {
34+
return defaultFeatures
35+
? `${numFeatures} extra feature${numFeatures > 1 ? 's' : ''}`
36+
: `only ${numFeatures} feature${numFeatures > 1 ? 's' : ''}`;
37+
} else if (!defaultFeatures) {
38+
return 'no default features';
39+
}
40+
}
41+
2942
@task *loadCrateTask() {
3043
let { dependency } = this.args;
3144
return yield this.store.findRecord('crate', dependency.crate_id);

app/components/dependency-list/row.module.css

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
text-transform: uppercase;
9595
letter-spacing: .7px;
9696
font-size: 13px;
97+
margin-right: 15px;
9798

9899
a {
99100
position: relative;
@@ -115,12 +116,24 @@
115116
text-transform: none;
116117
letter-spacing: normal;
117118
}
119+
120+
@media only screen and (max-width: 550px) {
121+
display: block;
122+
margin-top: 10px;
123+
}
118124
}
119125

120-
.features {
121-
margin-top: 10px;
122-
color: var(--crate-color);
123-
font-size: 80%;
126+
.feature-list {
127+
padding: 0;
128+
margin: 10px 5px;
129+
list-style: none;
130+
131+
svg {
132+
height: 1em;
133+
width: auto;
134+
margin-right: 2px;
135+
margin-bottom: -.1em;
136+
}
124137
}
125138

126139
.description {

0 commit comments

Comments
 (0)