Skip to content

Commit

Permalink
feat: accent-focus color
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 4, 2023
1 parent df5d8ba commit 5fffb75
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/widgets/post/PostRelated.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client'

import Link from 'next/link'

import { Divider } from '~/components/ui/divider'
import { useCurrentPostDataSelector } from '~/providers/post/CurrentPostDataProvider'

import { PeekLink } from '../peek/PeekLink'

export const PostRelated = () => {
const related = useCurrentPostDataSelector((s) => s?.related)
if (!related) {
Expand All @@ -24,12 +24,12 @@ export const PostRelated = () => {
{related.map((post) => {
return (
<li key={post.id}>
<PeekLink
<Link
href={`/posts/${post.category.slug}/${post.slug}`}
className="underline-current underline-dashed leading-10 underline"
>
{post.title}
</PeekLink>
</Link>
</li>
)
})}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function addAlphaToHSL(hsl: string, alpha: number): string {
return hsla.replace('hsl', 'hsla')
}

export function hexToHsl(hex: string): string {
export function hexToHsl(hex: string) {
// Remove the '#' symbol from the hex code
hex = hex.replace('#', '')

Expand Down Expand Up @@ -121,5 +121,5 @@ export function hexToHsl(hex: string): string {
s = Math.round(s * 100)

// Return the HSL values as a string
return `${h} ${s}% ${Math.round(l * 100)}%`
return [h, s, Math.round(l * 100)]
}
12 changes: 10 additions & 2 deletions src/providers/root/accent-color-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ export const AccentColorProvider = ({ children }: PropsWithChildren) => {
const accentColorL = sample(accentColorLight)
const accentColorD = sample(accentColorDark)

const lightHsl = hexToHsl(accentColorL)
const darkHsl = hexToHsl(accentColorD)

const [hl, sl, ll] = lightHsl
const [hd, sd, ld] = darkHsl

return (
<style
dangerouslySetInnerHTML={{
__html: `html[data-theme='dark'] {
--a: ${hexToHsl(accentColorD)};
--a: ${`${hl} ${sl}% ${ll}%`};
--af: ${`${hl} ${sl}% ${ll + 6}%`};
}
html[data-theme='light'] {
--a: ${hexToHsl(accentColorL)};
--a: ${`${hd} ${sd}% ${ld}%`};
--af: ${`${hd} ${sd}% ${ld - 6}%`};
}
`,
}}
Expand Down

1 comment on commit 5fffb75

@vercel
Copy link

@vercel vercel bot commented on 5fffb75 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

springtide.vercel.app
shiro-git-main-innei.vercel.app
shiro-innei.vercel.app
innei.in

Please sign in to comment.