Skip to content

Commit

Permalink
Add some type adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Dec 27, 2024
1 parent d9c1191 commit 61a9ddf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 27 deletions.
21 changes: 11 additions & 10 deletions packages/fuselage/src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ import { useBoxTransform, BoxTransforms } from './BoxTransforms';
import type { StylingProps } from './stylingProps';
import { useStylingProps } from './useStylingProps';

type BoxProps = {
export interface BoxProps
extends Partial<StylingProps>,
Omit<
AllHTMLAttributes<HTMLElement>,
'ref' | 'is' | 'className' | 'size' | 'elevation' | keyof StylingProps
>,
Omit<
SVGAttributes<SVGElement>,
keyof AllHTMLAttributes<HTMLElement> | 'elevation' | keyof StylingProps
> {
/**
* The `is` prop is used to render the Box as a different HTML tag. It can also be used to render a different fuselage component.
*/
Expand All @@ -25,15 +34,7 @@ type BoxProps = {
animated?: boolean;
withRichContent?: boolean | 'inlineWithoutBreaks';
htmlSize?: AllHTMLAttributes<HTMLElement>['size'];
} & Partial<StylingProps> &
Omit<
AllHTMLAttributes<HTMLElement>,
'ref' | 'is' | 'className' | 'size' | 'elevation'
> &
Omit<
SVGAttributes<SVGElement>,
keyof AllHTMLAttributes<HTMLElement> | 'elevation'
>;
}

export const Box = forwardRef(function Box(
{ is = 'div', children, ...props }: BoxProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage/src/components/Box/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default } from './Box';
export { default, default as Box, BoxProps } from './Box';
export { default as StylingBox, type StylingBoxProps } from './StylingBox';
4 changes: 2 additions & 2 deletions packages/fuselage/src/components/Box/useStylingProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { StylingProps } from './stylingProps';
import { extractStylingProps } from './stylingProps';

export const useStylingProps = <TProps extends { className?: string }>(
originalProps: TProps & Partial<StylingProps>,
): TProps => {
originalProps: TProps,
): Omit<TProps, keyof StylingProps> => {
const [props, styles] = extractStylingProps(originalProps);

const newClassName = useStyle(styles, undefined);
Expand Down
2 changes: 0 additions & 2 deletions packages/fuselage/src/hooks/useBoxOnlyProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { prependClassName } from '../helpers/prependClassName';
export const useBoxOnlyProps = <
T extends {
className: string;
size?: AllHTMLAttributes<HTMLElement>['size'];
},
>(
props: T & {
animated?: boolean;
withRichContent?: boolean | 'inlineWithoutBreaks';
elevation?: '0' | '1' | '2';
htmlSize?: AllHTMLAttributes<HTMLElement>['size'];
size?: AllHTMLAttributes<HTMLElement>['size'];
},
Expand Down
2 changes: 1 addition & 1 deletion packages/layout/src/List/List.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from '@rocket.chat/styled';
import type { CSSProperties } from 'react';

type ListComponentProps = {
color: string;
color: NonNullable<CSSProperties['color']>;
icon?: string;
listStyleType: CSSProperties['listStyleType'];
};
Expand Down
12 changes: 3 additions & 9 deletions packages/layout/src/List/List.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type { Box } from '@rocket.chat/fuselage';
import { Margins } from '@rocket.chat/fuselage';
import colors from '@rocket.chat/fuselage-tokens/colors.json';
import type {
ReactElement,
ReactNode,
ComponentProps,
CSSProperties,
} from 'react';
import type { ReactNode, ComponentProps, CSSProperties } from 'react';

import { ListComponent } from './List.styles';
import ListItem from './ListItem';
Expand All @@ -21,9 +15,9 @@ const List = ({
children: ReactNode;
spacing?: ComponentProps<typeof Margins>['block'];
listStyleType?: CSSProperties['listStyleType'];
color?: ComponentProps<typeof Box>['color'];
color?: CSSProperties['color'];
icon?: string;
}): ReactElement => (
}) => (
<ListComponent icon={icon} listStyleType={listStyleType} color={color}>
<Margins block={spacing}>{children}</Margins>
</ListComponent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'react-i18next';
import 'i18next';

declare module 'react-i18next' {
declare module 'i18next' {
interface CustomTypeOptions {
allowObjectInHTMLChildren: true;
}
Expand Down

0 comments on commit 61a9ddf

Please sign in to comment.