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

include <kbd> in running-text support #2475

Merged
merged 4 commits into from
May 8, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/core/src/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ Styleguide running-text
@extend %code-block;
}

kbd {
@extend %keyboard;
}

ul,
ol {
@extend %list;
Expand Down Expand Up @@ -281,6 +285,37 @@ Styleguide preformatted
@extend %code-block;
}

%keyboard {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remind me why we do this again? I'd have taken this opportunity to kill this pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro i un-killed it for this opportunity! https://github.com/palantir/blueprint/pull/2366/files#diff-63be20ab91cfbb20b47f78f5a125aea1R165

this is a perfect use case for placeholders: one set of styles that we want tied to two selectors - .X and .pt-running-text x

display: inline-flex;
align-items: center;
justify-content: center;
border-radius: $pt-border-radius;
box-shadow: $pt-elevation-shadow-1;
background: $white;
min-width: $pt-button-height-small;
height: $pt-button-height-small;
padding: $pt-border-radius ($pt-border-radius * 2);
vertical-align: middle;
line-height: $pt-button-height-small;
color: $pt-text-color-muted;
font-family: inherit;
font-size: $pt-font-size-small;

#{$icon-classes} {
margin-right: $pt-grid-size / 2;
}

.#{$ns}-dark & {
box-shadow: $pt-dark-elevation-shadow-1;
background: $dark-gray5;
color: $pt-dark-text-color-muted;
}
}

.#{$ns}-key {
@extend %keyboard;
}

/*
Block quotes

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Icon, IconName } from "../icon/icon";

export interface IAlertProps extends IProps {
/**
* Whether pressing <kbd class="pt-key">escape</kbd> when focused on the Alert should cancel the alert.
* Whether pressing <kbd>escape</kbd> when focused on the Alert should cancel the alert.
* If this prop is enabled, then either `onCancel` or `onClose` must also be defined.
* @default false
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/button/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use the `@ns-button` class to access button styles. You should implement buttons
* Add the attribute `tabindex="0"` to make `<a>` tags focusable. `<button>` elements are
focusable by default.
* For buttons implemented with `<a>` tags, add `tabindex="-1"` to disabled buttons to prevent the
user from focusing them by pressing <kbd class="@ns-key">tab</kbd> on the keyboard.
user from focusing them by pressing <kbd>tab</kbd> on the keyboard.
* Note that `<a>` tags do not respond to the `:disabled` attribute; use `.@ns-disabled` instead.

@css button
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/forms/numericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface INumericInputProps extends IIntentProps, IProps {
placeholder?: string;

/**
* The increment between successive values when <kbd class="pt-key">shift</kbd> is held.
* The increment between successive values when <kbd>shift</kbd> is held.
* Pass explicit `null` value to disable this interaction.
* @default 10
*/
Expand All @@ -86,7 +86,7 @@ export interface INumericInputProps extends IIntentProps, IProps {
min?: number;

/**
* The increment between successive values when <kbd class="pt-key">alt</kbd> is held.
* The increment between successive values when <kbd>alt</kbd> is held.
* Pass explicit `null` value to disable this interaction.
* @default 0.1
*/
Expand Down
38 changes: 3 additions & 35 deletions packages/core/src/components/hotkeys/_hotkeys.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,6 @@
@import "../../common/variables";
@import "../../common/mixins";

$kbd-key-size: 25px !default;
$modifier-key-padding: 3px 8px 3px 6px !default;

.#{$ns}-key {
display: inline-block;
border-radius: $pt-border-radius - 1;
box-shadow: $pt-elevation-shadow-2;
background: $white;
min-width: $kbd-key-size;
height: $kbd-key-size;
padding: 3px 5px;
vertical-align: middle;
text-align: center;
line-height: $pt-grid-size * 2;
color: $pt-text-color-muted;
font-family: inherit;
font-size: $pt-font-size-small;

&.#{$ns}-modifier-key {
padding: $modifier-key-padding;
}

.#{$ns}-dark & {
box-shadow: $pt-dark-elevation-shadow-2,
inset 0 1px 0 rgba($white, 0.05);
background: $dark-gray5;
color: $pt-dark-text-color-muted;
}
}

