make whole card clickable (#7984)

This commit is contained in:
Kasper Fabricius Kristensen authored and GitHub committed 2024-07-08 10:03:04 +02:00
1 parent 9750047af1
commit 4d750c13d9
3 files changed
+72 -64

No files matched your search

@@ -14,7 +14,7 @@ export const IconAvatar = ({ children, className }: IconAvatarProps) => {
return ( return (
<div <div
className={clx( className={clx(
"shadow-borders-base flex size-7 items-center justify-center rounded-md", "shadow-borders-base bg-ui-bg-base flex size-7 items-center justify-center rounded-md",
"[&>div]:bg-ui-bg-field [&>div]:text-ui-fg-subtle [&>div]:flex [&>div]:size-6 [&>div]:items-center [&>div]:justify-center [&>div]:rounded-[4px]", "[&>div]:bg-ui-bg-field [&>div]:text-ui-fg-subtle [&>div]:flex [&>div]:size-6 [&>div]:items-center [&>div]:justify-center [&>div]:rounded-[4px]",
className className
)} )}
@@ -900,11 +900,15 @@
} }
}, },
"sidebar": { "sidebar": {
"shippingConfiguration": "Shipping configuration", "header": "Shipping Configuration",
"shippingProfiles": "Shipping profiles", "shippingProfiles": {
"shippingProfilesDesc": "Shipping rules for different types of products", "label": "Shipping Profiles",
"shippingOptionTypes": "Shipping Option Types", "description": "Group products by shipping requirements"
"shippingOptionTypesDesc": "Group options based on characteristic" },
"shippingOptionTypes": {
"label": "Shipping Option Types",
"description": "Group options based on characteristic"
}
}, },
"salesChannels": { "salesChannels": {
"header": "Sales Channels", "header": "Sales Channels",
@@ -1,15 +1,17 @@
import { Outlet, useLoaderData, useNavigate } from "react-router-dom"
import { Container, Heading, IconButton } from "@medusajs/ui"
import { ArrowUpRightOnBox, Buildings, ShoppingBag } from "@medusajs/icons" import { ArrowUpRightOnBox, Buildings, ShoppingBag } from "@medusajs/icons"
import { Container, Heading, Text } from "@medusajs/ui"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
import { Link, Outlet, useLoaderData } from "react-router-dom"
import { useStockLocations } from "../../../hooks/api/stock-locations" import { useStockLocations } from "../../../hooks/api/stock-locations"
import LocationListItem from "./components/location-list-item/location-list-item" import LocationListItem from "./components/location-list-item/location-list-item"
import { LOCATION_LIST_FIELDS } from "./constants" import { LOCATION_LIST_FIELDS } from "./constants"
import { shippingListLoader } from "./loader" import { shippingListLoader } from "./loader"
import { ReactNode } from "react"
import after from "virtual:medusa/widgets/location/list/after" import after from "virtual:medusa/widgets/location/list/after"
import before from "virtual:medusa/widgets/location/list/before" import before from "virtual:medusa/widgets/location/list/before"
import { IconAvatar } from "../../../components/common/icon-avatar"
import { LocationListHeader } from "./components/location-list-header" import { LocationListHeader } from "./components/location-list-header"
export function LocationList() { export function LocationList() {
@@ -67,71 +69,73 @@ export function LocationList() {
) )
} }
interface SidebarLinkProps {
to: string
labelKey: string
descriptionKey: string
icon: ReactNode
}
const SidebarLink = ({
to,
labelKey,
descriptionKey,
icon,
}: SidebarLinkProps) => {
return (
<Link to={to} className="group outline-none">
<div className="flex flex-col gap-2 px-2 pb-2">
<div className="shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2">
<div className="flex items-center gap-4">
<IconAvatar>{icon}</IconAvatar>
<div className="flex flex-1 flex-col">
<Text size="small" leading="compact" weight="plus">
{labelKey}
</Text>
<Text
size="small"
leading="compact"
className="text-ui-fg-subtle"
>
{descriptionKey}
</Text>
</div>
<div className="flex size-7 items-center justify-center">
<ArrowUpRightOnBox className="text-ui-fg-muted" />
</div>
</div>
</div>
</div>
</Link>
)
}
const LinksSection = () => { const LinksSection = () => {
const { t } = useTranslation() const { t } = useTranslation()
const navigate = useNavigate()
return ( return (
<Container className="p-0"> <Container className="p-0">
<div className="flex items-center justify-between px-6 py-4"> <div className="flex items-center justify-between px-6 py-4">
<Heading level="h2"> <Heading level="h2">{t("stockLocations.sidebar.header")}</Heading>
{t("stockLocations.sidebar.shippingConfiguration")}
</Heading>
</div> </div>
<div className="txt-small flex flex-col gap-2 px-2 pb-2"> <SidebarLink
<div className="shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2"> to="/settings/locations/shipping-profiles"
<div className="flex items-center gap-3"> labelKey={t("stockLocations.sidebar.shippingProfiles.label")}
<div className="shadow-elevation-card-rest rounded-md"> descriptionKey={t(
<ShoppingBag /> "stockLocations.sidebar.shippingProfiles.description"
</div> )}
<div className="flex flex-1 flex-col"> icon={<ShoppingBag />}
<span className="text-ui-fg-base font-medium"> />
{t("stockLocations.sidebar.shippingProfiles")}
</span>
<span className="text-ui-fg-subtle">
{t("stockLocations.sidebar.shippingProfilesDesc")}
</span>
</div>
<IconButton
size="2xsmall"
variant="transparent"
type="button"
onClick={() => navigate(`/settings/locations/shipping-profiles`)}
>
<ArrowUpRightOnBox className="text-ui-fg-muted" />
</IconButton>
</div>
</div>
</div>
<div className="txt-small flex flex-col gap-2 px-2 pb-2"> <SidebarLink
<div className="shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2"> to="/settings/locations/shipping-option-types"
<div className="flex items-center gap-3"> labelKey={t("stockLocations.sidebar.shippingOptionTypes.label")}
<div className="shadow-elevation-card-rest rounded-md"> descriptionKey={t(
<Buildings /> "stockLocations.sidebar.shippingOptionTypes.description"
</div> )}
<div className="flex flex-1 flex-col"> icon={<Buildings />}
<span className="text-ui-fg-base font-medium"> />
{t("stockLocations.sidebar.shippingOptionTypes")}
</span>
<span className="text-ui-fg-subtle">
{t("stockLocations.sidebar.shippingOptionTypesDesc")}
</span>
</div>
<IconButton
size="2xsmall"
variant="transparent"
type="button"
onClick={() =>
navigate(`/settings/locations/shipping-option-types`)
}
>
<ArrowUpRightOnBox className="text-ui-fg-muted" />
</IconButton>
</div>
</div>
</div>
</Container> </Container>
) )
} }