style: refactor user profile tabs to use anchor links
This commit is contained in:
1 parent
258348cb0d
commit
07a61990a7
1 file changed
+31
-49
@@ -10,87 +10,69 @@
|
|||||||
<!-- Tabs Navigation -->
|
<!-- Tabs Navigation -->
|
||||||
<div class="mb-4 border-b border-gray-200">
|
<div class="mb-4 border-b border-gray-200">
|
||||||
<nav class="-mb-px flex space-x-8" aria-label="Tabs">
|
<nav class="-mb-px flex space-x-8" aria-label="Tabs">
|
||||||
<button class="tab-button whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm border-primary text-primary" data-target="tab-about">
|
<a href="#tab-about" class="group whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
border-primary text-primary [&:not(:target):not(:has(~:target))]:border-primary [&:not(:target):not(:has(~:target))]:text-primary
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
About
|
About
|
||||||
</button>
|
</a>
|
||||||
<button class="tab-button whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" data-target="tab-submissions">
|
<a href="#tab-submissions" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
Submissions
|
Submissions
|
||||||
</button>
|
</a>
|
||||||
<button class="tab-button whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" data-target="tab-comments">
|
<a href="#tab-comments" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
Comments
|
Comments
|
||||||
</button>
|
</a>
|
||||||
<button class="tab-button whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" data-target="tab-favorites">
|
<a href="#tab-favorites" class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm
|
||||||
|
[&:target]:border-primary [&:target]:text-primary
|
||||||
|
[&:not(:target)]:border-transparent [&:not(:target)]:text-gray-500 [&:not(:target)]:hover:text-gray-700 [&:not(:target)]:hover:border-gray-300">
|
||||||
Favorites
|
Favorites
|
||||||
</button>
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab Content Panes -->
|
<!-- Tab Content Panes -->
|
||||||
<div>
|
<div>
|
||||||
<div id="tab-about" class="tab-pane">
|
<div id="tab-about" class="block [&:not(:target)]:hidden [&:not(:target):not(:has(~:target))]:block">
|
||||||
<div class="text-text-muted prose max-w-none"> <!-- Added prose for potential markdown styling -->
|
<div class="text-text-muted prose max-w-none">
|
||||||
{{ page.about | markdownify }}
|
{{ page.about | markdownify }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-submissions" class="tab-pane hidden">
|
<div id="tab-submissions" class="hidden [&:target]:block">
|
||||||
<p class="text-text-muted">User submissions will be listed here.</p>
|
<p class="text-text-muted">User submissions will be listed here.</p>
|
||||||
<!-- Placeholder: Add Liquid logic to loop through user's submissions -->
|
<!-- Placeholder: Add Liquid logic to loop through user's submissions -->
|
||||||
<!-- Example:
|
|
||||||
{% assign user_submissions = site.posts | where: "author", page.username %}
|
{% assign user_submissions = site.posts | where: "author", page.username %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for post in user_submissions %}
|
{% for post in user_submissions %}
|
||||||
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-comments" class="tab-pane hidden">
|
<div id="tab-comments" class="hidden [&:target]:block">
|
||||||
<p class="text-text-muted">User comments will be listed here.</p>
|
<p class="text-text-muted">User comments will be listed here.</p>
|
||||||
<!-- Placeholder: Add Liquid logic to loop through user's comments -->
|
<!-- Placeholder: Add Liquid logic to loop through user's comments -->
|
||||||
<!-- Example:
|
|
||||||
{% assign user_comments = site.comments | where: "author", page.username %}
|
{% assign user_comments = site.comments | where: "author", page.username %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for comment in user_comments %}
|
{% for comment in user_comments %}
|
||||||
<li>{{ comment.content | truncatewords: 15 }} - <a href="{{ comment.post_url }}#comment-{{ comment.id }}">view</a></li>
|
<li>{{ comment.content | truncatewords: 15 }} - <a href="{{ comment.post_url }}#comment-{{ comment.id }}">view</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-favorites" class="tab-pane hidden">
|
<div id="tab-favorites" class="hidden [&:target]:block">
|
||||||
<p class="text-text-muted">User favorites will be listed here.</p>
|
<p class="text-text-muted">User favorites will be listed here.</p>
|
||||||
<!-- Placeholder: Add Liquid logic to loop through user's favorites -->
|
<!-- Placeholder: Add Liquid logic to loop through user's favorites -->
|
||||||
<!-- This depends heavily on how favorites are stored -->
|
{% if page.favorites %}
|
||||||
|
<ul>
|
||||||
|
{% for favorite in page.favorites %}
|
||||||
|
<li><a href="{{ favorite.url }}">{{ favorite.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No favorites yet.</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const tabs = document.querySelectorAll('.tab-button');
|
|
||||||
const panes = document.querySelectorAll('.tab-pane');
|
|
||||||
|
|
||||||
tabs.forEach(tab => {
|
|
||||||
tab.addEventListener('click', function() {
|
|
||||||
const targetId = this.getAttribute('data-target');
|
|
||||||
|
|
||||||
// Update tab appearance
|
|
||||||
tabs.forEach(t => {
|
|
||||||
t.classList.remove('border-primary', 'text-primary');
|
|
||||||
t.classList.add('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300');
|
|
||||||
});
|
|
||||||
this.classList.add('border-primary', 'text-primary');
|
|
||||||
this.classList.remove('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300');
|
|
||||||
|
|
||||||
|
|
||||||
// Update pane visibility
|
|
||||||
panes.forEach(pane => {
|
|
||||||
if (pane.id === targetId) {
|
|
||||||
pane.classList.remove('hidden');
|
|
||||||
} else {
|
|
||||||
pane.classList.add('hidden');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
Reference in new issue
Block a user