Skip to content

Commit ab4417c

Browse files
committed
EditCard only appears when focused
Update snapshots
1 parent 297ff9b commit ab4417c

File tree

9 files changed

+24
-14
lines changed

9 files changed

+24
-14
lines changed

src/app/components/Modal/__snapshots__/Modal.spec.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ exports[`Modal matches snapshot 1`] = `
6868
-ms-flex-align: center;
6969
align-items: center;
7070
margin: 0;
71-
padding: 1.5rem 0;
7271
}
7372
7473
.c6 {
@@ -263,7 +262,6 @@ exports[`Modal matches snapshot with children 1`] = `
263262
-ms-flex-align: center;
264263
align-items: center;
265264
margin: 0;
266-
padding: 1.5rem 0;
267265
}
268266
269267
.c6 {

src/app/components/Modal/styles.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const Heading = styled.h1`
3737
display: flex;
3838
align-items: center;
3939
margin: 0;
40-
padding: ${modalPadding * 0.5}rem 0;
4140
`;
4241

4342
// tslint:disable-next-line:variable-name

src/app/content/__snapshots__/routes.spec.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ Array [
286286
.c4 .highlight {
287287
position: relative;
288288
z-index: 1;
289+
-webkit-user-select: none;
290+
-moz-user-select: none;
291+
-ms-user-select: none;
292+
user-select: none;
289293
}
290294
291295
.c4 .MathJax_Display .highlight,

src/app/content/components/Page/PageContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default styled(MainContent)`
5858
.highlight {
5959
position: relative;
6060
z-index: 1;
61+
user-select: none;
6162
}
6263
6364
/* stylelint-disable selector-class-pattern */

src/app/content/components/__snapshots__/Content.spec.tsx.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ Array [
711711
.c74 .highlight {
712712
position: relative;
713713
z-index: 1;
714+
-webkit-user-select: none;
715+
-moz-user-select: none;
716+
-ms-user-select: none;
717+
user-select: none;
714718
}
715719

716720
.c74 .MathJax_Display .highlight,
@@ -8072,6 +8076,10 @@ Array [
80728076
.c74 .highlight {
80738077
position: relative;
80748078
z-index: 1;
8079+
-webkit-user-select: none;
8080+
-moz-user-select: none;
8081+
-ms-user-select: none;
8082+
user-select: none;
80758083
}
80768084

80778085
.c74 .MathJax_Display .highlight,

src/app/content/highlights/components/Card.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ function Card(props: CardProps) {
170170
);
171171
}
172172

173+
type ComputedProps = ReturnType<typeof useComputedProps>;
174+
type CommonProps = ComputedProps['commonProps'];
175+
173176
function NoteOrCard({
174177
props,
175178
setHighlightRemoved,
@@ -179,7 +182,7 @@ function NoteOrCard({
179182
props: CardPropsWithBookAndPage;
180183
setHighlightRemoved: React.Dispatch<React.SetStateAction<boolean>>;
181184
locationFilterId: string;
182-
computedProps: ReturnType<typeof useComputedProps>;
185+
computedProps: ComputedProps;
183186
}) {
184187
const {
185188
focusCard,
@@ -219,7 +222,7 @@ function NoteOrCard({
219222
/>
220223
) : (
221224
<EditCardWithOnCreate
222-
cardProps={props as CardPropsWithBookAndPage}
225+
cardProps={props}
223226
commonProps={{ ...commonProps, onRemove }}
224227
locationFilterId={locationFilterId}
225228
hasUnsavedHighlight={hasUnsavedHighlight}
@@ -230,9 +233,8 @@ function NoteOrCard({
230233
);
231234
}
232235

233-
type ComputedProps = ReturnType<typeof useComputedProps>;
234236
type EditCardProps = {
235-
commonProps: object;
237+
commonProps: CommonProps & {onRemove: () => void};
236238
cardProps: CardPropsWithBookAndPage;
237239
locationFilterId: string;
238240
} & Pick<ComputedProps, 'hasUnsavedHighlight' | 'setEditing'>;
@@ -291,12 +293,13 @@ const StyledCard = styled(Card)`
291293
// Styling is expensive and most Cards don't need to render
292294
function PreCard(props: CardProps) {
293295
const computedProps = useComputedProps(props);
296+
const hideUnfocusedEditCard = computedProps.annotation ? {} : {isHidden: !props.shouldFocusCard}
294297

295298
if (!computedProps.annotation && (!props.isActive)) {
296299
return null;
297300
}
298301
return (
299-
<StyledCard {...props} />
302+
<StyledCard {...{...props, ...hideUnfocusedEditCard}} />
300303
);
301304
}
302305

src/app/content/highlights/components/__snapshots__/Card.spec.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Card matches snapshot when focused without note 1`] = `
44
.c0 {
5-
visibility: visible;
5+
visibility: hidden;
66
-webkit-animation: 600ms bcCCNc ease-out;
77
animation: 600ms bcCCNc ease-out;
88
display: block;
@@ -121,7 +121,7 @@ exports[`Card matches snapshot when focused without note 1`] = `
121121

122122
exports[`Card matches snapshot when passed data without note 1`] = `
123123
.c0 {
124-
visibility: visible;
124+
visibility: hidden;
125125
-webkit-animation: 600ms bcCCNc ease-out;
126126
animation: 600ms bcCCNc ease-out;
127127
display: block;
@@ -215,7 +215,7 @@ exports[`Card matches snapshot when passed data without note 1`] = `
215215

216216
exports[`Card matches snapshot without data 1`] = `
217217
.c0 {
218-
visibility: visible;
218+
visibility: hidden;
219219
-webkit-animation: 600ms bcCCNc ease-out;
220220
animation: 600ms bcCCNc ease-out;
221221
display: block;

src/app/content/highlights/components/__snapshots__/ConfirmationModal.spec.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ exports[`ConfirmationModal matches snapshot 1`] = `
6868
-ms-flex-align: center;
6969
align-items: center;
7070
margin: 0;
71-
padding: 1.5rem 0;
7271
}
7372
7473
.c7 {

src/app/errors/components/__snapshots__/ErrorModal.spec.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ exports[`ErrorModal matches snapshot 1`] = `
6868
-ms-flex-align: center;
6969
align-items: center;
7070
margin: 0;
71-
padding: 1.5rem 0;
7271
}
7372
7473
.c7 {
@@ -391,7 +390,6 @@ exports[`ErrorModal matches snapshots with recorded error ids 1`] = `
391390
-ms-flex-align: center;
392391
align-items: center;
393392
margin: 0;
394-
padding: 1.5rem 0;
395393
}
396394
397395
.c7 {

0 commit comments

Comments
 (0)