Skip to content
This repository was archived by the owner on Nov 1, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
dacb12a
structure refactoring
Oct 3, 2017
47859ae
better file naming for themes
Oct 3, 2017
db3372a
<Autocomplete/>: default theme
Oct 3, 2017
9fc35d6
move popup back
Oct 4, 2017
dfffbec
removed unused styles
Oct 4, 2017
c199fea
factored out styles from number input to default theme, started refac…
Oct 4, 2017
783a94b
removed svg from checkbox api
Oct 4, 2017
5bd6e6e
merge master
Oct 5, 2017
5233001
fix merge master
Oct 5, 2017
4d3ee66
fix buttons after merge
Oct 5, 2017
03356eb
better hiding
Oct 5, 2017
b7bd0f0
fix autocomplete test to render it with theme
Oct 5, 2017
de20aae
theme HOC
Oct 5, 2017
f5b2792
Merge branch 'tyv/theming' into leonidl/theming
Oct 5, 2017
19ce316
theme rules for button
Oct 5, 2017
6531d7d
datepicker theme and checkbox base
Oct 6, 2017
1b95901
rollback hack with classNames
Oct 6, 2017
1c60e69
checkbox sliced
Oct 6, 2017
99956fd
checkbox themed
Oct 6, 2017
8cd1731
dropdown default theme and small related fixes
Oct 9, 2017
7477400
Merge branch 'leonidl/theming' of github.com:wix/stylable-components …
Oct 9, 2017
608c16a
fixed missing variable names in imports in wix/theme.st.css
Oct 9, 2017
1db174c
Merge branch 'leonidl/theming' of github.com:wix/stylable-components …
Oct 9, 2017
3558c03
merge number Input theming
Oct 9, 2017
d719244
number input - factored out project.st.css everywhere and fixed wix t…
Oct 9, 2017
067c71a
fixes to NumberInput CSS to allow shrinking the input without breaking
Oct 9, 2017
b76efc3
base input default theming files
Oct 9, 2017
d420dab
merge leo theming
Oct 9, 2017
580d11e
input theming
Oct 10, 2017
6fd4ab9
splitting Stepper component and adding its files to themes
Oct 10, 2017
d5e2b93
modal, start variables moving
Oct 10, 2017
3ed4ff4
continue moving vars
Oct 10, 2017
db43eeb
merge Leo changes
Oct 10, 2017
e95a2f2
better syntax
Oct 10, 2017
49310c2
fixing number input demo; removing background sizing from stepper com…
Oct 10, 2017
3430b8b
Stepper theme; fixing padding in theme of number input
Oct 10, 2017
8867f2a
stepper fix in default theme:
Oct 10, 2017
f20de1d
changed .root > Input in Input default theme
Oct 10, 2017
18b7472
refactored input styles to a mixin, applied them to the regular input…
Oct 10, 2017
b977f84
cleaned out input component's CSS file
Oct 10, 2017
3e5d14f
added important comments
Oct 10, 2017
a7bdacb
a little order in wix/theme.st.css
Oct 10, 2017
047e8af
using variables in themes
Oct 11, 2017
43fccbe
small changes before merge
Oct 11, 2017
ac71636
Merge branch 'tyv/theming' into leonidl/theming
Oct 11, 2017
d9853fa
refactoring autocomplete to match other inputs
Oct 11, 2017
2f70172
radio button default theme
Oct 11, 2017
1234891
removing CaretDown from autocomplete, refactoring to use background-i…
Oct 11, 2017
53b3ba9
leftovers from previous commit
Oct 11, 2017
5654b24
added font setting to default theme for numberInput
Oct 11, 2017
cc820ee
selection list + merge leo's
Oct 11, 2017
ad8a494
Merge branch 'leonidl/theming' of github.com:wix/stylable-components …
Oct 11, 2017
30fa7e2
tiny
Oct 11, 2017
a12ebbf
small changes
Oct 11, 2017
c693d9e
Merge branch 'tyv/theming' into leonidl/theming
Oct 11, 2017
8391f23
tiny
Oct 11, 2017
6e81ce1
code style
Oct 11, 2017
cfcf95b
stepper splitted
Oct 11, 2017
5167996
splitting timepicker
Oct 11, 2017
035675f
toggle
Oct 11, 2017
d5241eb
dropdown
Oct 12, 2017
afffdfa
Merge branch 'leonidl/theming' of github.com:wix/stylable-components …
Oct 12, 2017
73eb744
minor stuff
Oct 12, 2017
3b21f18
dropdown list fix
Oct 12, 2017
69d45f3
split tree view
Oct 12, 2017
03ce22d
time picker theme
Oct 13, 2017
7f25143
wix theme for toggle:
Oct 13, 2017
f878c28
fixed timepicker colon
wtfil Oct 13, 2017
e85872d
small
Oct 13, 2017
da3ee0b
checkbox wix style
Oct 13, 2017
3af4d52
end of toggle; button theme WIP
Oct 13, 2017
dd30bc9
fix conflicts & merge:
Oct 13, 2017
fe7c675
finish button theme
Oct 13, 2017
4898d82
made button variable names more semantic (replaced Blue with Main)
Oct 13, 2017
7a3d647
Merge pull request #463 from wix/wtfil/theming
tyv Oct 13, 2017
490612b
fixed tests
Oct 15, 2017
4a7a975
themes entry points for webpack
Oct 15, 2017
cebd260
merge master
Oct 17, 2017
b731f9e
review fixes
Oct 17, 2017
77b9e47
dialog
liorzisman Oct 17, 2017
e5c007d
progress
liorzisman Oct 18, 2017
86397fe
re-think the css for the dialog
liorzisman Oct 18, 2017
fc0f904
added button onclicks modal now seems to work. just gotta reconsider css
liorzisman Oct 18, 2017
6fc6280
basic dialog completed
liorzisman-ux Oct 19, 2017
a92debd
removed unused something
liorzisman-ux Oct 19, 2017
76702f0
removed unused soemthing ver2
liorzisman-ux Oct 19, 2017
a510025
removed unused final
liorzisman-ux Oct 19, 2017
829d43c
Merge branch 'master' of github.com:wix/wix-react-components into lio…
liorzisman-ux Oct 19, 2017
5a9b70c
modal driver wip
liorzisman-ux Oct 19, 2017
bb15af2
default props, inline-block
liorzisman-ux Oct 19, 2017
1a1e5a8
dialog renders invisibly and therefore removed from default contract …
liorzisman-ux Oct 19, 2017
126e7e2
inline-block
liorzisman-ux Oct 19, 2017
e441753
modal driver done
liorzisman-ux Oct 19, 2017
35235e0
Merge branch 'master' of github.com:wix/wix-react-components into lio…
liorzisman Oct 22, 2017
bd6efcc
dialog test driver
liorzisman Oct 22, 2017
11b224c
test driver for dialog
liorzisman Oct 22, 2017
5f66e3d
cleanup
liorzisman Oct 22, 2017
93ea389
yes
liorzisman Oct 23, 2017
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
6 changes: 6 additions & 0 deletions demo/components-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';
import {AutoCompleteDemo} from './components/auto-complete.demo';
import {CheckBoxDemo} from './components/checkbox-demo';
import {DatePickerDemo} from './components/date-picker-demo';
import {DialogDemo} from './components/dialog-demo';
import {DropDownDemo} from './components/drop-down.demo';
import {ImageDemo} from './components/image-demo';
import {LoaderDemo} from './components/loader-demo';
Expand Down Expand Up @@ -397,6 +398,11 @@ export class ComponentsDemo extends React.Component<DemoProps> {
<h2>Modal</h2>
<ModalDemo />
</div>
<hr />
<div>
<h2>Dialog</h2>
<DialogDemo />
</div>
</div>
);
}
Expand Down
7 changes: 7 additions & 0 deletions demo/components/dialog-demo.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.content {
width: 300px;
height: 300px;
font-size: 250px;
text-align: center;
vertical-align: middle;
}
30 changes: 30 additions & 0 deletions demo/components/dialog-demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import {stylable} from 'wix-react-tools';
import {Dialog} from '../../src';
import styles from './dialog-demo.st.css';

