Skip to content

Commit d1e6960

Browse files
committed
Modify tile delete button for touch
Prototype of larger delete button for sprites, costumes and sounds to better support touch devices. I split it out from `CloseButton` as it made the changes simpler, and we may end up going in a different direction (open context menu).
1 parent f2ac39f commit d1e6960

File tree

5 files changed

+105
-6
lines changed

5 files changed

+105
-6
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@import "../../css/colors.css";
2+
@import "../../css/units.css";
3+
4+
/* the delete button has .25rem invisible 'slop' around the visible button
5+
to make it easier to tap on a touch device */
6+
.delete-button {
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
11+
overflow: hidden; /* Mask the icon animation */
12+
width: 2rem;
13+
height: 2rem;
14+
user-select: none;
15+
cursor: pointer;
16+
transition: all 0.15s ease-out;
17+
18+
}
19+
20+
/* .delete-button.large:hover {
21+
transform: scale(1.1, 1.1);
22+
box-shadow: 0 0 0 4px $ui-black-transparent;
23+
} */
24+
25+
.delete-button-visible {
26+
display: flex;
27+
align-items: center;
28+
justify-content: center;
29+
30+
overflow: hidden; /* Mask the icon animation */
31+
width: 1.75rem;
32+
height: 1.75rem;
33+
box-shadow: 0px 0px 0px 2px $motion-transparent;
34+
background-color: $motion-primary;
35+
color: $ui-white;
36+
border-radius: 50%;
37+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
38+
user-select: none;
39+
cursor: pointer;
40+
transition: all 0.15s ease-out;
41+
}
42+
43+
.delete-icon {
44+
position: relative;
45+
margin: 0.25rem;
46+
user-select: none;
47+
transform-origin: 50%;
48+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
import classNames from 'classnames';
4+
5+
import styles from './delete-button.css';
6+
import deleteIcon from './icon--delete.svg';
7+
8+
const DeleteButton = props => (
9+
<div
10+
aria-label="Delete"
11+
className={classNames(
12+
styles.deleteButton,
13+
props.className
14+
)}
15+
role="button"
16+
tabIndex="0"
17+
onClick={props.onClick}
18+
>
19+
<div className={styles.deleteButtonVisible}>
20+
<img
21+
className={styles.deleteIcon}
22+
src={deleteIcon}
23+
/>
24+
</div>
25+
</div>
26+
27+
);
28+
29+
DeleteButton.propTypes = {
30+
className: PropTypes.string,
31+
onClick: PropTypes.func.isRequired
32+
};
33+
34+
export default DeleteButton;
Lines changed: 18 additions & 0 deletions
Loading

src/components/sprite-selector-item/sprite-selector-item.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@
9494

9595
.delete-button {
9696
position: absolute;
97-
top: 0.125rem;
97+
top: -.625rem;
9898
z-index: auto;
9999
}
100100

101101
[dir="ltr"] .delete-button {
102-
right: 0.125rem;
102+
right: -.625rem;
103103
}
104104

105105
[dir="rtl"] .delete-button {
106-
left: 0.125rem;
106+
left: -.625rem;
107107
}
108108

109109
.number {

src/components/sprite-selector-item/sprite-selector-item.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import classNames from 'classnames';
22
import PropTypes from 'prop-types';
33
import React from 'react';
44

5-
import CloseButton from '../close-button/close-button.jsx';
5+
import DeleteButton from '../delete-button/delete-button.jsx';
66
import styles from './sprite-selector-item.css';
77
import {ContextMenuTrigger} from 'react-contextmenu';
88
import {DangerousMenuItem, ContextMenu, MenuItem} from '../context-menu/context-menu.jsx';
@@ -48,9 +48,8 @@ const SpriteSelectorItem = props => (
4848
) : null}
4949
</div>
5050
{(props.selected && props.onDeleteButtonClick) ? (
51-
<CloseButton
51+
<DeleteButton
5252
className={styles.deleteButton}
53-
size={CloseButton.SIZE_SMALL}
5453
onClick={props.onDeleteButtonClick}
5554
/>
5655
) : null }

0 commit comments

Comments
 (0)