shinokada / svelte-heros-v2

Hero Icons v2 for Svelte. You can select outline and solid icons using the variation props. Svlete-Heros support major CSS framework. You can add additional CSS using the `class` props.
https://svelte-heros-v2.codewithshin.com
Apache License 2.0
41 stars 3 forks source link

[FEAT]: Mini variation #16

Closed mvartuc closed 1 year ago

mvartuc commented 1 year ago

Description

Would love to be able to use the "Mini" variation with all the icons. It's especially useful in header elements and form components. Saves time playing with the icon sizes and a lot of component libraries utilize it so it'd make it easier to implement them. image

Additional Information

No response

shinokada commented 1 year ago

Can you try size="20"?

mvartuc commented 1 year ago
   <button
    type="button"
    class="group inline-flex items-center rounded-md bg-white bg-opacity-0 px-3 py-2 text-sm font-medium text-indigo-100 hover:bg-opacity-10 focus:outline-none"
    aria-expanded="false"
  >
    <span>Categories</span>
    <!-- Heroicon name: mini/chevron-down -->
    <svg
      class="ml-2 h-5 w-5 text-indigo-100"
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 20 20"
      fill="currentColor"
      aria-hidden="true"
    >
      <path
        fill-rule="evenodd"
        d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z"
        clip-rule="evenodd"
      />
    </svg>
    <ChevronDown size="20" class="ml-2 h-5 w-5 text-indigo-100" />
  </button>

Here's the result: (Left one is the mini variation and the right one is outline with size="20") image

shinokada commented 1 year ago

Try viewBox and variation props and let me know:

<ChevronDown size="20" viewBox="0 0 20 20" variation="solid" class="ml-2 h-5 w-5 text-indigo-100" />
mvartuc commented 1 year ago

Left:

<svg
  class="ml-2 h-5 w-5 text-indigo-100"
  xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 20 20"
  fill="currentColor"
  aria-hidden="true"
>
  <path
    fill-rule="evenodd"
    d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z"
    clip-rule="evenodd"
  />
</svg>

Middle: <ChevronDown size="20" viewBox="0 0 20 20" variation="solid" class="ml-2 h-5 w-5 text-indigo-100" /> Right: <ChevronDown size="20" class="ml-2 h-5 w-5 text-indigo-100" />

image

shinokada commented 1 year ago

How about this?

<ChevronDown size="20" viewBox="0 0 20 20" class="ml-2 w-4 h-4 text-red-900" />
<ChevronDown size="20" viewBox="0 0 20 20" class="ml-2 w-3 h-3 text-red-900" />
mvartuc commented 1 year ago

left one is still the mini variation svg path, the right ones are w-4 h-4 and w-3 h-3 in that order image

shinokada commented 1 year ago

Change the strokeWidth prop:

<ChevronDown size="20" viewBox="0 0 20 20" strokeWidth="2" class="ml-2 w-4 h-4 text-white" />

image Top mini-svg and Bottom svelte-heros-v2.

When I have time, I will add mini.

mvartuc commented 1 year ago

Is there a reason you can't introduce a new variation? Just seems like there's no direct conversion. I've played with the stroke width as well just doesn't translate easily at all.

shinokada commented 1 year ago

I need to update my script to add 20/solid for all icons.

shinokada commented 1 year ago

Can you try the latest and let me know?

pnpm I -D 'svelte-heros-v2@latest

Use variation="mini":

<AcademicCap variation="mini" />
mvartuc commented 1 year ago

Works great! Thanks a lot for the quick fix. image

mvartuc commented 1 year ago

The only problem is that the icon is focusable, I even added tabindex="-1" but it's still focusable when clicked directly on it.

  <button
    use:popover.button
    type="button"
    class:bg-opacity-10={$popover.expanded}
    class="group inline-flex items-center rounded-md bg-white bg-opacity-0 px-3 py-2 text-sm font-medium text-indigo-100 hover:bg-opacity-10"
    aria-expanded="false"
  >
    <span>Categories</span>
    <!-- Heroicon name: mini/chevron-down      -->
    <svg
      class="ml-2 h-5 w-5"
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 20 20"
      fill="currentColor"
      aria-hidden="true"
    >
      <path
        fill-rule="evenodd"
        d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z"
        clip-rule="evenodd"
      />
    </svg>

    <ChevronDown variation="mini" class="ml-2 h-5 w-5" aria-hidden="true" tabindex="-1" />
  </button>

The left one doesn't produce any focus indicators but the right one does for some reason. I tried removed role="img" as well but it still does this. image

shinokada commented 1 year ago

Can you add tabindex="-1" to the button?

tabindex="-1" works when I use it as it is.