export interface DialogDemoState {
isOpen: boolean;
}

@stylable(styles)
export class DialogDemo extends React.Component<{}, DialogDemoState> {
public state: DialogDemoState = {
isOpen: false
};

public render() {
return (
<div>
<button data-automation-id="DIALOG_BUTTON" onClick={this.toggleOpen}>Open The Dialog!</button>
<Dialog className="root" isOpen={this.state.isOpen} onCancel={this.toggleOpen} onOk={this.toggleOpen}>
<div role="children" className="content">🌌</div>
</Dialog>
</div>
);
}

private toggleOpen = () => {
this.setState({isOpen: !this.state.isOpen});
}
}
38 changes: 38 additions & 0 deletions src/components/dialog/dialog.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@namespace "Dialog";

:import{
-st-from: "../modal/modal.st.css";
-st-default: Modal;
}

.root {
-st-extends: Modal;
display: inline-block;
}

.root::children {
border: 1px solid black;
border-radius: 5px;
background-color: lightgray;
}

.header {
border-bottom: 1px solid black;
}

.header .title {
margin-left: 5px;
}

.header button {
float: right;
margin-right: 5px;
}

.footer {
display: flex;
justify-content: space-around;
padding-bottom: 5%;
}


87 changes: 87 additions & 0 deletions src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import keycode = require('keycode');
import * as React from 'react';
import {properties, stylable} from 'wix-react-tools';
import {noop} from '../../utils';
import {Button} from '../button';
import {Modal, RequestCloseEvent} from '../modal';
import styles from './dialog.st.css';

