Skip to content

Show features of dependencies #3505

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

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions app/components/dependency-list/row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,33 @@
{{@dependency.crate_id}}
</LinkTo>

<span local-class="metadata" data-test-metadata>
{{#if @dependency.optional}}
{{#if @dependency.optional}}
<span local-class="optional-label" data-test-optional>
optional
{{/if}}
</span>
</span>
{{/if}}

{{#if this.featuresDescription}}
<span local-class="features-label" data-test-features>
{{! extra <span> for better tooltip alignment }}
<span>
{{this.featuresDescription}}

<EmberTooltip>
<ul local-class="feature-list">
<li>
{{svg-jar (if @dependency.default_features "checkbox" "checkbox-empty")}} default features
</li>
{{#each @dependency.features as |feature|}}
<li>
{{svg-jar "checkbox"}} {{feature}}
</li>
{{/each}}
</ul>
</EmberTooltip>
</span>
</span>
{{/if}}
</div>

{{#if (or this.description this.loadCrateTask.isRunning)}}
Expand Down
13 changes: 13 additions & 0 deletions app/components/dependency-list/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ export default class VersionRow extends Component {
return this.loadCrateTask.lastSuccessful?.value?.description;
}

get featuresDescription() {
let { default_features: defaultFeatures, features } = this.args.dependency;
let numFeatures = features.length;

if (numFeatures !== 0) {
return defaultFeatures
? `${numFeatures} extra feature${numFeatures > 1 ? 's' : ''}`
: `only ${numFeatures} feature${numFeatures > 1 ? 's' : ''}`;
} else if (!defaultFeatures) {
return 'no default features';
}
}

@task *loadCrateTask() {
let { dependency } = this.args;
return yield this.store.findRecord('crate', dependency.crate_id);
Expand Down
27 changes: 27 additions & 0 deletions app/components/dependency-list/row.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
text-transform: uppercase;
letter-spacing: .7px;
font-size: 13px;
margin-right: 15px;

a {
position: relative;
Expand All @@ -115,6 +116,32 @@
text-transform: none;
letter-spacing: normal;
}

@media only screen and (max-width: 550px) {
display: block;
margin-top: 10px;
}
}

.optional-label {
composes: metadata;
}

.features-label {
composes: metadata;
}

.feature-list {
padding: 0;
margin: 10px 5px;
list-style: none;

svg {
height: 1em;
width: auto;
margin-right: 2px;
margin-bottom: -.1em;
}
}

.description {
Expand Down