Skip to content

Commit 63ebbde

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

File tree

3 files changed

+64
-19
lines changed

3 files changed

+64
-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="optional-label" data-test-optional>
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="features-label" data-test-features>
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: 25 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,32 @@
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+
.optional-label {
127+
composes: metadata;
128+
}
129+
130+
.features-label {
131+
composes: metadata;
132+
}
133+
134+
.feature-list {
135+
padding: 0;
136+
margin: 10px 5px;
137+
list-style: none;
138+
139+
svg {
140+
height: 1em;
141+
width: auto;
142+
margin-right: 2px;
143+
margin-bottom: -.1em;
144+
}
124145
}
125146

126147
.description {

0 commit comments

Comments
 (0)