export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
isOpen?: boolean;
onCancel?: (src: RequestCloseEvent) => void;
onOk?: () => void;
title?: string;
}

@stylable(styles)
@properties
export class Dialog extends React.PureComponent<DialogProps> {
public static defaultProps: DialogProps = {
isOpen: false,
onCancel: noop,
onOk: noop,
title: 'Dialog'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would avoid a default here

};

public render() {
return (
<Modal
className="root"
isOpen={!!this.props.isOpen}
onRequestClose={this.props.onCancel}
>
<div
data-automation-id="DIALOG_BODY"
onClick={this.onDialogBodyClick}
onKeyDown={this.handleKeyDown}
tabIndex={0}
>
<div className="header" role="header">
<span data-automation-id="DIALOG_TITLE" role="title" className="title">{this.props.title}</span>
<Button
onClick={this.props.onCancel}
role="header-close-button"
data-automation-id="DIALOG_CLOSE"
>
X
</Button>
</div>
<div className="body" role="body">
{this.props.children}
</div>
<div className="footer" role="footer">
<Button
onClick={this.props.onCancel}
role="footer-close-button"
data-automation-id="DIALOG_CANCEL"
>
Cancel
</Button>
<Button
onClick={this.props.onOk}
role="footer-primary-button"
data-automation-id="DIALOG_PRIMARY"
>
OK
</Button>
</div>
</div>
</Modal>
);
}

private handleKeyDown: React.KeyboardEventHandler<HTMLElement> = e => {
debugger;
switch (e.keyCode) {
case keycode('esc'):
const closeEvent: RequestCloseEvent = {source: 'escKeyPress'};
this.props.onCancel!(closeEvent);
}
}

private onDialogBodyClick(e: React.SyntheticEvent<HTMLElement>) {
// without this, the click on the body propagates
// to the backdrop which closes the dialog
e.stopPropagation();
}
}
1 change: 1 addition & 0 deletions src/components/dialog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dialog';
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './button';
export * from './checkbox';
export * from './context-provider';
export * from './date-picker';
export * from './dialog';
export * from './drop-down';
export * from './global-event';
export * from './image';
Expand Down
4 changes: 2 additions & 2 deletions src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {enableScrolling, stopScrolling} from '../../utils/stop-scrolling';
import {Portal} from '../portal';
import styles from './modal.st.css';

