Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): link to asset and refer to item icons #1272

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
caichi-t marked this conversation as resolved.
Show resolved Hide resolved
},
}}>
<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
Loading