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

Improved UI for editing layer names #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion src/renderer/components/layerlist/LayerLineEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { makeStyles } from '@material-ui/core/styles'
import { List, ListItem, ListItemText, ListItemSecondaryAction } from '@material-ui/core'
import Collapse from '@material-ui/core/Collapse'
import IconButton from '@material-ui/core/IconButton'
import EditIcon from '@material-ui/icons/Edit'
import LockIcon from '@material-ui/icons/Lock'
import LockOpenIcon from '@material-ui/icons/LockOpen'
import VisibilityIcon from '@material-ui/icons/Visibility'
Expand Down Expand Up @@ -65,6 +66,11 @@ export const LayerLineEntry = props => {
<ListItemText>{ props.active ? <b>{props.name}</b> : props.name }</ListItemText>

<ListItemSecondaryAction>
<IconButton
size='small'
onClick={props.editLayerName}>
<EditIcon/>
</IconButton>
<IconButton
disabled={lockToggleDisabled}
size='small'
Expand Down Expand Up @@ -103,5 +109,6 @@ LayerLineEntry.propTypes = {
locked: PropTypes.bool, // optional, false if omitted
hidden: PropTypes.bool, // optional, false if omitted
expanded: PropTypes.bool, // optional, false if omitted
selectLayer: PropTypes.func.isRequired
selectLayer: PropTypes.func.isRequired,
editLayerName: PropTypes.func.isRequired
}
5 changes: 5 additions & 0 deletions src/renderer/components/layerlist/LayerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const LayerList = (/* props */) => {
const reducer = (state, event) => (handlers[event.type] || I)(state, event)
const [layers, dispatch] = React.useReducer(reducer, {})

const editLayerName = (layerId) => () => {
dispatch({ type: 'editoractivated', layerId: layerId })
}

const selectedLayerId = () => {
const selected = selection.selected(URI.isLayerId)
return selected.length ? selected[0] : null
Expand Down Expand Up @@ -116,6 +120,7 @@ const LayerList = (/* props */) => {
key={layer.id}
{ ...layer }
selectLayer={selectLayer(layer.id)}
editLayerName={editLayerName(layer.id)}
/>

const sortedLayers = () => Object.values(layers)
Expand Down