Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add correct styling

Francesco Sansalvadore69764be842fc
diff --git a/apps/www/hooks/useActiveAnchors.tsx b/apps/www/hooks/useActiveAnchors.tsx
index c4919cb2852..00a48824387 100644
--- a/apps/www/hooks/useActiveAnchors.tsx
+++ b/apps/www/hooks/useActiveAnchors.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from 'react'
+import { useEffect, useRef } from 'react'
const useActiveAnchors = (
anchorsQuerySelector: string = 'h2',
@@ -19,11 +19,15 @@ const useActiveAnchors = (
})
toc.current?.forEach((link) => {
- link.classList.remove('translate-x-1')
- link.classList.remove('!text-brand-900')
- if (link.getAttribute('href')?.replace('#', '') === newActiveAnchor) {
- link.classList.add('translate-x-1')
- link.classList.add('!text-brand-900')
+ link.classList.remove('toc-animate')
+ // TODO: escape emojis
+ // The problem is that MDXRemote strips out emojis on slugs
+ // but ReactMarkdown doesn't,instead it encodes them
+ const sanitizedHref = (link.getAttribute('href') ?? '').replace('#', '')
+ const isMatch = sanitizedHref === newActiveAnchor
+
+ if (isMatch) {
+ link.classList.add('toc-animate')
}
})
}
diff --git a/apps/www/pages/blog/[slug].tsx b/apps/www/pages/blog/[slug].tsx
index 51c3d363b58..844638be517 100644
--- a/apps/www/pages/blog/[slug].tsx
+++ b/apps/www/pages/blog/[slug].tsx
@@ -105,8 +105,6 @@ function BlogPostPage(props: any) {
)
}
- // console.log('props.blog.toc', props.blog.toc)
-
const toc = props.blog.toc && (
<div className="space-y-8 py-8 lg:py-0">
<div>
diff --git a/apps/www/styles/index.css b/apps/www/styles/index.css
index 0cd50606353..dea791e7db2 100644
--- a/apps/www/styles/index.css
+++ b/apps/www/styles/index.css
@@ -84,6 +84,15 @@ h6:not(.overwrite) {
line-height: 1.2 !important;
}
+.toc-animate {
+ transform: translate3d(3px, 0, 0) !important;
+ color: hsla(153, 60%, 53%, 1) !important;
+}
+
+.prose-toc a {
+ transition: all 0.07s ease-in-out;
+}
+
@media only screen and (max-width: 960px) {
.h1:not(.prose *):not(.overwrite) {
font-size: 2.2rem !important;