Skip to content

Commit

Permalink
convert forwardRef to ref-as-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
eritbh committed Dec 10, 2024
1 parent 5fcb779 commit f005964
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 50 deletions.
16 changes: 6 additions & 10 deletions extension/data/components/controls/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import {type ComponentPropsWithoutRef, forwardRef} from 'react';
import {type ComponentPropsWithRef} from 'react';
import {classes} from '../../util/ui_interop';
import css from './ActionButton.module.css';

export const ActionButton = forwardRef<
HTMLButtonElement,
ComponentPropsWithoutRef<'button'> & {
inline?: boolean;
}
>(({
export const ActionButton = ({
inline,
className,
...props
}, ref) => (
}: ComponentPropsWithRef<'button'> & {
inline?: boolean;
}) => (
<button
className={classes(
css.actionButton,
inline && css.inline,
className,
)}
{...props}
ref={ref}
/>
));
);
16 changes: 6 additions & 10 deletions extension/data/components/controls/ActionSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import {type ComponentPropsWithoutRef, forwardRef} from 'react';
import {type ComponentPropsWithRef} from 'react';
import {classes} from '../../util/ui_interop';
import css from './ActionSelect.module.css';

export const ActionSelect = forwardRef<
HTMLSelectElement,
ComponentPropsWithoutRef<'select'> & {
inline?: boolean;
}
>(({
export const ActionSelect = ({
inline,
className,
...props
}, ref) => (
}: ComponentPropsWithRef<'select'> & {
inline?: boolean;
}) => (
<select
className={classes(
css.actionSelect,
inline && css.inline,
className,
)}
{...props}
ref={ref}
/>
));
);
16 changes: 6 additions & 10 deletions extension/data/components/controls/BracketButton.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import {type ComponentPropsWithoutRef, forwardRef} from 'react';
import {type ComponentPropsWithRef} from 'react';
import {classes} from '../../util/ui_interop';
import css from './BracketButton.module.css';

export const BracketButton = forwardRef<
HTMLButtonElement,
ComponentPropsWithoutRef<'button'> & {
inline?: boolean;
}
>(({
export const BracketButton = ({
inline,
className,
...props
}, ref) => (
}: ComponentPropsWithRef<'button'> & {
inline?: boolean;
}) => (
<button
className={classes(css.bracketButton, className)}
{...props}
ref={ref}
/>
));
);
16 changes: 6 additions & 10 deletions extension/data/components/controls/GeneralButton.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import {type ComponentPropsWithoutRef, forwardRef} from 'react';
import {type ComponentPropsWithRef} from 'react';
import {classes} from '../../util/ui_interop';
import css from './GeneralButton.module.css';

export const GeneralButton = forwardRef<
HTMLButtonElement,
ComponentPropsWithoutRef<'button'> & {
inline?: boolean;
}
>(({
export const GeneralButton = ({
inline,
className,
...props
}, ref) => (
}: ComponentPropsWithRef<'button'> & {
inline?: boolean;
}) => (
<button
className={classes(css.generalButton, className)}
{...props}
ref={ref}
/>
));
);
16 changes: 6 additions & 10 deletions extension/data/components/controls/NormalInput.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import {type ComponentPropsWithoutRef, forwardRef} from 'react';
import {type ComponentPropsWithRef} from 'react';
import {classes} from '../../util/ui_interop';
import css from './NormalInput.module.css';

// TODO: this is a terrible name
export const NormalInput = forwardRef<
HTMLInputElement,
ComponentPropsWithoutRef<'input'> & {
inFooter?: boolean;
}
>(({
export const NormalInput = ({
inFooter,
className,
...props
}, ref) => (
}: ComponentPropsWithRef<'input'> & {
inFooter?: boolean;
}) => (
<input
className={classes(
css.normalInput,
inFooter && css.inWindowFooter,
className,
)}
{...props}
ref={ref}
/>
));
);

0 comments on commit f005964

Please sign in to comment.