Skip to content

Commit

Permalink
refactor: use get-animation-style-variables from utils lib
Browse files Browse the repository at this point in the history
  • Loading branch information
lovrozagar committed Jul 7, 2024
1 parent 82ac080 commit c8bfa5b
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 125 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@renderui/core",
"version": "1.4.4",
"version": "1.4.5",
"private": false,
"description": "React UI library with highly modular and ready-out-of-the-box components",
"license": "MIT",
Expand Down Expand Up @@ -38,7 +38,7 @@
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@renderui/utils": "^0.1.8",
"@renderui/utils": "^0.2.0",
"cmdk": "^1.0.0",
"next-themes": "^0.3.0",
"react-aria": "^3.33.1",
Expand Down
2 changes: 2 additions & 0 deletions src/components/_shared/utils/focus-input.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import React from 'react'

function focusInput(inputRef: React.RefObject<HTMLInputElement>) {
Expand Down
79 changes: 0 additions & 79 deletions src/components/_shared/utils/get-animation-style-variables.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/_shared/utils/is-keyboard-pointer-type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import { PressEvent } from 'react-aria'

function isKeyboardPointerType(event: PressEvent) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/_shared/utils/split-aria-props.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import { UseAriaHandlersProps } from '@/components/_shared/types/aria'

type AriaHandlerPropsSelectorProps<T extends object> = T & Partial<UseAriaHandlersProps>
Expand Down
6 changes: 4 additions & 2 deletions src/components/accordion/components/accordion-content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use client'

import { AccordionContent as AccordionContentPrimitive } from '@radix-ui/react-accordion'
import { cn, getOptionalObject, polymorphic } from '@renderui/utils'
import { cn } from '@renderui/utils/cn'
import { getOptionalObject } from '@renderui/utils/get-optional-object'
import { polymorphic } from '@renderui/utils/polymorphic'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'
import React from 'react'

import {
Expand All @@ -12,7 +15,6 @@ import {
AccordionContentProps,
AccordionContentRef,
} from '@/components/accordion/types/accordion-content'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'

const AccordionContent = React.forwardRef<AccordionContentRef, AccordionContentProps>(
(props, ref) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
COLLAPSIBLE_CONTENT_DEFAULT_ANIMATION_DURATION,
DEFAULT_COLLAPSIBLE_CONTENT_CLASSNAME,
} from '../constants/constants'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const CollapsibleContent = React.forwardRef<CollapsibleContentRef, CollapsibleContentProps>(
(props, ref) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/components/dialog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { cn, cx, getOptionalObject } from '@renderui/utils'
import React from 'react'

import { CrossSmallIcon } from '@/components/_shared/components/icons/cross-small-icon'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { Button } from '@/components/button/components/button'
import { DialogClose } from '@/components/dialog/components/dialog-close'
import {
Expand All @@ -19,6 +18,7 @@ import {
import { DialogContentProps, DialogContentRef } from '@/components/dialog/types/dialog-content'
import { Overlay } from '@/components/overlay/components/overlay'
import { VisuallyHidden } from '@/components/visually-hidden/components/visually-hidden'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const DialogContent = React.forwardRef<DialogContentRef, DialogContentProps>((props, ref) => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { NavigationMenuContent as NavigationMenuContentPrimitive } from '@radix-
import { cn } from '@renderui/utils'
import React from 'react'

import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { DEFAULT_NAVIGATION_MENU_CONTENT_CLASSNAME } from '@/components/navigation-menu/constants/constants'
import {
NavigationMenuContentProps,
NavigationMenuContentRef,
} from '@/components/navigation-menu/types/navigation-menu-content'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const NavigationMenuContent = React.forwardRef<
NavigationMenuContentRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
NavigationMenuProps,
NavigationMenuRef,
} from '@/components/navigation-menu/types/navigation-menu'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const NavigationMenu = React.forwardRef<NavigationMenuRef, NavigationMenuProps>((props, ref) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/components/overlay/components/overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react'

import { DEFAULT_OVERLAY_CLASSNAME } from '@/components/overlay/constants/constants'
import { OverlayProps, OverlayRef } from '@/components/overlay/types/overlay'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const Overlay = React.forwardRef<OverlayRef, OverlayProps>((props, ref) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/components/popover/components/popover-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { cn, getOptionalObject } from '@renderui/utils'
import React from 'react'

import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import {
DEFAULT_POPOVER_ARROW_CLASSNAME,
DEFAULT_POPOVER_ARROW_CONTAINER_CLASSNAME,
Expand All @@ -21,6 +20,7 @@ import {
POPOVER_CONTENT_TRIGGER_WIDTH_CLASSNAME,
} from '@/components/popover/constants/constants'
import { PopoverContentProps, PopoverContentRef } from '@/components/popover/types/popover-content'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const PopoverContent = React.forwardRef<PopoverContentRef, PopoverContentProps>((props, ref) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/components/sheet/components/sheet-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { cn, cx, getOptionalObject } from '@renderui/utils'
import React from 'react'

import { ModalClose } from '@/components/_shared/components/modal-close/modal-close'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { Button } from '@/components/button'
import { Overlay } from '@/components/overlay'
import { sheetClasses } from '@/components/sheet/classes/sheet-classes'
Expand All @@ -19,6 +18,7 @@ import {
import { SheetContentProps, SheetContentRef } from '@/components/sheet/types/sheet-content'
import { VisuallyHidden } from '@/components/visually-hidden'
import { CrossSmallIcon } from '@/components/_shared/components/icons/cross-small-icon'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const SheetContent = React.forwardRef<SheetContentRef, SheetContentProps>((props, ref) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion src/components/skeleton/components/skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'

import { SkeletonProps, SkeletonRef } from '@/components/skeleton/types/skeleton'
import { getMergedClassName } from '@/components/skeleton/utils/get-merged-class-name'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const Skeleton = React.forwardRef<SkeletonRef, SkeletonProps>((props, ref) => {
const {
Expand Down
7 changes: 4 additions & 3 deletions src/components/toggle-group/components/toggle-group-item.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client'

import { ToggleGroupItem as ToggleGroupItemPrimitive } from '@radix-ui/react-toggle-group'
import { cn } from '@renderui/utils'
import { cn } from '@renderui/utils/cn'
import { functionCallOrValue } from '@renderui/utils/function-call-or-value'
import React from 'react'

import { Button } from '@/components/button'
Expand Down Expand Up @@ -34,7 +35,7 @@ const ToggleGroupItem = React.forwardRef<ToggleGroupItemRef, ToggleGroupItemProp
: value.toString() === rootValue.toString()

return (
<ToggleGroupItemPrimitive asChild value={value as string} className={cn(className)}>
<ToggleGroupItemPrimitive asChild value={value as string}>
<Button
ref={ref}
data-slot='item'
Expand All @@ -49,7 +50,7 @@ const ToggleGroupItem = React.forwardRef<ToggleGroupItemRef, ToggleGroupItemProp
data-state={isOn ? 'on' : 'off'}
{...restProps}
>
{children}
{functionCallOrValue(children, { isOn })}
</Button>
</ToggleGroupItemPrimitive>
)
Expand Down
6 changes: 5 additions & 1 deletion src/components/toggle-group/types/toggle-group-item.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Simplify } from '@/components/_shared/types/simplify'

import { ButtonProps, ButtonRef } from '@/components/button'
import { ReactNode } from 'react'

type ToggleGroupItemRef = ButtonRef

type ToggleGroupItemCustomProps = {
value: string | number
hasToggledOffRing?: boolean
children: (({ isOn }: { isOn: boolean }) => ReactNode) | ReactNode
}

type ToggleGroupItemProps = Simplify<Omit<ButtonProps, 'value'> & ToggleGroupItemCustomProps>
type ToggleGroupItemProps = Simplify<
Omit<ButtonProps, 'value' | 'children'> & ToggleGroupItemCustomProps
>

export type { ToggleGroupItemProps, ToggleGroupItemRef }
2 changes: 1 addition & 1 deletion src/components/tooltip/components/tooltip-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
DEFAULT_TOOLTIP_CONTENT_CLASSNAME,
} from '@/components/tooltip/constants/constants'
import { TooltipContentProps, TooltipContentRef } from '@/components/tooltip/types/tooltip-content'
import { getAnimationStyleVariables } from '@/components/_shared/utils/get-animation-style-variables'
import { getAnimationStyleVariables } from '@renderui/utils/get-animation-style-variables'

const TooltipContent = React.forwardRef<TooltipContentRef, TooltipContentProps>((props, ref) => {
const {
Expand Down
Loading

0 comments on commit c8bfa5b

Please sign in to comment.