Skip to content

Commit

Permalink
Merge pull request #91 from sublimetext-io/fix/contributors-2
Browse files Browse the repository at this point in the history
Make spacing of contributors really nice and dynamic
  • Loading branch information
FichteFoll authored Oct 29, 2023
2 parents 52b2db7 + bd0fb5c commit f0c2715
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 75 deletions.
101 changes: 62 additions & 39 deletions docs/.vitepress/components/Contributors.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,90 @@
<template>
<h1>Contributors ({{ contributors.length }})</h1>

<input type="checkbox" id="showMoreToggle" class="hidden">

<!-- Displayed contributors -->
<div class="contributors-card">
<h1>Contributors ({{ contributors.length }})</h1>

<input type="checkbox" id="showMoreToggle" class="hidden">

<!-- Displayed contributors -->
<VPTeamMembers class="contributors" size="small" :members="contributors" />

<!-- Toggle button -->
<label for="showMoreToggle" class="toggleButton">
<div class="icon-container">
<svg class="show" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="m6 9 6 6 6-6" />
</svg>
<svg class="hide" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="m18 15-6-6-6 6" />
</svg>
</div>
</label>

<p v-if="error" class="error-message">{{ error }}</p>
</div>
</template>

<VPTeamMembers class="contributors" size="small" :members="contributors.slice(0, maxVisible)" />
<style scoped>
.contributors-card {
--item-height: 256px; /* allows for 2 rows in name */
--item-width: 180px;
--item-gap: 0px; /* items are padded enough */
background-color: var(--vp-c-bg-soft);
color: var(--vp-c-text-1);
min-height: 400px;
border-radius: 10px;
padding: 24px;
}
<!-- More contributors -->
<VPTeamMembers class="moreContributors" size="small" :members="contributors" />
.contributors-card h1 {
font-size: 1.75rem;
font-weight: 600;
}
<!-- Toggle button -->
<label for="showMoreToggle" class="toggleButton">
<div class="icon-container">
<svg class="show" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="m6 9 6 6 6-6" />
</svg>
<svg class="hide" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<path d="m18 15-6-6-6 6" />
</svg>
</div>
</label>
.hidden {
display: none;
}
<p v-if="error" class="error-message">{{ error }}</p>
</template>
.toggleButton {
cursor: pointer;
}
<style>
.icon-container {
display: inline-block;
width: 24px;
height: 24px;
position: relative;
}
.hidden {
display: none;
.contributors {
max-height: calc(var(--item-height) * 2);
overflow: hidden;
}
.moreContributors {
display: none;
}
#showMoreToggle:checked~.contributors {
display: none;
}
#showMoreToggle:checked~.moreContributors {
display: block;
#showMoreToggle:checked ~ .contributors {
max-height: none;
}
#showMoreToggle:checked~.toggleButton .show,
#showMoreToggle:not(:checked)~.toggleButton .hide {
display: none;
}
</style>

.VPTeamMembers>.container {
<style>
/* Overrides for within .VPTeamMembers */
.contributors-card .VPTeamMembers > .container {
/* Allows items to wrap to the next line if there's not enough space */
display: flex;
flex-wrap: wrap;
/* Allows items to wrap to the next line if there's not enough space */
justify-content: center;
/* Centers items horizontally */
gap: 1rem;
/* Space between members. Adjust as needed */
justify-content: center;
gap: var(--item-gap);
}
.contributors-card .VPTeamMembers > .container > .item {
width: var(--item-width);
height: var(--item-height);
}
</style>

Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/data/contributors.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
name: contributor.login,
title: 'Contributor',
links: [
{ icon: 'github', link: contributor.url },
{ icon: 'github', link: contributor.html_url },
]
}));

Expand Down
34 changes: 0 additions & 34 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
}



.VPNavBar:not(.has-sidebar):not(.top) {
border-bottom-color: transparent !important;
}
Expand All @@ -48,40 +47,7 @@
background-color: var(--vp-c-bg-elv);
}

.VPTeamMembers.small .container {
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
gap: 10px;
}

/* Custom Stlye */
.custom-layout {
background-color: var(--vp-c-bg-soft);
color: var(--vp-c-text-1);
padding: 1.5rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 1rem;
min-height: 400px;
max-width: 1152px;
margin: 6rem auto 0;
border-radius: 10px;
}

.custom-layout h1 {
font-size: 1.75rem;
font-weight: 600;
}

.custom-layout .btn {
background-color: var(--vp-button-brand-bg);
color: var(--vp-button-brand-text);
border-radius: 20px;
padding: 0.5rem 1.4rem;
}

dt.defined-term {
color: var(--vp-c-brand) !important;
text-transform: uppercase;
Expand Down
34 changes: 33 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,38 @@ head:

<!-- Custom home layout -->
<div class="custom-layout">
<Contributors ></Contributors>
<div class="custom-container">
<Contributors ></Contributors>
</div>
</div>

<style scoped>
/* horizonal padding copied from .VPFeatures's padding */
.custom-layout {
padding: 0 24px;
}

@media (min-width: 640px) {
.custom-layout {
padding: 0 48px;
}
}

@media (min-width: 960px) {
.custom-layout {
padding: 0 64px;
}
}

.custom-container {
max-width: 1152px;
margin: 2rem auto 0;

display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 1rem;
}
</style>

0 comments on commit f0c2715

Please sign in to comment.