export interface RequestCloseEvent extends React.SyntheticEvent<Element> {
export interface RequestCloseEvent {
source: string;
}

Expand Down Expand Up @@ -48,7 +48,7 @@ export class Modal extends React.PureComponent<ModalProps> {
private onClick: React.EventHandler<React.SyntheticEvent<Element>> = event => {
const {target} = event;
if (isElement(target)) {
const closeEvent: RequestCloseEvent = {...event, source: this.getDataFromNearestNode(target)};
const closeEvent: RequestCloseEvent = {source: this.getDataFromNearestNode(target)};
this.props.onRequestClose!(closeEvent);
}
}
Expand Down
31 changes: 31 additions & 0 deletions test-kit/components/dialog-driver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {DriverBase} from 'test-drive-react';
import {Dialog} from '../../src';
import {ModalTestDriver} from './modal-driver';

export type DialogButtonType = 'CANCEL' | 'CLOSE' | 'PRIMARY';

export class DialogTestDriver extends DriverBase {
public static ComponentClass = Dialog;
public modalDriver: ModalTestDriver;

constructor(getDialog: () => HTMLElement) {
super(getDialog);
this.modalDriver = new ModalTestDriver(getDialog);
}

public get root(): Element {
return this.modalDriver.children[0];
}

public get title(): Element {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would expect this method to return string (the title text itself)

return this.getDialogElement('DIALOG_TITLE');
}

public getButton(type: DialogButtonType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

type

return this.getDialogElement(`DIALOG_${type}`);
}

private getDialogElement(elem: string): Element {
return this.select(this.root.getAttribute('data-automation-id')!, elem);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems to me like if you're fetching an element from the MODAL content you should rely on the modal driver to do it.

}
}
2 changes: 2 additions & 0 deletions test-kit/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export * from './checkbox-driver';
export * from './tree-view-driver';
export * from './drop-down-driver';
export * from './image-driver';
export * from './modal-driver';
export * from './portal-driver';
export * from './dialog-driver';
export * from './modal-driver';
export * from './radio-group-driver';
export * from './selection-list-driver';
Expand Down
94 changes: 94 additions & 0 deletions test/components/dialog.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import * as React from 'react';
import {ClientRenderer, DriverBase, expect, sinon, waitFor} from 'test-drive-react';
import {DialogDemo} from '../../demo/components/dialog-demo';
import {Dialog} from '../../src';
import {DialogButtonType, DialogTestDriver} from '../../test-kit/components';

const dialogButtons = [
{id: 'X', handler: 'onCancel', type: 'CLOSE'},
{id: 'CANCEL', handler: 'onCancel', type: 'CANCEL'},
{id: 'PRIMARY', handler: 'onOk', type: 'PRIMARY'}
];

class DialogDemoDriver extends DriverBase {
public static ComponentClass = DialogDemo;
public dialogDriver: DialogTestDriver;

constructor(getDialogDemo: () => HTMLElement) {
super(getDialogDemo);
this.dialogDriver = new DialogTestDriver(getDialogDemo);
}

public get dialog(): Element {
return this.dialogDriver.root;
}

public get showDialogButton(): Element {
return this.select('DIALOG_BUTTON');
}
}

describe('<Dialog />', () => {
const clientRenderer = new ClientRenderer();

afterEach(() => clientRenderer.cleanup());

it('opens the dialog upon extra button click, and closes it upon clicking any of the buttons', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does extra mean

const {driver: dialogDemo, waitForDom} =
clientRenderer
.render(<DialogDemo />)
.withDriver(DialogDemoDriver);

const showDialogBtn = dialogDemo.showDialogButton as HTMLButtonElement;
showDialogBtn.click();

const dialogDriver = dialogDemo.dialogDriver;

await waitForDom(() => expect(dialogDemo.dialog).to.be.present());

(dialogDriver.getButton('CLOSE') as HTMLButtonElement).click();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that the casting will not be required if the getButton method was typed


await waitForDom(() => expect(dialogDriver.modalDriver.root).to.be.absent());
showDialogBtn.click();

(dialogDriver.getButton('CANCEL') as HTMLButtonElement).click();

await waitForDom(() => expect(dialogDriver.modalDriver.root).to.be.absent());
showDialogBtn.click();

(dialogDriver.getButton('PRIMARY') as HTMLButtonElement).click();

await waitForDom(() => expect(dialogDriver.modalDriver.root).to.be.absent());
});

it('displays the provided title', async () => {
const testTitle = 'Do you accept this?';
const {driver: dialog, waitForDom} = clientRenderer
.render(<Dialog isOpen title={testTitle} />)
.withDriver(DialogTestDriver);

await waitForDom(() => expect(dialog.title).to.have.text(testTitle));

});

dialogButtons.forEach(button => {
it(`invokes the callback handler provided for ${button.id} button`, async () => {
const onClick = sinon.spy();

const handlerProp = {
[button.handler]: onClick
};

const {driver: dialog} = clientRenderer
.render(<Dialog isOpen {...handlerProp} />)
.withDriver(DialogTestDriver);

const getButton: Element = dialog.getButton(button.type as DialogButtonType);

(getButton as HTMLButtonElement).click();

await waitFor(() => expect(onClick).to.have.been.calledOnce);
});
});

});
2 changes: 1 addition & 1 deletion test/contracts/root-element.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {isReactComponent} from '../utils/is-react-component';

const allComponents = Object.keys(WixReactComponents);
const failingComponents = [
'Portal', 'Popup', 'Modal', 'ContextProvider', 'GlobalEvent'
'Portal', 'Popup', 'Modal', 'ContextProvider', 'GlobalEvent', 'Dialog'
];

describe('Root Element contract', () => {
Expand Down