feat(admin-ui): adds category ui for tree/list, edit, create, delete (#3399)

* chore: adds category ui for tree/list, edit, create, delete

* fix: address feedback

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
Riqwan Thamir
2023-03-07 13:29:22 +01:00
committed by GitHub
co-authored by Oliver Windall Juhl fPolic
parent 06f567f446
commit b5662d0c6a
16 changed files with 873 additions and 22 deletions
@@ -0,0 +1,29 @@
import React from "react"
import IconProps from "../types/icon-type"
const FolderOpenIcon: React.FC<IconProps> = ({
size = "20px",
color = "currentColor",
...attributes
}) => {
return (
<svg
width={size}
height={size}
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...attributes}
>
<path
d="M3.49557 8.24663C3.58387 8.23322 3.67454 8.22613 3.76678 8.22613H16.2328C16.325 8.22613 16.4157 8.23322 16.504 8.24663M3.49557 8.24663C3.03418 8.31808 2.61956 8.56856 2.34165 8.94373C2.06373 9.31891 1.94494 9.78852 2.01103 10.2507L2.68668 14.9811C2.74703 15.4037 2.95781 15.7905 3.28032 16.0703C3.60284 16.3501 4.01546 16.5041 4.44243 16.5042H15.5579C15.9849 16.5041 16.3975 16.3501 16.72 16.0703C17.0426 15.7905 17.2533 15.4037 17.3137 14.9811L17.9893 10.2507C18.0554 9.78852 17.9366 9.31891 17.6587 8.94373C17.3808 8.56856 16.9654 8.31808 16.504 8.24663M3.49557 8.24663L3.49636 5.26967C3.49636 4.79934 3.68314 4.34827 4.01564 4.01562C4.34813 3.68298 4.79912 3.496 5.26945 3.49579H8.32761C8.64115 3.49606 8.94174 3.62084 9.16331 3.84268L10.8363 5.51407C11.0578 5.73591 11.3584 5.86068 11.672 5.86096H14.7301C15.2006 5.86096 15.6518 6.04785 15.9844 6.38051C16.3171 6.71318 16.504 7.16437 16.504 7.63484V8.24663"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
export default FolderOpenIcon
@@ -0,0 +1,64 @@
import React from "react"
import IconProps from "../types/icon-type"
const ReorderIcon: React.FC<IconProps> = ({
size = "24px",
color = "currentColor",
...attributes
}) => {
return (
<svg
width={size}
height={size}
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...attributes}
>
<path
d="M7.5 10.75C7.91421 10.75 8.25 10.4142 8.25 10C8.25 9.58579 7.91421 9.25 7.5 9.25C7.08579 9.25 6.75 9.58579 6.75 10C6.75 10.4142 7.08579 10.75 7.5 10.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M7.5 5.75C7.91421 5.75 8.25 5.41421 8.25 5C8.25 4.58579 7.91421 4.25 7.5 4.25C7.08579 4.25 6.75 4.58579 6.75 5C6.75 5.41421 7.08579 5.75 7.5 5.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M7.5 15.75C7.91421 15.75 8.25 15.4142 8.25 15C8.25 14.5858 7.91421 14.25 7.5 14.25C7.08579 14.25 6.75 14.5858 6.75 15C6.75 15.4142 7.08579 15.75 7.5 15.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M12.5 10.75C12.9142 10.75 13.25 10.4142 13.25 10C13.25 9.58579 12.9142 9.25 12.5 9.25C12.0858 9.25 11.75 9.58579 11.75 10C11.75 10.4142 12.0858 10.75 12.5 10.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M12.5 5.75C12.9142 5.75 13.25 5.41421 13.25 5C13.25 4.58579 12.9142 4.25 12.5 4.25C12.0858 4.25 11.75 4.58579 11.75 5C11.75 5.41421 12.0858 5.75 12.5 5.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M12.5 15.75C12.9142 15.75 13.25 15.4142 13.25 15C13.25 14.5858 12.9142 14.25 12.5 14.25C12.0858 14.25 11.75 14.5858 11.75 15C11.75 15.4142 12.0858 15.75 12.5 15.75Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
export default ReorderIcon
@@ -0,0 +1,28 @@
import React from "react"
import IconProps from "../types/icon-type"
const TriangleDownIcon: React.FC<IconProps> = ({
size = "20",
color = "currentColor",
...attributes
}) => {
return (
<svg
width={size}
height={size}
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...attributes}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M13.0869 6.25006C13.7804 6.25006 14.22 7.00005 13.8859 7.61318L10.7988 13.2737C10.4525 13.9089 9.54748 13.9089 9.20123 13.2737L6.1141 7.61368C5.78 7.00054 6.21963 6.25055 6.91312 6.25055L13.0869 6.25006Z"
fill={color}
/>
</svg>
)
}
export default TriangleDownIcon
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from "react"
import { PropsWithChildren } from "react"
import { AnimatePresence, motion } from "framer-motion"
const MODAL_WIDTH = 560
@@ -43,9 +43,9 @@ function SideModal(props: SideModalProps) {
background: "white",
right: 0,
top: 0,
zIndex: 9999,
zIndex: 200,
}}
className="rounded border overflow-hidden"
className="overflow-hidden rounded border"
animate={{ right: 0 }}
exit={{ right: -MODAL_WIDTH }}
>
@@ -1,5 +1,6 @@
import clsx from "clsx"
import React, {
CSSProperties,
useContext,
useEffect,
useImperativeHandle,
@@ -31,6 +32,7 @@ type MultiSelectProps = InputHeaderProps & {
placeholder?: string
isMultiSelect?: boolean
labelledBy?: string
menuPortalStyles?: CSSProperties
options: { label: string; value: string | null; disabled?: boolean }[]
value:
| { label: string; value: string }[]
@@ -69,6 +71,7 @@ const SSelect = React.forwardRef(
placeholder = "Search...",
options,
onCreateOption,
menuPortalStyles = {},
}: MultiSelectProps,
ref
) => {
@@ -135,10 +138,10 @@ const SSelect = React.forwardRef(
<div
key={name}
className={clsx(className, {
"bg-white rounded-t-rounded": isFocussed,
"rounded-t-rounded bg-white": isFocussed,
})}
>
<div className="w-full flex text-grey-50 pr-0.5 justify-between pointer-events-none cursor-pointer mb-2">
<div className="text-grey-50 pointer-events-none mb-2 flex w-full cursor-pointer justify-between pr-0.5">
<InputHeader {...{ label, required, tooltip, tooltipContent }} />
</div>
@@ -176,7 +179,9 @@ const SSelect = React.forwardRef(
}}
closeMenuOnSelect={!isMultiSelect}
blurInputOnSelect={!isMultiSelect}
styles={{ menuPortal: (base) => ({ ...base, zIndex: 60 }) }}
styles={{
menuPortal: (base) => ({ ...base, ...menuPortalStyles }),
}}
hideSelectedOptions={false}
menuPortalTarget={portalRef?.current?.lastChild || document.body}
menuPlacement="auto"
@@ -188,7 +193,7 @@ const SSelect = React.forwardRef(
components={SelectComponents}
/>
}
{isFocussed && enableSearch && <div className="w-full h-5" />}
{isFocussed && enableSearch && <div className="h-5 w-full" />}
</div>
</div>
)
@@ -1,5 +1,6 @@
import { useAdminStore } from "medusa-react"
import React, { useState } from "react"
import { useFeatureFlag } from "../../../providers/feature-flag-provider"
import BuildingsIcon from "../../fundamentals/icons/buildings-icon"
import CartIcon from "../../fundamentals/icons/cart-icon"