Skip to content

Commit 68074d0

Browse files
authored
Merge pull request #2339 from tf/motif-indicator
Improve motif indicator
2 parents 0228eb2 + 63f0b57 commit 68074d0

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

entry_types/scrolled/package/spec/frontend/v1/MotifArea-spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ describe('MotifArea', () => {
9696
expect(container.firstChild).toHaveStyle('height: 0px');
9797
});
9898

99+
it('does not apply visible class when image does not have motif area', () => {
100+
const {container} =
101+
renderInEntry(
102+
() => <MotifArea file={useFile({collectionName: 'imageFiles', permaId: 100})} />,
103+
{
104+
wrapper: ({children}) => (
105+
<MotifAreaVisibilityProvider visible={true}>
106+
{children}
107+
</MotifAreaVisibilityProvider>
108+
),
109+
seed: {
110+
imageFiles: [
111+
{
112+
permaId: 100,
113+
width: 200,
114+
height: 100
115+
}
116+
]
117+
}
118+
}
119+
);
120+
121+
expect(container.firstChild).not.toHaveClass(styles.visible);
122+
});
123+
99124
describe('onUpdate prop', () => {
100125
const seed = {
101126
imageFiles: [

entry_types/scrolled/package/src/frontend/MotifArea.module.css

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.root {
22
position: absolute;
3-
background: radial-gradient(transparent, currentColor);
43
z-index: 2;
54
opacity: 0;
65
pointer-events: none;
@@ -13,6 +12,53 @@
1312
-webkit-transform: translateZ(0);
1413
}
1514

15+
.root::before {
16+
content: '';
17+
position: absolute;
18+
inset: 0;
19+
background: radial-gradient(transparent, currentColor);
20+
opacity: 0.15;
21+
}
22+
1623
.visible {
17-
opacity: 0.2;
24+
opacity: 1;
25+
}
26+
27+
.corner {
28+
position: absolute;
29+
width: 20px;
30+
height: 20px;
31+
border-color: currentColor;
32+
border-style: solid;
33+
border-width: 0;
34+
border-radius: 3px;
35+
opacity: 0.5;
36+
}
37+
38+
.topLeft {
39+
top: 0;
40+
left: 0;
41+
border-top-width: 3px;
42+
border-left-width: 3px;
43+
}
44+
45+
.topRight {
46+
top: 0;
47+
right: 0;
48+
border-top-width: 3px;
49+
border-right-width: 3px;
50+
}
51+
52+
.bottomLeft {
53+
bottom: 0;
54+
left: 0;
55+
border-bottom-width: 3px;
56+
border-left-width: 3px;
57+
}
58+
59+
.bottomRight {
60+
bottom: 0;
61+
right: 0;
62+
border-bottom-width: 3px;
63+
border-right-width: 3px;
1864
}

entry_types/scrolled/package/src/frontend/v1/MotifArea.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ export const MotifArea = function MotifArea(props) {
3535
return null;
3636
}
3737

38+
const hasMotifArea = !!props.file.motifAreaOffsetRect;
39+
3840
return (
3941
<div ref={setElementRef}
40-
className={classNames(styles.root, {[styles.visible]: visible})}
42+
className={classNames(styles.root, {[styles.visible]: visible && hasMotifArea})}
4143
style={position}
4244
onMouseEnter={props.onMouseEnter}
4345
onMouseLeave={props.onMouseLeave}>
46+
<div className={classNames(styles.corner, styles.topLeft)} />
47+
<div className={classNames(styles.corner, styles.topRight)} />
48+
<div className={classNames(styles.corner, styles.bottomLeft)} />
49+
<div className={classNames(styles.corner, styles.bottomRight)} />
4450
</div>
4551
);
4652
};

0 commit comments

Comments
 (0)