diff --git a/www/apps/ui/src/components/icon-search.tsx b/www/apps/ui/src/components/icon-search.tsx index 8919f4db79..20549099df 100644 --- a/www/apps/ui/src/components/icon-search.tsx +++ b/www/apps/ui/src/components/icon-search.tsx @@ -1,8 +1,9 @@ "use client" import * as Icons from "@medusajs/icons" -import { Container, Input, Text, Tooltip } from "@medusajs/ui" +import { Container, Input, Text } from "@medusajs/ui" import clsx from "clsx" +import { CopyButton } from "docs-ui" import * as React from "react" const iconNames = Object.keys(Icons).filter((name) => name !== "default") @@ -56,7 +57,7 @@ const SearchResults = ({ query = "" }: { query?: string }) => { key={name} className="flex h-full w-full items-center justify-center" > - +
{ {React.createElement(Icons[name as keyof typeof Icons])}
-
+ ) })} diff --git a/www/apps/ui/src/content/docs/components/table.mdx b/www/apps/ui/src/content/docs/components/table.mdx index bad1118049..77e3e4ac3b 100644 --- a/www/apps/ui/src/content/docs/components/table.mdx +++ b/www/apps/ui/src/content/docs/components/table.mdx @@ -39,4 +39,12 @@ import { Table } from "@medusajs/ui" \ No newline at end of file +]} /> + +## Examples + +--- + +### Table with Pagination + + \ No newline at end of file diff --git a/www/apps/ui/src/content/docs/icons/overview.mdx b/www/apps/ui/src/content/docs/icons/overview.mdx index 1871cee5e4..bc8abb36c6 100644 --- a/www/apps/ui/src/content/docs/icons/overview.mdx +++ b/www/apps/ui/src/content/docs/icons/overview.mdx @@ -21,7 +21,34 @@ The icons are available as an [npm package](https://www.npmjs.com/package/@medus --- ```tsx -import { Sun, Moon } from "@medusajs/icons" +import { Sun } from "@medusajs/icons" + +export default function Component() { + return ( + + ) +} ``` - \ No newline at end of file + + +## Icon Props +--- + +Icons accept all props that an `svg` element accepts. + +### Icon Color + +By default, outline icons' stroke color and solid icon's fill color are set to `currentColor`. + +You can set a different color by passing the `color` prop. + + + +You can also use a CSS class by passing the `className` prop. + + + +### Icon Size + +All icon's width and height are `20px` and it's not possible to change them. diff --git a/www/apps/ui/src/examples/icon-color-classes.tsx b/www/apps/ui/src/examples/icon-color-classes.tsx new file mode 100644 index 0000000000..3e88f649b7 --- /dev/null +++ b/www/apps/ui/src/examples/icon-color-classes.tsx @@ -0,0 +1,5 @@ +import { Sun } from "@medusajs/icons" + +export default function Component() { + return +} diff --git a/www/apps/ui/src/examples/icon-color.tsx b/www/apps/ui/src/examples/icon-color.tsx new file mode 100644 index 0000000000..a5247fc59f --- /dev/null +++ b/www/apps/ui/src/examples/icon-color.tsx @@ -0,0 +1,5 @@ +import { Sun } from "@medusajs/icons" + +export default function Component() { + return +} diff --git a/www/apps/ui/src/examples/table-pagination.tsx b/www/apps/ui/src/examples/table-pagination.tsx new file mode 100644 index 0000000000..7264be36b7 --- /dev/null +++ b/www/apps/ui/src/examples/table-pagination.tsx @@ -0,0 +1,135 @@ +import { Table } from "@medusajs/ui" +import { useMemo, useState } from "react" + +type Order = { + id: string + displayId: number + customer: string + email: string + amount: number + currency: string +} + +export default function TableDemo() { + const fakeData: Order[] = useMemo( + () => [ + { + id: "order_6782", + displayId: 86078, + customer: "Jill Miller", + email: "32690@gmail.com", + amount: 493, + currency: "EUR", + }, + { + id: "order_46487", + displayId: 42845, + customer: "Sarah Garcia", + email: "86379@gmail.com", + amount: 113, + currency: "JPY", + }, + { + id: "order_8169", + displayId: 39129, + customer: "Josef Smith", + email: "89383@gmail.com", + amount: 43, + currency: "USD", + }, + { + id: "order_67883", + displayId: 5548, + customer: "Elvis Jones", + email: "52860@gmail.com", + amount: 840, + currency: "GBP", + }, + { + id: "order_61121", + displayId: 87668, + customer: "Charles Rodriguez", + email: "45675@gmail.com", + amount: 304, + currency: "GBP", + }, + ], + [] + ) + const [currentPage, setCurrentPage] = useState(0) + const pageSize = 3 + const pageCount = Math.ceil(fakeData.length / pageSize) + const canNextPage = useMemo( + () => currentPage < pageCount - 1, + [currentPage, pageCount] + ) + const canPreviousPage = useMemo(() => currentPage - 1 >= 0, [currentPage]) + + const nextPage = () => { + if (canNextPage) { + setCurrentPage(currentPage + 1) + } + } + + const previousPage = () => { + if (canPreviousPage) { + setCurrentPage(currentPage - 1) + } + } + + const currentOrders = useMemo(() => { + const offset = currentPage * pageSize + const limit = Math.min(offset + pageSize, fakeData.length) + + return fakeData.slice(offset, limit) + }, [currentPage, pageSize, fakeData]) + + return ( +
+ + + + # + Customer + Email + Amount + + + + + {currentOrders.map((order) => { + return ( + + {order.displayId} + {order.customer} + {order.email} + + {new Intl.NumberFormat("en-US", { + style: "currency", + currency: order.currency, + }).format(order.amount)} + + + {order.currency} + + + ) + })} + +
+ +
+ ) +} diff --git a/www/apps/ui/src/registries/example-registry.tsx b/www/apps/ui/src/registries/example-registry.tsx index cbbaaf28f8..d2c55ef2d5 100644 --- a/www/apps/ui/src/registries/example-registry.tsx +++ b/www/apps/ui/src/registries/example-registry.tsx @@ -330,6 +330,11 @@ export const ExampleRegistry: Record = { ), file: "src/examples/switch-checked-disabled.tsx", }, + "table-pagination": { + name: "table-pagination", + component: React.lazy(async () => import("@/examples/table-pagination")), + file: "src/examples/table-pagination.tsx", + }, "table-demo": { name: "table-demo", component: React.lazy(async () => import("@/examples/table-demo")), @@ -459,6 +464,16 @@ export const ExampleRegistry: Record = { component: React.lazy(async () => import("@/examples/icon-button-xlarge")), file: "src/examples/icon-button-xlarge.tsx", }, + "icon-color-classes": { + name: "icon-color-classes", + component: React.lazy(async () => import("@/examples/icon-color-classes")), + file: "src/examples/icon-color-classes.tsx", + }, + "icon-color": { + name: "icon-color", + component: React.lazy(async () => import("@/examples/icon-color")), + file: "src/examples/icon-color.tsx", + }, "currency-input-demo": { name: "currency-input-demo", component: React.lazy(async () => import("@/examples/currency-input-demo")), diff --git a/www/packages/docs-ui/src/components/CopyButton/index.tsx b/www/packages/docs-ui/src/components/CopyButton/index.tsx index d31cbe50bc..035577ca02 100644 --- a/www/packages/docs-ui/src/components/CopyButton/index.tsx +++ b/www/packages/docs-ui/src/components/CopyButton/index.tsx @@ -9,12 +9,14 @@ export type CopyButtonProps = { text: string buttonClassName?: string tooltipClassName?: string + tooltipText?: string } & React.HTMLAttributes export const CopyButton = ({ text, buttonClassName = "", tooltipClassName = "", + tooltipText = "Copy to Clipboard", children, className, }: CopyButtonProps) => { @@ -22,7 +24,7 @@ export const CopyButton = ({ return (