Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Refactor of files structure in components directories (saleor#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-potepa authored Mar 24, 2022
1 parent 8ced1f0 commit d8c65d6
Show file tree
Hide file tree
Showing 40 changed files with 77 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { Layout, Spinner } from "@/components";
import { NavigationPanel } from "@/components/NavigationPanel";
import { usePaths } from "@/lib/paths";

export const AccountLayout = ({ children }: PropsWithChildren<{}>) => {
export interface AccountLayoutProps extends PropsWithChildren<{}> {}

export const AccountLayout = ({ children }: AccountLayoutProps) => {
const router = useRouter();
const paths = usePaths();
const { authenticated, authenticating } = useAuthState();
Expand Down
2 changes: 2 additions & 0 deletions components/AccountLayout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { AccountLayoutProps } from "./AccountLayout";
export { AccountLayout } from "./AccountLayout";
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
useSetAddressDefaultMutation,
} from "@/saleor/api";

import { messages } from "./translations";
import { messages } from "../translations";

interface AddressBookCardProps {
export interface AddressBookCardProps {
address: AddressDetailsFragment;
onRefreshBook: () => void;
}
Expand Down
2 changes: 2 additions & 0 deletions components/AddressBookCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { AddressBookCardProps } from "./AddressBookCard";
export { AddressBookCard } from "./AddressBookCard";
18 changes: 0 additions & 18 deletions components/Button.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import clsx from "clsx";
import { HTMLAttributes, ReactNode } from "react";

const styles = `bg-blue-100 border border-blue-300 rounded-md shadow-sm py-2 px-4 text-sm font-medium hover:bg-blue-200`;

export interface ButtonProps
extends Pick<HTMLAttributes<{}>, "className" | "onClick" | "children"> {}

export const Button = ({ className, ...rest }: ButtonProps) => (
<button className={clsx(styles, className)} {...rest} />
);
2 changes: 2 additions & 0 deletions components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { ButtonProps } from "./Button";
export { Button } from "./Button";
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
useCheckoutAddPromoCodeMutation,
} from "@/saleor/api";

import { useRegions } from "./RegionsProvider";
import { messages } from "./translations";
import { useRegions } from "../RegionsProvider";
import { messages } from "../translations";

export interface PromoCodeFormData {
promoCode: string;
Expand Down
2 changes: 2 additions & 0 deletions components/CartSummary/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { CartSummaryProps } from "./CartSummary";
export { CartSummary } from "./CartSummary";
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
useRemoveProductFromCheckoutMutation,
} from "@/saleor/api";

import { usePaths } from "../lib/paths";
import { useRegions } from "./RegionsProvider";
import { messages } from "./translations";
import { usePaths } from "../../lib/paths";
import { useRegions } from "../RegionsProvider";
import { messages } from "../translations";

interface CheckoutLineItemProps {
line: CheckoutLineDetailsFragment;
Expand Down Expand Up @@ -160,4 +160,5 @@ export const CheckoutLineItem = ({ line }: CheckoutLineItemProps) => {
</>
);
};

export default CheckoutLineItem;
1 change: 1 addition & 0 deletions components/CheckoutLineItem/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CheckoutLineItem } from "./CheckoutLineItem";
File renamed without changes.
1 change: 1 addition & 0 deletions components/DemoBanner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./DemoBanner";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from "clsx";

interface HamburgerButtonProps {
export interface HamburgerButtonProps {
onClick: (ev: any) => void;
active?: boolean;
}
Expand Down
2 changes: 2 additions & 0 deletions components/HamburgerButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { HamburgerButtonProps } from "./HamburgerButton";
export { HamburgerButton } from "./HamburgerButton";
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { usePaths } from "@/lib/paths";
import { translate } from "@/lib/translations";
import { HomepageBlockFragment, ProductFilterInput } from "@/saleor/api";

import { ProductCollection, RichText } from ".";
import { messages } from "./translations";
import { ProductCollection } from "../ProductCollection";
import { RichText } from "../RichText";
import { messages } from "../translations";

export interface HomepageBlockProps {
menuItem: HomepageBlockFragment;
Expand Down
2 changes: 2 additions & 0 deletions components/HomepageBlock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { HomepageBlockProps } from "./HomepageBlock";
export { HomepageBlock } from "./HomepageBlock";
2 changes: 1 addition & 1 deletion components/Layout.tsx → components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Navbar } from ".";
import { Navbar } from "../Navbar";

export interface LayoutProps {
children?: React.ReactNode;
Expand Down
2 changes: 2 additions & 0 deletions components/Layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { LayoutProps } from "./Layout";
export { Layout } from "./Layout";
6 changes: 3 additions & 3 deletions components/MainMenu.tsx → components/MainMenu/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { translate } from "@/lib/translations";
import { notNullable } from "@/lib/util";
import { MenuItemFragment, useMainMenuQuery } from "@/saleor/api";

import { usePaths } from "../lib/paths";
import { HamburgerButton } from "./HamburgerButton";
import { useRegions } from "./RegionsProvider";
import { usePaths } from "../../lib/paths";
import { HamburgerButton } from "../HamburgerButton";
import { useRegions } from "../RegionsProvider";

export const MainMenu = () => {
const paths = usePaths();
Expand Down
1 change: 1 addition & 0 deletions components/MainMenu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MainMenu } from "./MainMenu";
6 changes: 3 additions & 3 deletions components/Navbar.tsx → components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { usePaths } from "@/lib/paths";
import { useCheckout } from "@/lib/providers/CheckoutProvider";
import { CheckoutLine, CheckoutLineDetailsFragment } from "@/saleor/api";

import { RegionDialog } from "./RegionDialog";
import { useRegions } from "./RegionsProvider";
import { messages } from "./translations";
import { RegionDialog } from "../RegionDialog";
import { useRegions } from "../RegionsProvider";
import { messages } from "../translations";

export const Navbar = () => {
const paths = usePaths();
Expand Down
1 change: 1 addition & 0 deletions components/Navbar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Navbar } from "./Navbar";
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Link from "next/link";
import React from "react";
import { useIntl } from "react-intl";

import { usePaths } from "../lib/paths";
import { messages } from "./translations";
import { usePaths } from "../../lib/paths";
import { messages } from "../translations";

export const NavigationPanel = () => {
const paths = usePaths();
Expand Down
1 change: 1 addition & 0 deletions components/NavigationPanel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { NavigationPanel } from "./NavigationPanel";
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useRouter } from "next/router";
import { usePaths } from "@/lib/paths";
import { OrderDetailsFragment } from "@/saleor/api";

import { useRegions } from "./RegionsProvider";
import { useRegions } from "../RegionsProvider";

interface OrdersTableProps {
export interface OrdersTableProps {
orders: OrderDetailsFragment[];
}

Expand Down
2 changes: 2 additions & 0 deletions components/OrdersTable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { OrdersTableProps } from "./OrdersTable";
export { OrdersTable } from "./OrdersTable";
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CollectionDetailsFragment,
} from "@/saleor/api";

import { RichText } from "./RichText";
import { RichText } from "../RichText";

export interface PageHeroProps {
entity: CollectionDetailsFragment | CategoryDetailsFragment;
Expand Down
2 changes: 2 additions & 0 deletions components/PageHero/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { PageHeroProps } from "./PageHero";
export { PageHero } from "./PageHero";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useIntl } from "react-intl";

import { PageInfo } from "@/saleor/api";

import { messages } from "./translations";
import { messages } from "../translations";

export interface PaginationProps {
pageInfo?: PageInfo;
Expand Down
2 changes: 2 additions & 0 deletions components/Pagination/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { PaginationProps } from "./Pagination";
export { Pagination } from "./Pagination";
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { usePaths } from "@/lib/paths";
import { translate } from "@/lib/translations";
import { ProductCardFragment } from "@/saleor/api";

import { useRegions } from "./RegionsProvider";
import { useRegions } from "../RegionsProvider";

const styles = {
grid: `grid grid-cols-4 gap-4`,
Expand Down
2 changes: 2 additions & 0 deletions components/ProductCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { ProductCardProps } from "./ProductCard";
export { ProductCard } from "./ProductCard";
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { useIntl } from "react-intl";

import { ProductFilterInput, useProductCollectionQuery } from "@/saleor/api";

import { Pagination } from "./Pagination";
import { ProductCard } from "./ProductCard";
import { useRegions } from "./RegionsProvider";
import { Spinner } from "./Spinner";
import { messages } from "./translations";
import { Pagination } from "../Pagination";
import { ProductCard } from "../ProductCard";
import { useRegions } from "../RegionsProvider";
import { Spinner } from "../Spinner";
import { messages } from "../translations";

export interface ProductCollectionProps {
filter?: ProductFilterInput;
Expand Down
2 changes: 2 additions & 0 deletions components/ProductCollection/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { ProductCollectionProps } from "./ProductCollection";
export { ProductCollection } from "./ProductCollection";
2 changes: 1 addition & 1 deletion components/RegionDialog/RegionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Button } from "../Button";
import { useRegions } from "../RegionsProvider";
import { messages } from "../translations";

interface RegionDialogProps {
export interface RegionDialogProps {
onClose: () => void;
isOpen: boolean;
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions components/RichText/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RichText } from "./RichText";
File renamed without changes.
1 change: 1 addition & 0 deletions components/Spinner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Spinner } from "./Spinner";

0 comments on commit d8c65d6

Please sign in to comment.