.#{$ns}-key-combo .#{$ns}-key:not(:last-child) {
margin-right: $pt-grid-size / 2;
}
Expand All @@ -46,10 +16,8 @@ $modifier-key-padding: 3px 8px 3px 6px !default;
padding: 0;
}

.#{$ns}-key-combo {
flex: 1 0 auto;
width: $pt-grid-size * 16;
text-align: right;
.#{$ns}-hotkey-label {
flex-grow: 1;
}
}

Expand All @@ -70,7 +38,7 @@ $modifier-key-padding: 3px 8px 3px 6px !default;

.#{$ns}-hotkey {
display: flex;
align-items: baseline;
align-items: center;
justify-content: space-between;
margin-right: 0;
margin-left: 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/tag-input/tag-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Tag inputs render [`Tag`](#core/components/tag)s inside an input, followed by an

@reactExample TagInputExample

**`TagInput` must be controlled,** meaning the `values` prop is required and event handlers are strongly suggested. Typing in the input and pressing <kbd class="@ns-key">enter</kbd> will **add new items** by invoking callbacks. If `addOnBlur` is set to true, clicking out of the component will also trigger the callback to add new items. A `separator` prop is supported to allow multiple items to be added at once; the default splits on commas.
**`TagInput` must be controlled,** meaning the `values` prop is required and event handlers are strongly suggested. Typing in the input and pressing <kbd>enter</kbd> will **add new items** by invoking callbacks. If `addOnBlur` is set to true, clicking out of the component will also trigger the callback to add new items. A `separator` prop is supported to allow multiple items to be added at once; the default splits on commas.

**Tags can be removed** by clicking their <span class="@ns-icon-standard @ns-icon-cross"></span> buttons, or by pressing <kbd class="@ns-key">backspace</kbd> repeatedly. Arrow keys can also be used to focus on a particular tag before removing it. The cursor must be at the beginning of the text input for these interactions.
**Tags can be removed** by clicking their <span class="@ns-icon-standard @ns-icon-cross"></span> buttons, or by pressing <kbd>backspace</kbd> repeatedly. Arrow keys can also be used to focus on a particular tag before removing it. The cursor must be at the beginning of the text input for these interactions.

**`Tag` appearance can be customized** with `tagProps`: supply an object to apply the same props to every tag, or supply a callback to apply dynamic props per tag. Tag `values` must be an array of strings so you may need a transformation step between your state and these props.

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/docs/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ any time.

Blueprint includes a utility that manages the appearance of focus styles. When enabled, focus styles
will be hidden while the user interacts using the mouse and will appear when the
<kbd class="@ns-key">tab</kbd> key is pressed to begin keyboard navigation. Try this out for yourself
<kbd>tab</kbd> key is pressed to begin keyboard navigation. Try this out for yourself
below.

**You must explictly enable this feature in your app (and you probably want to):**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/docs/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For longer blocks of running text, such as articles or documents, see [running t
Longform text, such as rendered Markdown documents, benefit from increased spacing and support for unclassed textual elements.
Apply `.@ns-running-text` to the parent element to apply the following styles to all children:

- `<h*>`, `<ul>`, `<ol>`, `<blockquote>`, `<code>`, `<pre>` do not require additional CSS classes for styles. This is great for rendered Markdown documents.
- `<h*>`, `<ul>`, `<ol>`, `<blockquote>`, `<code>`, `<pre>`, `<kbd>` tags do not require additional CSS classes for styles. This is great for rendered Markdown documents.
- `<h*>` tag margins are adjusted to provide clear separation between sections in a document.
- `<ul>` and `<ol>` tags receive [`.@ns-list`](#core/typography.lists) styles for legibility.

Expand Down
8 changes: 5 additions & 3 deletions packages/docs-theme/src/styles/_props.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// Licensed under the terms of the LICENSE file distributed with this project.

.docs-prop-details code {
box-shadow: none;
background: none;
// stylelint-disable declaration-no-important
box-shadow: none !important;
background: none !important;
padding: 0;
color: inherit;
color: inherit !important;
font-size: small;
font-weight: 600;
// stylelint-enable declaration-no-important
}

.docs-prop-default {
Expand Down