-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Enable server-side/isomorphic rendering #360
Changes from all commits
e9c89e0
f281672
32dda35
345e1fa
69568c3
f77bd1a
dd490e9
828acbe
df12c62
6a53b13
97c0800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ export const Aliases = { | |
command: "meta", | ||
escape: "esc", | ||
minus: "-", | ||
mod: /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "meta" : "ctrl", | ||
mod: ((typeof navigator !== "undefined") && /Mac|iPod|iPhone|iPad/.test(navigator.platform)) ? "meta" : "ctrl", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feels like we should have an |
||
option: "alt", | ||
plus: "+", | ||
return: "enter", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import { comboMatches, getKeyCombo, IKeyCombo, parseKeyCombo } from "./hotkeyPar | |
import { IHotkeysProps } from "./hotkeys"; | ||
import { isHotkeysDialogShowing, showHotkeysDialog } from "./hotkeysDialog"; | ||
|
||
const SHOW_DIALOG_KEY_COMBO = parseKeyCombo("?"); | ||
const SHOW_DIALOG_KEY = "?"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
export enum HotkeyScope { | ||
LOCAL, | ||
|
@@ -59,7 +59,7 @@ export class HotkeysEvents { | |
|
||
const combo = getKeyCombo(e); | ||
|
||
if (comboMatches(SHOW_DIALOG_KEY_COMBO, combo)) { | ||
if (comboMatches(parseKeyCombo(SHOW_DIALOG_KEY), combo)) { | ||
showHotkeysDialog(this.actions.map((action) => action.props)); | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,12 @@ | |
* and https://github.com/palantir/blueprint/blob/master/PATENTS | ||
*/ | ||
|
||
import "dom4"; | ||
declare function require(moduleName: string): any; // declare node.js "require" so that we can conditionally import | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note for a follow-up change (doesn't have to be in this PR): we should share this ambient declaration with https://github.com/palantir/blueprint/blob/497a03eab4420e48db0865407995895aa25726fa/packages/docs/src/require-shim.d.ts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I included it there in the same file specifically because I was worried about scoping. It makes sense to merge them. Personally, I find the Node.js form clearer than the one used in |
||
if (typeof window !== "undefined" && typeof document !== "undefined") { // we're in browser | ||
// tslint:disable-next-line:no-var-requires | ||
require("dom4"); // only import actual dom4 if we're in the browser (not server-compatible) | ||
// we'll still need dom4 types for the TypeScript to compile, these are included in package.json | ||
} | ||
|
||
import * as contextMenu from "./context-menu/contextMenu"; | ||
export const ContextMenu = contextMenu; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,13 @@ export class MenuItem extends AbstractComponent<IMenuItemProps, IMenuItemState> | |
} | ||
|
||
let { left = 0, right = 0 } = this.props.submenuViewportMargin; | ||
right = document.documentElement.clientWidth - right; | ||
if (typeof document !== "undefined" | ||
&& typeof document.documentElement !== "undefined" | ||
&& Number(document.documentElement.clientWidth)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. implicit coercion number => boolean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I spotted this, but unfortunately we can't test for |
||
// we're in a browser context and the clientWidth is available, | ||
// use it to set calculate 'right' | ||
right = document.documentElement.clientWidth - right; | ||
} | ||
// uses context to prioritize the previous positioning | ||
let alignLeft = this.context.alignLeft || false; | ||
if (alignLeft) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test coverage is failing for this file; it's pretty hard to cover this functionality anyway, so we should disable the whole file. I suggest moving this
/* istanbul ignore next */
line to the top, right after the license.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks. I was just struggling with that. Coverage inexplicably runs on CircleCI but not locally, and I can't figure out why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried
gulp karma-unit-core
gulp karma-core
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using
gulp test
, which is an alias forgulp karma
.gulp karma-core
seems to do the same thing but only for the 'core' package. In all cases a coverage report is generated, but it is empty (shows100% Statements 0/0 100% Branches 0/0 100% Functions 0/0 100% Lines 0/0
). Anyhow, coverage seems to pass now.