Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle the launcher, enable keyboard navigation #6587

Merged
merged 3 commits into from Jun 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/launcher/src/index.tsx
Expand Up @@ -347,7 +347,7 @@ function Card(
const args = { ...item.args, cwd: launcher.cwd };
const caption = commands.caption(command, args);
const label = commands.label(command, args);
const title = caption || label;
const title = kernel ? label : caption || label;

// Build the onclick handler.
let onclick = () => {
Expand Down Expand Up @@ -375,12 +375,22 @@ function Card(
});
};

// With tabindex working, you can now pick a kernel by tabbing around and
// pressing Enter.
let onkeypress = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
onclick();
}
};

// Return the VDOM element.
return (
<div
className="jp-LauncherCard"
title={title}
onClick={onclick}
onKeyPress={onkeypress}
tabIndex={100}
data-category={item.category || 'Other'}
key={Private.keyProperty.get(item)}
>
Expand All @@ -400,7 +410,7 @@ function Card(
)}
</div>
<div className="jp-LauncherCard-label" title={title}>
{label}
<p>{label}</p>
</div>
</div>
);
Expand Down
29 changes: 21 additions & 8 deletions packages/launcher/style/base.css
Expand Up @@ -9,8 +9,8 @@
--jp-private-launcher-top-padding: 16px;
--jp-private-launcher-side-padding: 32px;
--jp-private-launcher-card-size: 100px;
--jp-private-launcher-card-label-height: 25px;
--jp-private-launcher-card-icon-height: 75px;
--jp-private-launcher-card-label-height: 32px;
--jp-private-launcher-card-icon-height: 68px;
--jp-private-launcher-large-icon-size: 52px;
--jp-private-launcher-small-icon-size: 32px;
}
Expand Down Expand Up @@ -117,10 +117,19 @@
border-radius: var(--jp-border-radius);
}

.jp-LauncherCard:focus:not(:active) {
border: 1px solid var(--jp-brand-color1);
box-shadow: var(--jp-elevation-z6);
}

.jp-LauncherCard:hover {
box-shadow: var(--jp-elevation-z6);
}

.jp-LauncherCard:active {
box-shadow: var(--jp-elevation-z4);
}

.jp-LauncherCard-icon {
width: 100%;
height: var(--jp-private-launcher-card-icon-height);
Expand Down Expand Up @@ -150,15 +159,19 @@
.jp-LauncherCard-label {
width: 100%;
height: var(--jp-private-launcher-card-label-height);
line-height: var(--jp-private-launcher-card-label-height);
font-size: var(--jp-ui-font-size1);
padding: 0 8px;
color: var(--jp-ui-font-color1);
padding: 0 4px 4px 4px;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.jp-LauncherCard-label p {
height: 28px;
word-break: break-word;
text-align: center;
color: var(--jp-ui-font-color1);
line-height: 14px;
font-size: 12px;
overflow: hidden;
}

/* Icons, kernel icons */
Expand Down