Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2f24d99
Adding files to experiments
kelseyyoung Feb 2, 2018
76352b0
Fix most tslint errors
kelseyyoung Feb 2, 2018
3543cc3
Fix initial tslint errors
montselozanod Feb 2, 2018
67627a4
Fix other tslint errors
montselozanod Feb 2, 2018
cbd290b
Fix last compiling issues
montselozanod Feb 2, 2018
51cc7ef
Add keysequence files
montselozanod Feb 2, 2018
2e2af82
Add pages to example app
montselozanod Feb 2, 2018
2af68af
Removed IKeySequence files in packages/utilities
kelseyyoung Feb 2, 2018
0a062cd
First pass of writing processInput
kelseyyoung Feb 2, 2018
36fd2eb
Update KeytipLayer Example to use data attribute
kelseyyoung Feb 5, 2018
92fbf3a
Add Keytipsequencestarts with tests
montselozanod Feb 5, 2018
fdf62fe
Add matched and partially matched nodes tests
montselozanod Feb 5, 2018
c4ad656
Add keysequenceStarts with tests and partial and exact node matched t…
montselozanod Feb 5, 2018
d8df180
Add more tests to keysquences
montselozanod Feb 5, 2018
2c2b93c
Add initial processInput tests
montselozanod Feb 6, 2018
4cffb82
Add initial processInput tests
montselozanod Feb 6, 2018
186a0c6
Clean up unused imports
montselozanod Feb 6, 2018
99a5f34
Merge branch 'features/keytips2' of https://github.com/kelseyyoung/of…
montselozanod Feb 6, 2018
361a486
Add partial nodes tests
montselozanod Feb 6, 2018
31d12d1
Show/hide methods for the tree nodes
montselozanod Feb 6, 2018
c400a87
Add hasChildrenNodes prop and a test for it
montselozanod Feb 6, 2018
bd1bceb
Moved function to comply with tslint
kelseyyoung Feb 6, 2018
e0376be
Merge with features/keytips2
kelseyyoung Feb 6, 2018
780e149
Get keytip to show on starting sequence in example
kelseyyoung Feb 6, 2018
3f410d5
Refactor KeySequences to use strings instead of KeyCodes
kelseyyoung Feb 8, 2018
e7c4aff
disable and enable keytipmode correctly
montselozanod Feb 8, 2018
6f5ab2a
Add more items to KeytipLayer example
kelseyyoung Feb 9, 2018
4d90cb8
Fix unit tests
montselozanod Feb 9, 2018
49aca3b
Fix exit points for keys
montselozanod Feb 9, 2018
67805a0
Exit when scrolled and enter keytipmode again
montselozanod Feb 9, 2018
c155d12
Add exit sequences
montselozanod Feb 9, 2018
f70ba2b
Fix broken unit tests
montselozanod Feb 9, 2018
822ba9a
Add modifier to example
montselozanod Feb 9, 2018
4d3cb06
Fix hierarchy bugs
montselozanod Feb 10, 2018
80f27de
Add more examples keytips demo
montselozanod Feb 12, 2018
a9d13a8
Add get execture func
montselozanod Feb 12, 2018
88dbee6
Make processInput consume only one key
montselozanod Feb 12, 2018
6ebe467
Change goback to return
montselozanod Feb 13, 2018
c37541c
Add overflowsetSequence props
montselozanod Feb 13, 2018
836b2d5
Documentation and refactoring
kelseyyoung Feb 13, 2018
ae15574
Merge with features/keytips2
kelseyyoung Feb 13, 2018
6d09062
Unregister keytip functionality
kelseyyoung Feb 13, 2018
6f67c31
Remove IKeytipTranstionSequence, transition keys can only be one key now
kelseyyoung Feb 14, 2018
e4d51ed
Add comments algorithm
montselozanod Feb 14, 2018
6eb9632
Change addNode to receive keytipProps
montselozanod Feb 14, 2018
9fc0717
Merge branch 'features/keytips2' of https://github.com/kelseyyoung/of…
montselozanod Feb 14, 2018
8d60d3f
Remove duplicate identifiers
montselozanod Feb 14, 2018
09472dc
Allow for multiple modifier keys
kelseyyoung Feb 14, 2018
3993394
Merge with features/keytips2
kelseyyoung Feb 14, 2018
ef514f5
Fix import errors by moving KeytipManager and Tree to utilities/keytip
kelseyyoung Feb 14, 2018
698dd1a
Show keytip right away if its parent is currentKeytip
kelseyyoung Feb 15, 2018
46d98da
Add tests for overflow node adding
montselozanod Feb 15, 2018
c5c4e20
Fix merge conflicts
montselozanod Feb 15, 2018
aa2a38d
Delete keytiptree tests from wrong directory
montselozanod Feb 15, 2018
964da5b
Re-add tests to overflowset sequence for add node
montselozanod Feb 15, 2018
f685f0e
Fix go back and clean current Sequence array
montselozanod Feb 15, 2018
5f226ec
registerKeytip update functionality
kelseyyoung Feb 15, 2018
5c93e0e
Merge with features/keytips2
kelseyyoung Feb 15, 2018
b4ad4d5
Updated KeytipLayer demo
kelseyyoung Feb 16, 2018
55ae9ee
Add test for keytiplink process input
montselozanod Feb 16, 2018
a639c18
Merge branch 'features/keytips2' of https://github.com/kelseyyoung/of…
montselozanod Feb 16, 2018
67084b0
Added logic for keytiplink in remove and added unit test
montselozanod Feb 16, 2018
605d57f
Add tests for matching disabled nodes
montselozanod Feb 16, 2018
deea27e
Make content required on IKeytipProps
kelseyyoung Feb 16, 2018
0cec24f
Remove outdated comments
montselozanod Feb 16, 2018
6f210d4
Fix merge conflicts
montselozanod Feb 16, 2018
08094e0
Remove outdated comment
montselozanod Feb 16, 2018
34f92f4
Comments and small refactoring
kelseyyoung Feb 20, 2018
2fdc1a2
Add refactoring changes for ketip and keytipcontent
montselozanod Feb 21, 2018
ffec17f
Add tests
montselozanod Feb 21, 2018
8106e73
Very basic layer test
montselozanod Feb 21, 2018
38e04e6
Added examples for Keytip page
kelseyyoung Feb 21, 2018
cd531ac
Merge with features/keytips2
kelseyyoung Feb 21, 2018
eaaba1c
Remove unused keytipstate
montselozanod Feb 21, 2018
dc82938
Remove unused files
montselozanod Feb 21, 2018
f594b05
Small fixes
kelseyyoung Feb 21, 2018
a6140d4
Merge branch 'features/keytips2' of https://github.com/kelseyyoung/of…
kelseyyoung Feb 21, 2018
c71a890
Fix Keytip language example
kelseyyoung Feb 21, 2018
5cac5fa
Merge remote-tracking branch 'upstream/master' into features/keytips2
kelseyyoung Feb 21, 2018
74cf1d4
Make KeyCodes a const enum again
kelseyyoung Feb 21, 2018
ea81f58
Add rush change files
kelseyyoung Feb 21, 2018
17f122d
Add offset default prop and test UI for offset
montselozanod Feb 22, 2018
59baba9
Improve code with Fabric array utils
kelseyyoung Feb 27, 2018
ba40a98
Merge branch 'features/keytips2' of https://github.com/kelseyyoung/of…
kelseyyoung Feb 27, 2018
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/experiments",
"comment": "Add initial set of Keytip work",
"type": "patch"
}
],
"packageName": "@uifabric/experiments",
"email": "keyou@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/utilities",
"comment": "Update KeyCodes enum to include all key codes",
"type": "minor"
}
],
"packageName": "@uifabric/utilities",
"email": "keyou@microsoft.com"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"devDependencies": {
"@microsoft/rush": "4.1.0"
}
}
}
1 change: 1 addition & 0 deletions packages/experiments/src/Keytip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Keytip/index';
1 change: 1 addition & 0 deletions packages/experiments/src/KeytipLayer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/KeytipLayer/index';
2 changes: 1 addition & 1 deletion packages/experiments/src/Utilities.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'office-ui-fabric-react/lib/Utilities';
export * from 'office-ui-fabric-react/lib/Utilities';
52 changes: 52 additions & 0 deletions packages/experiments/src/components/Keytip/Keytip.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { IKeytipStyleProps, IKeytipStyles } from './Keytip.types';
import { ICalloutContentStyleProps, ICalloutContentStyles } from 'office-ui-fabric-react/lib/Callout';

