Skip to content

Commit 1683277

Browse files
committed
EditCard only appears when focused
1 parent 4a38c4a commit 1683277

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

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/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/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

0 commit comments

Comments
 (0)