-
Notifications
You must be signed in to change notification settings - Fork 458
feat: add label support to boolean toggle widgets #7767
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
Open
csongorczezar
wants to merge
17
commits into
main
Choose a base branch
from
feat-widget-label-props
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cb17dae
feat: add label support to boolean toggle widgets
csongorczezar d83c091
fix: render wrapper dynamically
csongorczezar ad9f15d
fix: used generic typing
csongorczezar 3552078
fix: added fallback labels
csongorczezar 2c3ca55
feat: add ToggleGroup support for labeled boolean widgets
csongorczezar d7bacee
fix: aligned colors and positions
csongorczezar 70f9377
fix: adding i18n keys for the fallback strings
csongorczezar 609e2df
fix: disable vue/no-unused-properties for shadcn-vue forwarded props
csongorczezar 28b724c
fix: removed unused imports and dependencies
csongorczezar 0eece3d
[automated] Apply ESLint and Prettier fixes
actions-user c2589e5
fix: use cva from catalog instead of class-variance-authority
csongorczezar cf07b9c
feat: added primary togglegroup buttton styles
csongorczezar 3d3408d
fix: removing unused types
csongorczezar c3fdf81
[automated] Apply ESLint and Prettier fixes
actions-user 88ffe86
feat: added secondary and inverted styles
csongorczezar 174a91c
fix: default variant changed and truncation added
csongorczezar 8678f11
fix: downgrade pinia to 2.2.2 to match main and fix test failures
csongorczezar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <script setup lang="ts"> | ||
| /* eslint-disable vue/no-unused-properties */ | ||
| import { reactiveOmit } from '@vueuse/core' | ||
| import type { ToggleGroupRootEmits, ToggleGroupRootProps } from 'reka-ui' | ||
| import { ToggleGroupRoot, useForwardPropsEmits } from 'reka-ui' | ||
| import type { HTMLAttributes } from 'vue' | ||
| import { provide } from 'vue' | ||
|
|
||
| import { cn } from '@/utils/tailwindUtil' | ||
|
|
||
| import { toggleGroupVariants } from './toggleGroup.variants' | ||
| import type { ToggleGroupItemVariants } from './toggleGroup.variants' | ||
|
|
||
| const props = defineProps< | ||
| ToggleGroupRootProps & { | ||
| class?: HTMLAttributes['class'] | ||
| variant?: ToggleGroupItemVariants['variant'] | ||
| } | ||
| >() | ||
| const emits = defineEmits<ToggleGroupRootEmits>() | ||
|
|
||
| provide('toggleGroup', { | ||
| variant: props.variant | ||
| }) | ||
|
|
||
| const delegatedProps = reactiveOmit(props, 'class') | ||
|
|
||
| const forwarded = useForwardPropsEmits(delegatedProps, emits) | ||
| </script> | ||
|
|
||
| <template> | ||
| <ToggleGroupRoot | ||
| v-slot="slotProps" | ||
| v-bind="forwarded" | ||
| :class="cn(toggleGroupVariants(), props.class)" | ||
| > | ||
| <slot v-bind="slotProps" /> | ||
| </ToggleGroupRoot> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <script setup lang="ts"> | ||
| /* eslint-disable vue/no-unused-properties */ | ||
csongorczezar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { reactiveOmit } from '@vueuse/core' | ||
| import type { ToggleGroupItemProps } from 'reka-ui' | ||
| import { ToggleGroupItem, useForwardProps } from 'reka-ui' | ||
| import type { HTMLAttributes } from 'vue' | ||
| import { inject } from 'vue' | ||
| import { cn } from '@/utils/tailwindUtil' | ||
| import { toggleGroupItemVariants } from './toggleGroup.variants' | ||
| import type { ToggleGroupItemVariants } from './toggleGroup.variants' | ||
| const props = defineProps< | ||
| ToggleGroupItemProps & { | ||
| class?: HTMLAttributes['class'] | ||
| variant?: ToggleGroupItemVariants['variant'] | ||
| } | ||
| >() | ||
| const context = inject<{ variant?: ToggleGroupItemVariants['variant'] }>( | ||
| 'toggleGroup' | ||
| ) | ||
| const delegatedProps = reactiveOmit(props, 'class', 'variant') | ||
| const forwardedProps = useForwardProps(delegatedProps) | ||
| </script> | ||
|
|
||
| <template> | ||
| <ToggleGroupItem | ||
| v-slot="slotProps" | ||
| v-bind="forwardedProps" | ||
| :class=" | ||
| cn( | ||
| toggleGroupItemVariants({ | ||
| variant: context?.variant || variant | ||
| }), | ||
| props.class | ||
| ) | ||
| " | ||
| > | ||
| <span class="truncate min-w-0"> | ||
| <slot v-bind="slotProps" /> | ||
| </span> | ||
| </ToggleGroupItem> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import type { VariantProps } from 'cva' | ||
| import { cva } from 'cva' | ||
|
|
||
| export const toggleGroupVariants = cva({ | ||
| base: 'flex gap-[var(--primitive-padding-padding-1,4px)] p-[var(--primitive-padding-padding-1,4px)] rounded-[var(--primitive-border-radius-rounded-sm,4px)] bg-component-node-widget-background' | ||
| }) | ||
|
|
||
| export const toggleGroupItemVariants = cva({ | ||
| base: 'flex-1 inline-flex items-center justify-center border-0 rounded-[var(--primitive-border-radius-rounded-sm,4px)] px-[var(--primitive-padding-padding-2,8px)] py-[var(--primitive-padding-padding-1,4px)] text-xs font-inter font-normal transition-colors cursor-pointer overflow-hidden', | ||
| variants: { | ||
| variant: { | ||
| primary: [ | ||
| 'data-[state=off]:bg-transparent data-[state=off]:text-muted-foreground', | ||
| 'data-[state=off]:hover:bg-component-node-widget-background-hovered data-[state=off]:hover:text-white', | ||
| 'data-[state=on]:bg-primary-background data-[state=on]:text-white' | ||
| ], | ||
| secondary: [ | ||
| 'data-[state=off]:bg-transparent data-[state=off]:text-muted-foreground', | ||
| 'data-[state=off]:hover:bg-component-node-widget-background-hovered data-[state=off]:hover:text-white', | ||
| 'data-[state=on]:bg-component-node-widget-background-selected data-[state=on]:text-base-foreground' | ||
| ], | ||
| inverted: [ | ||
| 'data-[state=off]:bg-transparent data-[state=off]:text-muted-foreground', | ||
| 'data-[state=off]:hover:bg-component-node-widget-background-hovered data-[state=off]:hover:text-white', | ||
| 'data-[state=on]:bg-white data-[state=on]:text-base-background' | ||
| ] | ||
| } | ||
| }, | ||
| defaultVariants: { | ||
| variant: 'secondary' | ||
| } | ||
| }) | ||
|
|
||
| export type ToggleGroupItemVariants = VariantProps< | ||
| typeof toggleGroupItemVariants | ||
| > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.