Skip to content

Commit

Permalink
make website not suck on mobile (and various fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-ni committed Oct 14, 2023
1 parent 630a2d6 commit f22637b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 47 deletions.
2 changes: 1 addition & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ activities, and other math competition opportunities!
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display: none;"></div>
<div class="response" id="mce-success-response" style="display: none;"></div>
</div><div aria-hidden="true" style="position: absolute; left: -5000px;"><input type="text" name="b_24d4cef68c36baccb820775ad_385ee9d1d1" tabindex="-1" value=""></div><div class="clear"><input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="Subscribe"></div>
</div><div aria-hidden="true" style="position: absolute; left: -5000px;"><input type="text" name="b_24d4cef68c36baccb820775ad_385ee9d1d1" tabindex="-1" value=""></div><div class="clear"><input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="Subscribe" autocomplete="email"></div>
</div>
</form>
</div>
Expand Down
87 changes: 48 additions & 39 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,66 @@
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body);"></script>

<script>
function thing() {
document.getElementById("navbar").classList.toggle("open");
}
</script>
</head>

<body class="max-w-4xl p-8 mx-auto flex flex-col gap-8">
{% block header %}
<nav class="flex flex-col items-center gap-4">
<a href="/"><img src="/assets/logo.png" alt="BMT Logo" width="80"></a>
<p class="text-2xl font-bold">Berkeley Math Tournament</p>

<div class="flex gap-4">
{{ macros::nav_link(path="@/_index.md", label="Home") }}
{{ macros::nav_link(path="@/news/_index.md", label="News") }}
{{ macros::nav_link(path="@/about.md", label="About") }}
{{ macros::nav_link(path="@/sponsors/index.md", label="Sponsors") }}
{{ macros::nav_link(path="@/events/bmt-2023.md", label="BMT 2023") }}
</div>
</nav>
{% endblock %}
<body>
<div class="max-w-4xl p-4 md:p-8 mx-auto flex flex-col gap-4 md:gap-8">
{% block header %}
<header class="flex flex-col gap-4 text-center">
<a class="mx-auto" href="/"><img src="/assets/logo.png" alt="BMT Logo" width="80"></a>
<p class="text-2xl font-bold">Berkeley Math Tournament</p>

<nav id="navbar"
class="[&.open>a.nav-hidden]:block [&>a.nav-hidden]:hidden flex flex-col md:flex-row md:mx-auto gap-4 items-stretch">
{{ macros::nav_link(path="@/_index.md", label="Home") }}
{{ macros::nav_link(path="@/news/_index.md", label="News") }}
{{ macros::nav_link(path="@/about.md", label="About") }}
{{ macros::nav_link(path="@/sponsors/index.md", label="Sponsors") }}
{{ macros::nav_link(path="@/events/bmt-2023.md", label="BMT 2023") }}
</nav>
</header>
{% endblock %}

<hr>
<hr>

<div class="flex flex-col gap-8">
{% block content %}{% endblock %}
</div>
<div class="flex flex-col gap-4 md:gap-8">
{% block content %}{% endblock %}
</div>

<hr>
<hr>

{% block footer %}
<div class="flex flex-col items-center justify-between md:items-start text-center md:flex-row gap-4 mb-12">
<div class="flex flex-col gap-6 items-center md:items-start">
<img class="-ml-1 grayscale brightness-0" src="/assets/logo.png" alt="BMT Logo" width="50">
{% block footer %}
<div class="flex flex-col items-center justify-between md:items-start text-center md:flex-row gap-4 mb-12">
<div class="flex flex-col gap-6 items-center md:items-start">
<img class="-ml-1 grayscale brightness-0" src="/assets/logo.png" alt="BMT Logo" width="50">

<div class="flex gap-4 text-xl">
<a href="https://www.instagram.com/berkeley_mt/"><i class="bi bi-instagram"></i></a>
<a href="https://www.tiktok.com/@berkeley_mt"><i class="bi bi-tiktok"></i></a>
<a href="mailto:[email protected]"><i class="bi bi-envelope-fill"></i></a>
<div class="flex gap-4 text-xl">
<a href="https://www.instagram.com/berkeley_mt/"><i class="bi bi-instagram"></i></a>
<a href="https://www.tiktok.com/@berkeley_mt"><i class="bi bi-tiktok"></i></a>
<a href="mailto:[email protected]"><i class="bi bi-envelope-fill"></i></a>
</div>
</div>
</div>

<div class="flex flex-col gap-4 items-center md:items-end md:text-right max-w-xs">
<a href="https://ocf.berkeley.edu">
<img src="http://ocf.berkeley.edu/hosting-logos/ocf-hosted-penguin-dark.svg" width="80"
alt="Hosted by the OCF" />
</a>
<div class="flex flex-col gap-4 items-center md:items-end md:text-right max-w-xs">
<a href="https://ocf.berkeley.edu">
<img src="https://ocf.berkeley.edu/hosting-logos/ocf-hosted-penguin-dark.svg" width="80"
alt="Hosted by the OCF" />
</a>

<p class="text-xs">
We are a student group acting independently of the University of California. We take full responsibility for
our organization and this web site.
</p>
<p class="text-xs">
We are a student group acting independently of the University of California. We take full responsibility for
our organization and this web site.
</p>
</div>
</div>
{% endblock %}
</div>
{% endblock %}
</body>

</html>
10 changes: 5 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<a href="{{ href }}"
class="p-6 flex flex-col gap-4 group-hover:backdrop-sepia group-hover:backdrop-brightness-75 transition-all">
<div class="flex flex-col gap-1">
<h3 class="font-bold text-2xl flex items-center gap-2">
<h3 class="font-bold text-lg md:text-2xl flex items-center gap-2">
<span>{{ name }}</span>
<i class="bi bi-chevron-right text-base transition-transform"></i>
</h3>
Expand Down Expand Up @@ -54,8 +54,8 @@ <h3 class="font-bold text-2xl flex items-center gap-2">

{# Main banner & description #}

<div id="banner" class="bg-black p-8 rounded-xl">
<p class="h-full text-3xl font-bold text-white flex flex-col justify-between">
<div id="banner" class="bg-black p-6 md:p-8 rounded-xl">
<p class="h-full text-xl md:text-3xl font-bold text-white flex flex-col justify-between">
<span class="order-0 after:content-['…'] text-left">Promoting advanced math</span>
<span class="order-2 before:content-['…'] text-right">to middle and high school students</span>
<span class="order-1 text-center">
Expand All @@ -65,7 +65,7 @@ <h3 class="font-bold text-2xl flex items-center gap-2">
</div>

<div>
<p class="text-xl leading-relaxed">
<p class="text-lg md:text-xl leading-relaxed">
A UC Berkeley student-led organization that aims to spread mathematics and the spirit of mathematical competition
globally by presenting students with interesting, original, hand-crafted problems. As of 2023, we are one of the
largest student-run math competitions on the West Coast with over 2,000 contestants.
Expand All @@ -76,7 +76,7 @@ <h3 class="font-bold text-2xl flex items-center gap-2">

{# Events section #}

<h2 class="font-bold text-3xl">Recent & Upcoming Events</h2>
<h2 class="font-bold text-xl md:text-3xl">Recent & Upcoming Events</h2>

<div class="flex flex-col md:grid grid-cols-6 gap-4 max-w-4xl">
{{ self::event(
Expand Down
19 changes: 17 additions & 2 deletions templates/macros.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{% macro nav_link(path, label) %}
{% set href = get_url(path=path) %}
<p class="first:hidden text-gray-400"></p>
<a href="{{ href }}" class="{% if current_url == href %} font-semibold {% endif %}">

{# Desktop version #}
<p class="hidden md:block first:hidden text-gray-400"></p>
<a href="{{ href }}" class="hidden md:block {% if current_url == href %} font-semibold {% endif %}">
{{ label }}
</a>

{# Mobile version #}
{% if current_url == href %}
<button class="md:hidden order-1 font-semibold border py-2 px-3 rounded-xl relative" onclick="thing()">
{{ label }}
<i class="bi bi-chevron-down [.open_&]:-scale-y-100 transition-transform absolute right-4"></i>
</button>
{% else %}
<a href="{{ href }}" class="py-2 px-3 bg-gray-100 border rounded-xl nav-hidden order-2">
{{ label }}
</a>
{% endif %}

{% endmacro nav_link %}

0 comments on commit f22637b

Please sign in to comment.