export const getStyles = (props: IKeytipStyleProps): IKeytipStyles => {
const { theme, disabled, visible } = props;
return {
container: [
{
backgroundColor: theme.palette.neutralDark
},
disabled && {
opacity: 0.5,
},
!visible && {
visibility: 'hidden'
}
],
root: [{
textAlign: 'center',
paddingLeft: 3,
paddingRight: 3,
backgroundColor: theme.palette.neutralDark,
color: theme.palette.neutralLight,
minWidth: 11,
lineHeight: 17,
height: 17,
display: 'inline-block'
},
disabled && {
color: '#b1b1b1'
}]
};
};

export const getCalloutStyles = (props: ICalloutContentStyleProps): ICalloutContentStyles => {
return {
container: [
],
root: [{
border: 'none',
boxShadow: 'none'
}],
beak: [
],
beakCurtain: [
],
calloutMain: [{
backgroundColor: 'transparent'
}
]
};
};
46 changes: 46 additions & 0 deletions packages/experiments/src/components/Keytip/Keytip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as React from 'react';
import { BaseComponent } from '../../Utilities';
import { Callout } from 'office-ui-fabric-react/lib/Callout';
import { DirectionalHint } from 'office-ui-fabric-react/lib/ContextualMenu';
import { IKeytip, IKeytipProps } from './Keytip.types';
import { KeytipContent } from './KeytipContent';
import { getCalloutStyles } from './Keytip.styles';
import { constructKeytipTargetFromSequences } from '../../utilities/keytip/KeytipUtils';

/**
* A callout corresponding to another Fabric component to describe a key sequence that will activate that component
*
* @export
* @class Keytip
* @extends {BaseComponent<IKeytipProps, {}}>}
*/
export class Keytip extends BaseComponent<IKeytipProps, {}> implements IKeytip {

// tslint:disable-next-line:no-any
constructor(props: IKeytipProps, context: any) {
super(props, context);
}

public render(): JSX.Element {
const {
calloutProps,
keySequences,
offset = 0 // Default value for gap is 0
} = this.props;

return (
<Callout
{ ...calloutProps }
gapSpace={ offset }
isBeakVisible={ false }
doNotLayer={ true }
directionalHint={ DirectionalHint.bottomCenter }
target={ constructKeytipTargetFromSequences(keySequences) }
getStyles={ getCalloutStyles }
preventDismissOnScroll={ true }
>
<KeytipContent {...this.props} />
</Callout>
);
}
}
156 changes: 156 additions & 0 deletions packages/experiments/src/components/Keytip/Keytip.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { ICalloutProps } from 'office-ui-fabric-react/lib/Callout';
import { IStyle, ITheme } from '../../Styling';
import { IStyleFunction } from '../../Utilities';
import { IKeySequence } from '../../utilities/keysequence/IKeySequence';

export interface IKeytip {
}

