yamada-ui / yamada-colors

All-in-one color tool of the Yamada, by the Yamada, for the Yamada.
https://yamada-colors.app
MIT License
16 stars 4 forks source link

fix(color.ts): keep origin color and converting tones #68

Closed jiwooproity closed 3 months ago

jiwooproity commented 3 months ago

Closes #67

Description

I think it cant resolve the problem, but if keep origin color and converting tones it will be resolve

The reason I chose to keep the original color is because the format of hsl has different saturation than hex and rgb, so changes may occur when converted back to hex code.

Current behavior (updates)

A conditional statement to maintain the original color was added to the utils/color.ts/tones function.

Among the 11 colors, the 1st to 5th colors are light and the 7th to 11th colors are dark to maintain the original color.

export const tone = (hex: string) => {
  const [h, s, l] = toHsl(hex)
  const hexes: string[] = []
  const d = l <= 50
  const x = ((!d ? 100 : 95) - l) / 5
  const y = (l - (d ? 5 : 15)) / 5

  tones.forEach((tone) => {
    const t = tone / 100
    let z: number = l
    let origin: boolean = false

    if (t < 5) {
      z = l + (5 - t) * x
    } else if (t > 5) {
      z = l - (t - 5) * y
    } else {
      origin = true // keep orignal hex
    }

    hexes.push(origin ? hex : `#${convert.hsl.hex([h, s, z]).toLowerCase()}`)
  })

  return hexes
}

New behavior

I added conditional statement in utils/color.ts/tones function

Looking at the problem, the 6th color out of 11 colors must maintain the Hex value selected by the user. However, since rgb and hex values ​​may change when converting to hsl, we have added a condition to maintain the original color.

Is this a breaking change (Yes/No):

[No] I just add to conditional statement for keep origin color, and it will convering tones 50 ~ 400, 600 ~ 950 then keep color hex value

Additional Information

I used papago tool,, i cant speak english well sry Please review once!

vercel[bot] commented 3 months ago

@jiwooproity is attempting to deploy a commit to the yamada-ui Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yamada-colors ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 8, 2024 3:20pm
hirotomoyamada commented 3 months ago

Thanks!