Skip to content
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

Reduce amount of console warnings #975

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
4 changes: 1 addition & 3 deletions src/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,7 @@ const Sidebar = () => {
key="sidebar"
forwardedAs="nav"
height="100%"
css={`
overflow: scroll;
`}
overflow="scroll"
width={{ default: '240px', s: '65px' }}
backgroundColor={getValueForSidebar('backgroundColor')}
color={getValueForSidebar('color')}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type FooterLinkProps = {
const FooterLink = ({ footerVariant, ...props }: FooterLinkProps) => (
<Link
{...props}
as="span"
css={`
text-decoration: underline;
color: ${footerVariant === FooterVariants.LOGIN
Expand Down
8 changes: 4 additions & 4 deletions src/ui/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const IconWarning = () => {
width={24}
viewBox="0 0 24 24"
>
<g clip-path="url(#a)">
<g clip-path="url(#b)">
<g clipPath="url(#a)">
<g clipPath="url(#b)">
<path
d="M1 21h22L12 2 1 21Zm12-3h-2v-2h2v2Zm0-4h-2v-4h2v4Z"
fill="#E69336"
Expand All @@ -46,7 +46,7 @@ const IconSuccess = () => {
width={24}
viewBox="0 0 24 24"
>
<g clip-path="url(#a)">
<g clipPath="url(#a)">
<path
d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2Z"
fill="#6BCD69"
Expand Down Expand Up @@ -85,7 +85,7 @@ const IconError = () => {
width={24}
viewBox="0 0 24 24"
>
<g clip-path="url(#a)">
<g clipPath="url(#a)">
<path
d="M11 15h2v2h-2v-2Zm0-8h2v6h-2V7Zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2ZM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8Z"
fill="#DD5242"
Expand Down
13 changes: 11 additions & 2 deletions src/ui/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ReactDatePickerProps } from 'react-datepicker';
import type {
FlattenInterpolation,
FlattenSimpleInterpolation,
StyledConfig,
ThemeProps,
} from 'styled-components';
import styled, { css } from 'styled-components';
Expand Down Expand Up @@ -201,6 +202,7 @@ type UIProps = {
minHeight: UIProp<string | number>;
minWidth: UIProp<string | number>;
objectFit: UIProp<string>;
overflow: UIProp<string>;
opacity: UIProp<number>;
padding: UIProp<number>;
paddingBottom: UIProp<number>;
Expand Down Expand Up @@ -442,6 +444,7 @@ const boxProps = css`
${parseProperty('zIndex')};

${parseProperty('display')};
${parseProperty('overflow')};
${parseProperty('opacity')};
${parseProperty('flex')};
${parseProperty('flexShrink')};
Expand All @@ -467,6 +470,7 @@ const boxPropTypes = [
'display',
'flex',
'flexShrink',
'flexWrap',
'fontSize',
'fontWeight',
'fontStyle',
Expand All @@ -489,6 +493,7 @@ const boxPropTypes = [
'objectFit',
'onClick',
'opacity',
'overflow',
'padding',
'paddingBottom',
'paddingLeft',
Expand All @@ -502,7 +507,9 @@ const boxPropTypes = [
'textAlign',
'textDecoration',
'top',
'stackOn',
'width',
'size',
'zIndex',
'dangerouslySetInnerHTML',
] as const;
Expand All @@ -511,9 +518,11 @@ const notAllowedPropsSet = new Set(
difference(boxPropTypes, ['as', 'id', 'onClick', 'dangerouslySetInnerHTML']),
);

const StyledBox = styled.div.withConfig({
export const withoutDisallowedPropsConfig: StyledConfig = {
shouldForwardProp: (prop) => !notAllowedPropsSet.has(prop as any),
})`
};

const StyledBox = styled.div.withConfig(withoutDisallowedPropsConfig)`
${boxProps}
`;

Expand Down
10 changes: 8 additions & 2 deletions src/ui/Inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

import { useMatchBreakpoint } from '@/hooks/useMatchBreakpoint';

import type { BoxProps, UIProp, UnknownProps } from './Box';
import {
BoxProps,
notAllowedPropsSet,

Check failure on line 9 in src/ui/Inline.tsx

View workflow job for this annotation

GitHub Actions / types

Module '"./Box"' declares 'notAllowedPropsSet' locally, but it is not exported.
UIProp,
UnknownProps,
withoutDisallowedPropsConfig,
} from './Box';
import {
Box,
boxProps,
Expand Down Expand Up @@ -44,7 +50,7 @@
${parseStackOnProperty()};
`;

const StyledBox = styled(Box)`
const StyledBox = styled(Box).withConfig(withoutDisallowedPropsConfig)`
${inlineProps};
${boxProps};
`;
Expand Down
1 change: 0 additions & 1 deletion src/ui/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const Notification = ({ icon, header, body }: Props) => {
paddingBottom={4}
paddingRight={5}
paddingLeft={4}
as={BootstrapToast.Body}
alignItems="center"
color={getValue('textColor.dark')}
>
Expand Down
86 changes: 46 additions & 40 deletions src/ui/RadioButtonWithLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import React, { ReactNode, Ref } from 'react';

import { BoxProps } from './Box';
import { getInlineProps, Inline } from './Inline';
Expand All @@ -14,44 +14,50 @@ type Props = RadioButtonProps &
label?: ReactNode;
};

const RadioButtonWithLabel = ({
id,
name,
disabled,
onChange,
label,
info,
value,
className,
checked,
type,
...props
}: Props) => {
return (
<Inline
className={className}
alignItems={info ? 'flex-start' : 'center'}
spacing={3}
as="li"
{...getInlineProps(props)}
>
<RadioButton
id={id}
type={type}
onChange={onChange}
disabled={disabled}
value={value}
name={name}
checked={checked}
/>
<Stack>
<Label cursor="pointer" htmlFor={id}>
{label}
</Label>
{!!info && <Text variant={TextVariants.MUTED}>{info}</Text>}
</Stack>
</Inline>
);
};
const RadioButtonWithLabel = React.forwardRef(
(
{
id,
name,
disabled,
onChange,
label,
info,
value,
className,
checked,
type,
...props
}: Props,
ref: Ref<HTMLElement>,
) => {
return (
<Inline
className={className}
alignItems={info ? 'flex-start' : 'center'}
spacing={3}
as="li"
ref={ref}
{...getInlineProps(props)}
>
<RadioButton
id={id}
type={type}
onChange={onChange}
disabled={disabled}
value={value}
name={name}
checked={checked}
/>
<Stack>
<Label cursor="pointer" htmlFor={id}>
{label}
</Label>
{!!info && <Text variant={TextVariants.MUTED}>{info}</Text>}
</Stack>
</Inline>
);
},
);

export { RadioButtonWithLabel };
17 changes: 14 additions & 3 deletions src/ui/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { pickBy } from 'lodash';
import { Children, cloneElement, forwardRef } from 'react';
import styled, { css } from 'styled-components';

import type { BoxProps, UIProp, UnknownProps } from './Box';
import {
BoxProps,
getBoxProps,
UIProp,
UnknownProps,
withoutDisallowedPropsConfig,
} from './Box';
import {
Box,
boxProps,
Expand All @@ -27,7 +33,7 @@ const stackProps = css`
${parseProperty('justifyContent')};
`;

const StyledBox = styled(Box)`
const StyledBox = styled(Box).withConfig(withoutDisallowedPropsConfig)`
${stackProps};
${boxProps};
`;
Expand All @@ -50,7 +56,12 @@ const Stack = forwardRef<HTMLElement, Props>(
});

return (
<StyledBox className={className} as={as} ref={ref} {...props}>
<StyledBox
className={className}
as={as}
ref={ref}
{...getBoxProps(props)}
>
{clonedChildren}
</StyledBox>
);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Typeahead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const TypeaheadInner = <T extends TypeaheadModel>(
hideNewInputText,
newSelectionPrefix,
positionFixed,
isLoading,
isLoading = false,
...props
}: Props<T>,
ref: ForwardedRef<BootstrapTypeahead<T>>,
Expand Down
Loading