Skip to content
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
6 changes: 6 additions & 0 deletions packages/scratch-gui/src/components/cards/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ body .card-container {
height: 44px;
width: 44px;
border-radius: 100%;
border: none;
display: flex;
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -112,6 +113,11 @@ body .card-container {
font-weight: bold;
}

.header-buttons button {
background: none;
border: none;
}

.header-buttons-hidden {
border-bottom: 0px;
}
Expand Down
36 changes: 25 additions & 11 deletions packages/scratch-gui/src/components/cards/cards.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, {Fragment} from 'react';
import React, {Fragment, useEffect} from 'react';
import classNames from 'classnames';
import {FormattedMessage} from 'react-intl';
import Draggable from 'react-draggable';
Expand All @@ -18,9 +18,11 @@ import closeIcon from './icon--close.svg';
import {translateVideo} from '../../lib/libraries/decks/translate-video.js';
import {translateImage} from '../../lib/libraries/decks/translate-image.js';

import {KEY} from '../../lib/navigation-keys.js';

const CardHeader = ({onCloseCards, onShrinkExpandCards, onShowAll, totalSteps, step, expanded}) => (
<div className={expanded ? styles.headerButtons : classNames(styles.headerButtons, styles.headerButtonsHidden)}>
<div
<button
className={styles.allButton}
onClick={onShowAll}
>
Expand All @@ -33,7 +35,7 @@ const CardHeader = ({onCloseCards, onShrinkExpandCards, onShowAll, totalSteps, s
description="Title for button to return to tutorials library"
id="gui.cards.all-tutorials"
/>
</div>
</button>
{totalSteps > 1 ? (
<div className={styles.stepsList}>
{Array(totalSteps).fill(0)
Expand All @@ -46,7 +48,7 @@ const CardHeader = ({onCloseCards, onShrinkExpandCards, onShowAll, totalSteps, s
</div>
) : null}
<div className={styles.headerButtonsRight}>
<div
<button
className={styles.shrinkExpandButton}
onClick={onShrinkExpandCards}
>
Expand All @@ -66,8 +68,8 @@ const CardHeader = ({onCloseCards, onShrinkExpandCards, onShowAll, totalSteps, s
id="gui.cards.expand"
/>
}
</div>
<div
</button>
<button
className={styles.removeButton}
onClick={onCloseCards}
>
Expand All @@ -80,7 +82,7 @@ const CardHeader = ({onCloseCards, onShrinkExpandCards, onShowAll, totalSteps, s
description="Title for button to close how-to card"
id="gui.cards.close"
/>
</div>
</button>
</div>
</div>
);
Expand Down Expand Up @@ -192,29 +194,29 @@ const NextPrevButtons = ({isRtl, onNextStep, onPrevStep, expanded}) => (
{onNextStep ? (
<div>
<div className={expanded ? (isRtl ? styles.leftCard : styles.rightCard) : styles.hidden} />
<div
<button
className={expanded ? (isRtl ? styles.leftButton : styles.rightButton) : styles.hidden}
onClick={onNextStep}
>
<img
draggable={false}
src={isRtl ? leftArrow : rightArrow}
/>
</div>
</button>
</div>
) : null}
{onPrevStep ? (
<div>
<div className={expanded ? (isRtl ? styles.rightCard : styles.leftCard) : styles.hidden} />
<div
<button
className={expanded ? (isRtl ? styles.rightButton : styles.leftButton) : styles.hidden}
onClick={onPrevStep}
>
<img
draggable={false}
src={isRtl ? rightArrow : leftArrow}
/>
</div>
</button>
</div>
) : null}
</Fragment>
Expand Down Expand Up @@ -370,6 +372,18 @@ const Cards = props => {
} = props;
let {x, y} = posProps;

useEffect(() => {
const handleKeyDown = e => {
if (e.key === KEY.ESCAPE) {
onCloseCards();
}
};

window.addEventListener('keydown', handleKeyDown);

return () => window.removeEventListener('keydown', handleKeyDown);
}, [onCloseCards]);

if (activeDeckId === null) return;

// Tutorial cards need to calculate their own dragging bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ exports[`Cards component showVideos=false shows the title image/name instead of
>
<div>
<div>
<div>
<button>
<img
src="test-file-stub"
/>
Tutorials
</div>
</button>
<div>
<div>
<button>
<img
draggable="false"
src="test-file-stub"
/>
Shrink
</div>
<div>
</button>
<button>
<img
src="test-file-stub"
/>
Close
</div>
</button>
</div>
</div>
<div>
Expand Down Expand Up @@ -58,26 +58,26 @@ exports[`Cards component showVideos=true shows the video step 1`] = `
>
<div>
<div>
<div>
<button>
<img
src="test-file-stub"
/>
Tutorials
</div>
</button>
<div>
<div>
<button>
<img
draggable="false"
src="test-file-stub"
/>
Shrink
</div>
<div>
</button>
<button>
<img
src="test-file-stub"
/>
Close
</div>
</button>
</div>
</div>
<div>
Expand Down
Loading