Skip to content

Commit 3ec019e

Browse files
committed
Auto merge of #3505 - bikeshedder:show-features-of-dependencies, r=Turbo87
Show features of dependencies I keep getting asked why my crate depends on `tokio` besides it just needing a small subset of features: deadpool-rs/deadpool#88 This PR adds the list of features used from each dependency to the dependencies tab: ![image](https://user-images.githubusercontent.com/1112569/114195470-c5ce5800-9950-11eb-88c0-8e607a29213d.png)
2 parents 489fcb6 + 58514bc commit 3ec019e

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

app/components/dependency-list/row.hbs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,33 @@
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>
34+
</span>
35+
{{/if}}
36+
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}}
3658
</div>
3759

3860
{{#if (or this.description this.loadCrateTask.isRunning)}}

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: 27 additions & 0 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,6 +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+
}
124+
}
125+
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+
}
118145
}
119146

120147
.description {

0 commit comments

Comments
 (0)