Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VIconBtn): create new component #21114

Open
wants to merge 30 commits into
base: dev
Choose a base branch
from
Open

feat(VIconBtn): create new component #21114

wants to merge 30 commits into from

Conversation

johnleider
Copy link
Member

@johnleider johnleider commented Mar 17, 2025

Motivation and Context

  • A new lightweight component (~~50%~~30% faster than VBtn) that will be used to eventually replace VBtn usage throughout
  • Currently VBtn is used in a variety of components such as VTreeview, VDataTable, VDatePicker, VCarousel where it contains infinitely more functionality than what will ever be needed
  • Wanted to have a way to start bringing back toggle icons rotating for expansion components like VList, VTreeview, VExpansionPanels
  • Will also eventually replace closable buttons

TODO: https://m3.material.io/components/icon-buttons

Markup:

<template>
  <v-app>
    <v-main>
      <v-container>
        <v-toolbar class="px-3" title="Toolbar">
          <template #append>
            <div class="d-flex ga-2">
              <v-icon-btn icon="mdi-magnify" :opacity="dialog ? 1 : 0.32">
                <v-icon  />

              <v-dialog v-model="dialog" activator="parent" width="400">
                <v-card title="Find in page">
                  <v-card-text>
                    <v-text-field label="Search" hide-details="auto" />
                  </v-card-text>

                  <template #actions>
                    <v-btn text="Cancel" variant="plain" @click="dialog = false"></v-btn>

                    <v-btn text="Search" @click="dialog = false"></v-btn>
                  </template>
                </v-card>
              </v-dialog>
            </v-icon-btn>
            </div>
          </template>
        </v-toolbar>
      </v-container>
    </v-main>
  </v-app>
</template>

<script setup>
  import { shallowRef } from 'vue'

  const menu = shallowRef(false)
  const dialog = shallowRef(false)
</script>

@johnleider johnleider self-assigned this Mar 17, 2025
@MajesticPotatoe MajesticPotatoe added the T: feature A new feature label Mar 18, 2025
@johnleider johnleider marked this pull request as ready for review March 22, 2025 19:23
@johnleider johnleider added the C: New Component This issue would need a new component to be developed. label Mar 22, 2025
@johnleider johnleider added this to the v3.8.0 (Andromeda) milestone Mar 22, 2025
@johnleider johnleider requested a review from a team March 22, 2025 19:29
Copy link
Member

Choose a reason for hiding this comment

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

Missing variant prop?

}, 'VIconBtn')

export const VIconBtn = genericComponent<VIconBtnSlots>()({
name: 'VIconBtn',
Copy link
Member

@ikushum ikushum Mar 23, 2025

Choose a reason for hiding this comment

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

Since our button-related components have names such as VBtnToggle, VBtnGroup, it would make more sense to name this component VBtnIcon rather than VIconBtn.

Copy link
Member Author

Choose a reason for hiding this comment

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

What does everyone think? I chose the name for 2 reasons:

  • VCheckboxBtn
  • That's what Google calls it

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with VIconBtn. I think the last word should be what it is, a btn.

@KaelWD
Copy link
Member

KaelWD commented Mar 25, 2025

Sample size of 1 but looks like 1000x v-btn = 380ms and 1000x v-icon-btn = 270ms (29% faster)

{
'--v-icon-btn-rotate': convertToUnit(props.rotate, 'deg'),
'--v-icon-btn-height': props.size ? convertToUnit(props.size) : undefined,
'--v-icon-btn-width': props.size ? convertToUnit(props.size) : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

No named sizes?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's meant to be more intentional in it's size, it's why I didn't add density either.

Copy link
Contributor

@eesayas eesayas left a comment

Choose a reason for hiding this comment

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

I think it looks good! I don't think a density prop is needed since icon will remain the same size and btn size can be adjusted via size prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: New Component This issue would need a new component to be developed. T: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants