Skip to content

Commit

Permalink
Merge pull request #131 from RENCI/126-move-layer-delete-trash-can-to…
Browse files Browse the repository at this point in the history
…-the-layer-panel

126 move layer delete trash can to the layer panel
  • Loading branch information
PhillipsOwen authored Jul 25, 2024
2 parents 950e3e0 + d048c0d commit b148432
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
33 changes: 33 additions & 0 deletions src/components/trays/layers/delete-layer-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import PropTypes from 'prop-types';

import {
DeleteForever as RemoveIcon,
} from '@mui/icons-material';
import { useLayers } from '@context';
import { ActionButton } from '@components/buttons';

export const DeleteLayerButton = ({ layerId }) => {
const { removeLayer } = useLayers();

return (
<ActionButton
color="danger"
variant="outlined"
onClick={ () => removeLayer(layerId) }
sx={{
'filter': 'opacity(0.2)',
transition: 'filter 250ms',
'&:hover': {
'filter': 'opacity(1.0)',
},
}}
>
<RemoveIcon />
</ActionButton>
);
};

DeleteLayerButton.propTypes = {
layerId: PropTypes.string.isRequired
};
18 changes: 1 addition & 17 deletions src/components/trays/layers/layer-card-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import {
Box,
Divider,
FormControl,
FormLabel,
ListItemDecorator,
Expand All @@ -14,16 +13,14 @@ import {
Stack,
} from '@mui/joy';
import {
DeleteForever as RemoveIcon,
FormatPaint as AppearanceIcon,
DataObject as MetadataIcon,
} from '@mui/icons-material';
import { useLayers, useSettings } from '@context';
import { ActionButton } from '@components/buttons';

export const LayerActions = ({ layer }) => {
const { darkMode } = useSettings();
const { removeLayer, setLayerOpacity } = useLayers();
const { setLayerOpacity } = useLayers();

return (
<Tabs defaultValue={0}>
Expand All @@ -45,19 +42,6 @@ export const LayerActions = ({ layer }) => {
Metadata
</Tab>
</TabList>

<Divider orientation="vertical" />

<ActionButton
color="warning"
onClick={ () => removeLayer(layer.id) }
sx={{
borderRadius: 0,
borderBottom: '1px solid var(--joy-palette-divider)',
}}
>
<RemoveIcon />
</ActionButton>
</Stack>

<TabPanel value={ 0 } sx={{
Expand Down
4 changes: 3 additions & 1 deletion src/components/trays/layers/layer-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useLayers } from '@context';
import { useToggleState } from '@hooks';
import { LayerActions } from './layer-card-actions';
import { ActionButton } from '@components/buttons';
import { DeleteLayerButton } from './delete-layer-button';

export const LayerCard = ({ index, layer }) => {
const {
Expand Down Expand Up @@ -66,7 +67,7 @@ export const LayerCard = ({ index, layer }) => {
<Avatar variant="outlined">
<LayerIcon size="lg" color="primary" />
</Avatar>
<Typography level="title-md">
<Typography level="title-md" sx={{ flex: 1 }}>
{layer.properties.product_name}
</Typography>
<Switch
Expand All @@ -75,6 +76,7 @@ export const LayerCard = ({ index, layer }) => {
onChange={ () => toggleLayerVisibility(layer.id) }
className="action-button"
/>
<DeleteLayerButton layerId={ layer.id }/>
</Stack>

<Stack
Expand Down

0 comments on commit b148432

Please sign in to comment.