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

🐛 fix console errors #617

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-tigers-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kitchn": patch
---

Remove all React warnings from console
17 changes: 7 additions & 10 deletions examples/gatsby-typescript/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const IndexPage: React.FC<PageProps> = () => {
align={"center"}
>
<Container w={"100%"} align={"center"} justify={"space-between"} row>
<Card p={"small"} br={"square"} align={"center"} active row>
<Card p={"small"} br={"square"} align={"center"} bw={1} row>
<Text span>
{"Get started by editing \r"}
<Text size={"compact"} monospace span>
Expand Down Expand Up @@ -68,7 +68,7 @@ const IndexPage: React.FC<PageProps> = () => {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://kitchn.tonightpass.com/docs"}
p={"small"}
flex={1}
Expand All @@ -85,7 +85,7 @@ const IndexPage: React.FC<PageProps> = () => {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={"https://discord.gg/VvvAkPqQ98"}
p={"small"}
flex={1}
Expand All @@ -110,7 +110,7 @@ const IndexPage: React.FC<PageProps> = () => {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://patreon.com/onruntime"}
p={"small"}
flex={1}
Expand All @@ -125,7 +125,7 @@ const IndexPage: React.FC<PageProps> = () => {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={
"https://vercel.com/new/git/external?repository-url=https://github.com/tonightpass/kitchn/tree/master/examples/next-typescript&project-name=kitchn-app&repository-name=kitchn-app"
}
Expand All @@ -148,11 +148,8 @@ const IndexPage: React.FC<PageProps> = () => {
);
};

const Card = kitchn(Container)<{
active?: boolean;
}>`
border: 1px solid ${({ theme, active }) =>
active ? theme.colors.layout.dark : "transparent"};
const Card = kitchn(Container)`
border: 1px solid transparent;
transition: all 0.2s ease-in-out;
&:hover {
border: 1px solid ${({ theme }) => theme.colors.layout.dark};
Expand Down
17 changes: 7 additions & 10 deletions examples/next-typescript/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const IndexPage = () => {
<link rel={"icon"} href={"/favicon.ico"} />
</Head>
<Container w={"100%"} align={"center"} justify={"space-between"} row>
<Card p={"small"} br={"square"} align={"center"} active row>
<Card p={"small"} br={"square"} align={"center"} bw={1} row>
<Text span>
{"Get started by editing \r"}
<Text size={"compact"} monospace span>
Expand Down Expand Up @@ -71,7 +71,7 @@ const IndexPage = () => {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://kitchn.tonightpass.com/docs"}
p={"small"}
flex={1}
Expand All @@ -88,7 +88,7 @@ const IndexPage = () => {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={"https://discord.gg/VvvAkPqQ98"}
p={"small"}
flex={1}
Expand All @@ -113,7 +113,7 @@ const IndexPage = () => {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://patreon.com/onruntime"}
p={"small"}
flex={1}
Expand All @@ -128,7 +128,7 @@ const IndexPage = () => {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={
"https://vercel.com/new/git/external?repository-url=https://github.com/tonightpass/kitchn/tree/master/examples/next-typescript&project-name=kitchn-app&repository-name=kitchn-app"
}
Expand All @@ -151,11 +151,8 @@ const IndexPage = () => {
);
};

const Card = kitchn(Container)<{
active?: boolean;
}>`
border: 1px solid ${({ theme, active }) =>
active ? theme.colors.layout.dark : "transparent"};
const Card = kitchn(Container)`
border: 1px solid transparent;
transition: all 0.2s ease-in-out;
&:hover {
border: 1px solid ${({ theme }) => theme.colors.layout.dark};
Expand Down
17 changes: 7 additions & 10 deletions examples/react-typescript/src/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Template() {
align={"center"}
>
<Container w={"100%"} align={"center"} justify={"space-between"} row>
<Card p={"small"} br={"square"} align={"center"} active row>
<Card p={"small"} br={"square"} align={"center"} bw={1} row>
<Text span>
{"Get started by editing \r"}
<Text size={"compact"} monospace span>
Expand Down Expand Up @@ -66,7 +66,7 @@ export default function Template() {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://kitchn.tonightpass.com/docs"}
p={"small"}
flex={1}
Expand All @@ -83,7 +83,7 @@ export default function Template() {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={"https://discord.gg/VvvAkPqQ98"}
p={"small"}
flex={1}
Expand All @@ -108,7 +108,7 @@ export default function Template() {
row
>
<Card
as={Link}
forwardedAs={Link}
href={"https://patreon.com/onruntime"}
p={"small"}
flex={1}
Expand All @@ -123,7 +123,7 @@ export default function Template() {
</Card>

<Card
as={Link}
forwardedAs={Link}
href={
"https://vercel.com/new/git/external?repository-url=https://github.com/tonightpass/kitchn/tree/master/examples/next-typescript&project-name=kitchn-app&repository-name=kitchn-app"
}
Expand All @@ -146,11 +146,8 @@ export default function Template() {
);
}

const Card = kitchn(Container)<{
active?: boolean;
}>`
border: 1px solid ${({ theme, active }) =>
active ? theme.colors.layout.dark : "transparent"};
const Card = kitchn(Container)`
border: 1px solid transparent;
transition: all 0.2s ease-in-out;
&:hover {
border: 1px solid ${({ theme }) => theme.colors.layout.dark};
Expand Down
2 changes: 1 addition & 1 deletion packages/kitchn/src/components/Badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const BadgeComponent = styled(({ children, ...props }: BadgeProps) => {
return theme.colors.layout.light;
case "primary":
default:
return theme.colors.layout.darkest;
return theme.colors.layout.darker;
}
}};
`;
Expand Down
2 changes: 0 additions & 2 deletions packages/kitchn/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const ButtonComponent = styled(
width,
prefix,
suffix,
type,
htmlType,
...props
}: ButtonProps) => {
Expand All @@ -52,7 +51,6 @@ const ButtonComponent = styled(
aria-disabled={props.disabled ? "true" : undefined}
role={"button"}
type={htmlType}
$type={type}
{...props}
>
{(prefix || loading) && (
Expand Down
2 changes: 2 additions & 0 deletions packages/kitchn/src/components/Collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const CollapseComponent = styled(
children,
defaultExpanded = false,
size = "medium",
// Prevent 'card' from being passed to the DOM element
card: _card,
...props
}: CollapseProps) => {
const contentContainerRef = React.useRef<HTMLDivElement>(null);
Expand Down
12 changes: 11 additions & 1 deletion packages/kitchn/src/components/Container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ export type ContainerProps = Props & React.ComponentPropsWithRef<"div">;

const ForwardedContainer = React.forwardRef<HTMLDivElement, ContainerProps>(
(
{ children, header, section, form, label, ...rest }: ContainerProps,
{
children,
header,
section,
form,
label,
// This prevents 'row' and 'gap' from being passed to the DOM element, avoiding React warnings
row: _row,
gap: _gap,
...rest
}: ContainerProps,
ref: React.ForwardedRef<HTMLDivElement>,
) => {
const Component = header
Expand Down
10 changes: 5 additions & 5 deletions packages/kitchn/src/components/Entity/Field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export type EntityFieldTitleProps = KitchnComponent<
>;

export const EntityFieldTitle = styled(
({ ...props }: EntityFieldTitleProps) => {
({ active, label, ...props }: EntityFieldTitleProps) => {
return (
<Text
size={props.label ? "small" : "compact"}
weight={props.label ? "regular" : "semiBold"}
color={props.label ? "light" : !props.active ? "light" : "lightest"}
transform={props.label ? "uppercase" : "none"}
size={label ? "small" : "compact"}
weight={label ? "regular" : "semiBold"}
color={label ? "light" : !active ? "light" : "lightest"}
transform={label ? "uppercase" : "none"}
truncate
span
{...props}
Expand Down
21 changes: 14 additions & 7 deletions packages/kitchn/src/components/Fieldset/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,20 @@
: theme.colors.layout.darker};
`;

const FieldsetComponent = styled(({ children, ...props }: FieldsetProps) => {
return (
<div role={"group"} {...props}>
{children}
</div>
);
})<FieldsetProps>`
const FieldsetComponent = styled(
({
children,
// Prevents the 'tabs' prop from being passed down to the DOM element
tabs: _tabs,
...props
}: FieldsetProps) => {
return (
<div role={"group"} {...props}>
{children}
</div>
);
},
)<FieldsetProps>`
overflow: hidden;
position: relative;
box-sizing: border-box;
Expand Down Expand Up @@ -113,7 +120,7 @@

export const isFieldsetContainer = (
child: React.ReactNode,
): child is React.ReactElement<any> => {

Check warning on line 123 in packages/kitchn/src/components/Fieldset/index.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and ubuntu-latest

Unexpected any. Specify a different type
return React.isValidElement(child) && child.type === Fieldset.Container;
};

Expand Down
1 change: 0 additions & 1 deletion packages/kitchn/src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const FooterNav = styled.nav`
display: grid;
grid-template-columns: ${({ children }) =>
`repeat(${Math.min(React.Children.count(children), 4)}, 1fr)`};
gap: ${({ theme }) => theme.gap.normal};

@media (max-width: ${({ theme }) => theme.breakpoint.laptop}) {
grid-template-columns: ${({ children }) =>
Expand Down
8 changes: 7 additions & 1 deletion packages/kitchn/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ type Props = IconSource & {
export type IconProps = KitchnComponent<Props, React.SVGProps<SVGSVGElement>>;

const IconComponent = styled(
({ size, src, icon: IconComponent, ...rest }: IconProps) => {
({
size,
src,
icon: IconComponent,
clickable: _clickable,
...rest
}: IconProps) => {
const theme = useTheme();

if (src) {
Expand Down
25 changes: 17 additions & 8 deletions packages/kitchn/src/components/Image/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from "react";
import styled from "styled-components";

import { AreaProps, withDecorator } from "../../hoc/withDecorator";
import { withDecorator } from "../../hoc/withDecorator";
import { KitchnComponent } from "../../types";

type Props = {
width?: AreaProps["width"];
w?: Props["width"];
height?: AreaProps["height"];
h?: Props["height"];
htmlWidth?: string;
htmlHeight?: string;
src: string;
alt: string;
objectFit?:
Expand All @@ -27,9 +25,20 @@ export type ImageProps = KitchnComponent<
React.ImgHTMLAttributes<HTMLImageElement>
>;

const ImageComponent = styled(({ src, alt, ...props }: ImageProps) => {
return <img src={src} alt={alt} draggable={false} {...props} />;
})<ImageProps>`
const ImageComponent = styled(
({ src, alt, htmlWidth, htmlHeight, ...props }: ImageProps) => {
return (
<img
src={src}
alt={alt}
width={htmlWidth}
height={htmlHeight}
draggable={false}
{...props}
/>
);
},
)<ImageProps>`
${({ objectFit }) => objectFit && `object-fit: ${objectFit};`}
`;

Expand Down
2 changes: 2 additions & 0 deletions packages/kitchn/src/components/Note/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const NoteComponent = styled(
action,
label = true,
size,
// Prevents the 'fill' prop from being passed to the DOM element
fill: _fill,
children,
...props
}: NoteProps) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/kitchn/src/components/Progress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ const ProgressComponent = styled(
/>
<ProgressCheckpointContainer>
{states &&
Object.keys(states).map((key) => {
Object.keys(states).map((key, index) => {
const checkpoint = parseInt(key, 10);
const active = checkpoint <= value;
const first = checkpoint === 0;
const last = checkpoint === max;
return (
<>
<React.Fragment key={index}>
<ProgressCheckpoint
aria-hidden={"true"}
key={checkpoint}
Expand All @@ -103,7 +103,7 @@ const ProgressComponent = styled(
last={last}
onMouseEnter={() => setIsHover(checkpoint)}
onMouseLeave={() => setIsHover(null)}
title={states && title}
hasTitle={states && title}
max={max}
amount={Object.keys(states).length}
checkpointStyle={checkpointStyle}
Expand All @@ -120,7 +120,7 @@ const ProgressComponent = styled(
{states[checkpoint]}
</ProgressCheckpointTitle>
)}
</>
</React.Fragment>
);
})}
</ProgressCheckpointContainer>
Expand Down Expand Up @@ -214,7 +214,7 @@ export const ProgressCheckpoint = styled.div<{
color?: string;
first?: boolean;
last?: boolean;
title?: boolean;
hasTitle?: boolean;
amount: number;
checkpointStyle: ProgressProps["checkpointStyle"];
}>`
Expand Down
Loading
Loading