Skip to content

Commit

Permalink
feat(website): alert Git dependencies on package detail page (refs: #426
Browse files Browse the repository at this point in the history
)
  • Loading branch information
favoyang committed May 13, 2020
1 parent 0a9bf68 commit 4874027
Showing 1 changed file with 55 additions and 6 deletions.
61 changes: 55 additions & 6 deletions docs/.vuepress/theme/layouts/PackageDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,17 @@
class="columns"
>
<div class="col-12">
<i class=""></i>
<NavLink v-if="entry.link" :item="entry.link" />
<span v-else>{{ entry.name }}</span>
<div class="tooltip" :data-tooltip="entry.tooltip">
<NavLink
v-if="entry.link"
:item="entry.link"
class="dep-text"
/>
<span v-else class="dep-text"
><i :class="entry.icon"></i>
{{ entry.name }}</span
>
</div>
</div>
</li>
</ul>
Expand Down Expand Up @@ -396,11 +404,44 @@ export default {
if (!entry || !entry.dependencies) return [];
else
return Object.entries(entry.dependencies).map(([name, version]) => {
const nameWithVersion = `${name}@${version}`;
const isGit = version.startsWith("git");
let nameWithVersion = `${name}@${version}`;
const nameWithVersionMaxLen = 38;
const nameWithVersionLimited =
nameWithVersion.length > nameWithVersionMaxLen
? nameWithVersion.slice(0, nameWithVersionMaxLen) + "..."
: nameWithVersion;
const url = util.getPackageUrl(this.$site.pages, name);
let tooltip = null;
let icon = null;
if (isGit) {
if (url) {
tooltip = `Git dependency: ${nameWithVersion}.`;
icon = "fab fa-git";
} else {
tooltip = `Missing Git dependency, please install it manually: ${nameWithVersion}.`;
icon = "fas fa-exclamation-triangle text-warning";
}
} else if (url) {
tooltip = nameWithVersion;
icon = "fa fa-box-open";
} else {
tooltip = `Missing dependency, please install it manually: ${nameWithVersion}.`;
icon = "fas fa-exclamation-triangle text-warning";
}
return {
name: nameWithVersion,
link: url ? { link: url, text: nameWithVersion } : null,
icon,
isGit,
name: nameWithVersionLimited,
link: url
? {
link: url,
text: nameWithVersionLimited,
icon,
iconLeft: true
}
: null,
tooltip,
version
};
});
Expand Down Expand Up @@ -797,4 +838,12 @@ See more in the [${this.$package.repo}](${this.$package.repoUrl}) repository.
font-size 0.6rem
a
font-size 0.6rem

.dep-text
overflow-wrap break-word
max-width 10rem

.tooltip::after
white-space normal
overflow-wrap break-word
</style>

0 comments on commit 4874027

Please sign in to comment.