Skip to content

Commit

Permalink
link to assets and reference icon
Browse files Browse the repository at this point in the history
  • Loading branch information
caichi-t committed Oct 18, 2024
1 parent cf26d01 commit c4fa544
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import { useState, useRef, useCallback, useMemo } from "react";
import { useRef, useCallback, useMemo } from "react";

import Button from "@reearth-cms/components/atoms/Button";
import Icon from "@reearth-cms/components/atoms/Icon";
Expand Down Expand Up @@ -74,7 +74,6 @@ const LinkAssetModal: React.FC<Props> = ({
onUploadAndLink,
}) => {
const t = useT();
const [hoveredAssetId, setHoveredAssetId] = useState<string>();
const resetFlag = useRef(false);

const options: OptionConfig = useMemo(
Expand Down Expand Up @@ -127,14 +126,10 @@ const LinkAssetModal: React.FC<Props> = ({
width: 48,
minWidth: 48,
render: (_, asset) => {
const isLink =
(asset.id === linkedAsset?.id && hoveredAssetId !== asset.id) ||
(asset.id !== linkedAsset?.id && hoveredAssetId === asset.id);
const isLink = asset.id !== linkedAsset?.id;
return (
<Button
type="link"
onMouseEnter={() => setHoveredAssetId(asset.id)}
onMouseLeave={() => setHoveredAssetId(undefined)}
icon={<Icon icon={isLink ? "linkSolid" : "unlinkSolid"} size={16} />}
onClick={() => onLinkClick(isLink, asset)}
/>
Expand Down Expand Up @@ -184,7 +179,7 @@ const LinkAssetModal: React.FC<Props> = ({
minWidth: 100,
},
],
[hoveredAssetId, linkedAsset?.id, onLinkClick, t],
[linkedAsset?.id, onLinkClick, t],
);

const handleChange = useCallback(
Expand Down Expand Up @@ -242,9 +237,7 @@ const LinkAssetModal: React.FC<Props> = ({
width="70vw"
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px",
height: "70vh",
},
}}>
<ResizableProTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ const StyledProTable = styled(ProTable)<{
overflow: auto !important;
height: calc(100% - 47px);
}
.ant-pro-table-list-toolbar-container {
flex-direction: row;
}
.ant-pro-table-list-toolbar-left {
flex: 1;
max-width: calc(100% - 150px);
margin: 0;
.ant-pro-table-list-toolbar-search {
width: 100%;
}
Expand Down
19 changes: 6 additions & 13 deletions web/src/components/molecules/Content/LinkItemModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import { useState, useCallback, useMemo } from "react";
import { useCallback, useMemo } from "react";

import Button from "@reearth-cms/components/atoms/Button";
import Icon from "@reearth-cms/components/atoms/Icon";
Expand Down Expand Up @@ -53,7 +53,6 @@ const LinkItemModal: React.FC<Props> = ({
onChange,
onCheckItemReference,
}) => {
const [hoveredAssetId, setHoveredItemId] = useState<string>();
const t = useT();
const { confirm } = Modal;
const { value, pagination, handleInput } = useHooks(
Expand Down Expand Up @@ -110,16 +109,12 @@ const LinkItemModal: React.FC<Props> = ({
width: 48,
minWidth: 48,
render: (_, item) => {
const link =
(item.id === linkedItem && hoveredAssetId !== item.id) ||
(item.id !== linkedItem && hoveredAssetId === item.id);
const isLink = item.id !== linkedItem;
return (
<Button
type="link"
onMouseEnter={() => setHoveredItemId(item.id)}
onMouseLeave={() => setHoveredItemId(undefined)}
icon={<Icon icon={link ? "linkSolid" : "unlinkSolid"} size={16} />}
onClick={() => handleClick(link, item)}
icon={<Icon icon={isLink ? "linkSolid" : "unlinkSolid"} size={16} />}
onClick={() => handleClick(isLink, item)}
/>
);
},
Expand Down Expand Up @@ -158,7 +153,7 @@ const LinkItemModal: React.FC<Props> = ({
render: (_text, record) => dateTimeFormat(record.createdAt),
},
],
[t, linkedItem, hoveredAssetId, handleClick],
[t, linkedItem, handleClick],
);

const toolbar: ListToolBarProps = useMemo(
Expand Down Expand Up @@ -188,9 +183,7 @@ const LinkItemModal: React.FC<Props> = ({
onCancel={onLinkItemModalCancel}
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px",
height: "70vh",
},
}}>
<ResizableProTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ const LinkItemRequestModal: React.FC<Props> = ({
width="70vw"
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px 12px 0",
height: "70vh",
},
}}
afterClose={() => {
Expand Down

0 comments on commit c4fa544

Please sign in to comment.