export interface IKeytipProps {
/**
* Optional callback to access the Keytip component. Use this instead of ref for accessing
* the public methods and properties of the component.
*/
componentRef?: (component: IKeytip) => void;

/**
* Content to put inside the keytip
*
* @type {string}
*/
content: string;

/**
* Theme for the component
*
* @type {ITheme}
*/
theme?: ITheme;

/**
* T/F if the corresponding control is disabled
*
* @type {boolean}
*/
disabled?: boolean;

/**
* T/F if the keytip is visible
*
* @type {boolean}
*/
visible?: boolean;

/**
* Function to call when this keytip is activated
* 'el' is the DOM element that the keytip is attached to
*
* @type {(HTMLElement) => void}
*/
onExecute?: (el: HTMLElement) => void;

/**
* Function to call when the keytip is returned to
* 'el' is the DOM element that the keytip is attached to
*
* @type {(HTMLElement) => void}
*/
onReturn?: (el: HTMLElement) => void;

/**
* Array of KeySequences which is the full key sequence to trigger this keytip
* Should not include initial 'start' key sequence
*
* @type {IKeySequence[]}
*/
keySequences: IKeySequence[];

/**
* KeySequence of overflow set which will trigger the keytip.
*
* @type {IKeySequence}
*/
overflowSetSequence?: IKeySequence;

/**
* ICalloutProps to pass to the callout element
*
* @type {string}
*/
calloutProps?: ICalloutProps;

/**
* Optional styles for the component.
*
* @type {IStyleFunction<IKeytipStyleProps, IKeytipStyles>}
*/
getStyles?: IStyleFunction<IKeytipStyleProps, IKeytipStyles>;

/**
* Offset distance in px between the target element and the positioning of the keytip.this keytip
*
* @type {number}
* @default 0
*/
offset?: number;

/**
* Whether or not this node has children nodes or not. Should be used for menus/overflow components, that have
* their children registered after the initial rendering of the DOM.
*
* @type {boolean}
*/
hasChildrenNodes?: boolean;
}

/**
* Props to style Keytip component
*/
export interface IKeytipStyleProps {

/**
* The theme for the keytip.
*
* @type {ITheme}
*/
theme: ITheme;

/**
* Whether the keytip is disabled or not.
*
* @type {boolean}
*/
disabled?: boolean;

/**
* T/F if the keytip is visible
*
* @type {boolean}
*/
visible?: boolean;
}

export interface IKeytipStyles {

/**
* Style for the div container surrounding the keytip content.
*
* @type {IStyle}
*/
container: IStyle;

/**
* Style for the keytip content element.
*
* @type {IStyle}
*/
root: IStyle;
}

export enum KeytipTransitionModifier {
shift = 16,
ctrl = 17,
alt = 18,
leftWindow = 91,
rightWindow = 92
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as React from 'react';
import { BaseComponent, classNamesFunction, customizable } from '../../Utilities';
import { convertSequencesToKeytipID } from '../../utilities/keysequence/IKeySequence';
import { IKeytipProps, IKeytipStyleProps, IKeytipStyles } from './Keytip.types';

/**
* A component corresponding the the content rendered inside the callout of the keytip component.
*
* @export
* @class KeytipContent
* @extends {BaseComponent<IKeytipProps>}
*/
@customizable('KeytipContent', ['theme'])
export class KeytipContentBase extends BaseComponent<IKeytipProps, {}> {

public render(): JSX.Element {
let {
content,
getStyles,
theme,
disabled,
keySequences,
visible
} = this.props;

const getClassNames = classNamesFunction<IKeytipStyleProps, IKeytipStyles>();
let classNames = getClassNames(
getStyles!,
{
theme: theme!,
disabled,
visible
}
);

return (
<div className={ classNames.container } >
<span id={ convertSequencesToKeytipID(keySequences) } className={ classNames.root }>{ content }</span>
</div >
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import { IKeySequence } from '../../utilities/keysequence/IKeySequence';
import { KeytipContent } from './KeytipContent';

const sequence: IKeySequence[] = [{ keys: ['a'] }];
const keyCont = 'A';

describe('Keytip', () => {
it('renders visible Keytip correctly', () => {
const componentContent = renderer.create(<KeytipContent visible={ true } content={ keyCont } keySequences={ sequence } />);
let tree = componentContent.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders visible disabled Keytip correctly', () => {
const componentContent = renderer.create(
<KeytipContent
visible={ true }
disabled={ true }
content={ keyCont }
keySequences={ sequence }
/>);
let tree = componentContent.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders invisible Keytip correctly', () => {
const componentContent = renderer.create(<KeytipContent visible={ false } content={ keyCont } keySequences={ sequence } />);
let tree = componentContent.toJSON();
expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { styled } from '../../Utilities';
import { IKeytipProps, IKeytipStyleProps, IKeytipStyles } from './Keytip.types';
import { KeytipContentBase } from './KeytipContent.base';
import { getStyles } from './Keytip.styles';

export const KeytipContent = styled<IKeytipProps, IKeytipStyleProps, IKeytipStyles>(
KeytipContentBase,
getStyles
);
Loading