Refactor folder & consistency (#57400)

* refactor folder tsx

* Right-click to remove paper
This commit is contained in:
mozi_h
2021-03-04 17:53:55 +01:00
committed by GitHub
parent 1a9ed6c286
commit a588712ca2
2 changed files with 37 additions and 37 deletions

View File

@@ -27,7 +27,7 @@
/obj/item/folder/examine() /obj/item/folder/examine()
. = ..() . = ..()
if(contents) if(contents)
. += "<span class='notice'>Alt-click to remove [contents[1]].</span>" . += "<span class='notice'>Right-click to remove [contents[1]].</span>"
/obj/item/folder/proc/rename(mob/user) /obj/item/folder/proc/rename(mob/user)
if(!user.is_literate()) if(!user.is_literate())
@@ -49,10 +49,11 @@
to_chat(user, "<span class='notice'>You remove [Item] from [src].</span>") to_chat(user, "<span class='notice'>You remove [Item] from [src].</span>")
update_icon() update_icon()
/obj/item/folder/AltClick(mob/user) /obj/item/folder/attack_hand(mob/user, list/modifiers)
..() if(LAZYACCESS(modifiers, RIGHT_CLICK))
if(contents)
remove_item(contents[1], user) remove_item(contents[1], user)
return TRUE
. = ..()
/obj/item/folder/update_overlays() /obj/item/folder/update_overlays()
. = ..() . = ..()

View File

@@ -6,16 +6,20 @@ export const Folder = (props, context) => {
const { act, data } = useBackend(context); const { act, data } = useBackend(context);
const { theme, bg_color, folder_name, contents, contents_ref } = data; const { theme, bg_color, folder_name, contents, contents_ref } = data;
return ( return (
<Window title={folder_name || "Folder"} theme={theme} width={400} height={500}> <Window
title={folder_name || "Folder"}
theme={theme}
width={400}
height={500}
>
<Window.Content backgroundColor={bg_color || "#7f7f7f"} scrollable> <Window.Content backgroundColor={bg_color || "#7f7f7f"} scrollable>
{contents.length > 0 ? (
<>
{contents.map((item, index) => ( {contents.map((item, index) => (
<>
<Flex <Flex
key={contents_ref[index]}
color="black" color="black"
backgroundColor="white" backgroundColor="white"
style={{ padding: "2px 2px 0 2px" }} style={{ padding: "2px 2px 0 2px" }}
mb={0.5}
> >
<Flex.Item align="center" grow={1}> <Flex.Item align="center" grow={1}>
<Box align="center">{item}</Box> <Box align="center">{item}</Box>
@@ -24,22 +28,17 @@ export const Folder = (props, context) => {
{ {
<Button <Button
icon="search" icon="search"
onClick={() => onClick={() => act("examine", { ref: contents_ref[index] })}
act("examine", { ref: contents_ref[index] })}
/> />
} }
<Button <Button
icon="eject" icon="eject"
onClick={() => onClick={() => act("remove", { ref: contents_ref[index] })}
act("remove", { ref: contents_ref[index] })}
/> />
</Flex.Item> </Flex.Item>
</Flex> </Flex>
<Box style={{ height: "0.25em" }} />
</>
))} ))}
</> {contents.length === 0 && (
) : (
<Section> <Section>
<Box color="lightgrey" align="center"> <Box color="lightgrey" align="center">
This folder is empty! This folder is empty!