Skip to content

Commit

Permalink
Move focus style manager to its own file (palantir#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya committed Dec 5, 2016
1 parent c4aa603 commit d730e4f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
20 changes: 20 additions & 0 deletions packages/core/src/accessibility/focusStyleManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2016 Palantir Technologies, Inc. All rights reserved.
* Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy
* of the license at https://github.com/palantir/blueprint/blob/master/LICENSE
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/

import { InteractionModeEngine } from "../common/interactionMode";

export const FOCUS_DISABLED_CLASS = "pt-focus-disabled";

const focusEngine = new InteractionModeEngine(document.documentElement, FOCUS_DISABLED_CLASS);

// this is basically meaningless to unit test; it requires manual UI testing
/* istanbul ignore next */
export const FocusStyleManager = {
alwaysShowFocus: () => focusEngine.stop(),
isActive: () => focusEngine.isActive(),
onlyShowFocusOnTabs: () => focusEngine.start(),
};
8 changes: 8 additions & 0 deletions packages/core/src/accessibility/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright 2016 Palantir Technologies, Inc. All rights reserved.
* Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy
* of the license at https://github.com/palantir/blueprint/blob/master/LICENSE
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/

export * from "./focusStyleManager";
13 changes: 1 addition & 12 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/

export * from "./accessibility";
export * from "./common"
export * from "./components";
export { IconClasses } from "./generated/iconClasses";
export { IconContents } from "./generated/iconStrings";

import { InteractionModeEngine } from "./common/interactionMode";

export const FOCUS_DISABLED_CLASS = "pt-focus-disabled";

const focusEngine = new InteractionModeEngine(document.documentElement, FOCUS_DISABLED_CLASS);

export const FocusStyleManager = {
alwaysShowFocus: () => focusEngine.stop(),
isActive: () => focusEngine.isActive(),
onlyShowFocusOnTabs: () => focusEngine.start(),
};

0 comments on commit d730e4f

Please sign in to comment.