Skip to content

Commit

Permalink
Merge pull request #435 from lidofinance/feature/ui-916-move-props-de…
Browse files Browse the repository at this point in the history
…struction-to-component-declaration

fix: move props destruction to component declaration
  • Loading branch information
karinamaulitova authored Aug 2, 2023
2 parents 8882e87 + 7a3e82f commit 0fd54f5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
8 changes: 5 additions & 3 deletions packages/input/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import cn from 'classnames'
export type TextareaProps = ComponentPropsWithoutRef<'textarea'> & CommonProps

export const Textarea = forwardRef(
(props: TextareaProps, ref?: ForwardedRef<HTMLTextAreaElement>) => {
const {
(
{
id,
disabled = false,
label,
Expand All @@ -24,7 +24,9 @@ export const Textarea = forwardRef(
wrapperRef,
children,
...rest
} = props
}: TextareaProps,
ref?: ForwardedRef<HTMLTextAreaElement>,
) => {
const hasLabel = !!label && variant === 'default'

const hasError = !!error
Expand Down
8 changes: 5 additions & 3 deletions packages/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export type ModalProps = Omit<ModalOverlayProps, 'title' | 'in'> & {
}

export const Modal = forwardRef(
(props: ModalProps, ref?: ForwardedRef<HTMLDivElement>) => {
const {
(
{
children,
title,
titleIcon,
Expand All @@ -27,7 +27,9 @@ export const Modal = forwardRef(
onClose,
onBack,
...rest
} = props
}: ModalProps,
ref?: ForwardedRef<HTMLDivElement>,
) => {
const withTitleIcon = !!titleIcon
const withSubtitle = !!subtitle
const withCloseButton = !!onClose
Expand Down
9 changes: 4 additions & 5 deletions packages/popup-menu/PopupMenuProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export const usePopupMenuContext = (): PopupMenuContext => {
return useContext(Context)
}

export const PopupMenuProvider: FC<PropsWithChildren<PopupMenuContext>> = (
props,
) => {
const { variant, ...rest } = props

export const PopupMenuProvider: FC<PropsWithChildren<PopupMenuContext>> = ({
variant,
...rest
}) => {
return <Context.Provider value={{ variant }} {...rest} />
}
7 changes: 4 additions & 3 deletions packages/stack/StackProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export const useStackContext = (): StackContext => {
return useContext(Context)
}

export const StackProvider: FC<PropsWithChildren<StackContext>> = (props) => {
const { spacing, ...rest } = props

export const StackProvider: FC<PropsWithChildren<StackContext>> = ({
spacing,
...rest
}) => {
return <Context.Provider value={{ spacing }} {...rest} />
}
9 changes: 5 additions & 4 deletions packages/transition/withTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function withTransition<
): ForwardRefExoticComponent<
PropsWithoutRef<WrappedProps<P>> & RefAttributes<E>
> {
function Wrapped(props: WrappedProps<P>, externalRef: ForwardedRef<E>) {
const {
function Wrapped(
{
in: state = false,
timeout = DEFAULT_DURATION,
mountOnEnter = true,
Expand All @@ -39,8 +39,9 @@ export default function withTransition<
onExiting,
onExited,
...rest
} = props

}: WrappedProps<P>,
externalRef: ForwardedRef<E>,
) {
const transitionProps = {
in: state,
timeout,
Expand Down

0 comments on commit 0fd54f5

Please sign in to comment.