diff --git a/README.md b/README.md index ece398f..f14daf6 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,95 @@ Default themes: **primary**, **success**, **warning**, **alert** ![rangeslider_ios](https://cloud.githubusercontent.com/assets/1177226/22095658/437ef7d6-de49-11e6-8fdc-c83154033438.gif) ![rangeslider_android](https://cloud.githubusercontent.com/assets/1177226/22095661/459f58c6-de49-11e6-9f74-b013ac5a6315.gif) +### `` +Expand component + +#### Expand Props +| Name | Desc | Type | Default +| --- | --- | --- | --- | +| `title` | Always visible. | String | `-` +| `description` | In close state cropped to one line. | String | `-` +| `defaultExpanded` | Default state of component. If it true component will be rendered in open state | Bool | `false` +| `icon` | Disclosure indicator for close state \n `name` - icon name for [FontAwesome](http://fontawesome.io/icons/) | Object | `{ name: 'chevron-down', color: ThemeConstants.LIGHT_GRAY, size: 12 }` +| `expandedIcon` | Disclosure indicator for close state \n `name` - icon name for [FontAwesome](http://fontawesome.io/icons/) | Object | `{ name: 'chevron-up', color: ThemeConstants.LIGHT_GRAY, size: 12 }` +| `children` | Child element will be shown only in open state | Node | `-` + +#### Example +```js +import { Expand } from 'tipsi-ui-kit' + + +``` +Theme structure: + +```js +{ + container: , + titleWrapper: , + descriptionWrapper: , + childrenWrapper: , + titleText: , + descriptionText: , +} +``` +#### Preview + +![expand_ios](https://cloud.githubusercontent.com/assets/1177226/22414883/ce4aa522-e6f5-11e6-9da7-57dcece51376.gif) +![expand_android](https://cloud.githubusercontent.com/assets/1177226/22414884/d052c7f0-e6f5-11e6-8d36-ca210932b683.gif) + +### `` +Search component + +#### Search Props +| Name | Desc | Type | Default +| --- | --- | --- | --- | +| `value`| Text input value | String | - | +| `suggestions`| Array of suggestions. If not empty will be render as list | Array | [] | +| `beforeSuggestionsRenderer`| Child element will be shown before suggestions | Node | - | +| `afterSuggestionsRenderer`| Child element will be shown after suggestions | Node | - | +| `onClear`| Call when tap on clear button | Function | - | +| `onRowClick`| Call when select suggestion | Function | - | +| `endEditing`| Call when end editing TextInput | Function | - | +| `clearButtonMode`| When show clean button. Can be one of `'never', 'while-editing', 'unless-editing', 'always'` | String | `always` | +| `highlightColor`| Suggestion row highlighting color | String | `ThemeConstants.LIGHT_GRAY` | +| `clearButtonStyle`| Style for clean button, should contain size and color | Object | `{ size: 20, color: ThemeConstants.LIGHT_GRAY }`| +| `...rest` | All other props for `TextInput` component | - | - | - | + + +#### Example +```js +import { Search } from 'tipsi-ui-kit' + + {setState({ value: text })}} + onClear={() => {setState({ value: '' })}} + clearButtonMode='while-editing' +/> +``` +Theme structure: + +```js +{ + container: , + textIputWrapper: , + textInput: , + clearButtonWrapper: , + separator: , + scrollView: , + row: , + suggestionText: , +} +``` +#### Preview +![search_ios](https://cloud.githubusercontent.com/assets/370694/22469461/c7a7db9c-e7d4-11e6-8c1e-281fd274afa7.gif) +![search_android](https://cloud.githubusercontent.com/assets/370694/22469459/c706e110-e7d4-11e6-911a-dcdf8ad8fcef.gif) + + ## Utils ### ThemeRegister diff --git a/__tests__/e2e/09_Expand.test.js b/__tests__/e2e/09_Expand.test.js new file mode 100644 index 0000000..1078b3b --- /dev/null +++ b/__tests__/e2e/09_Expand.test.js @@ -0,0 +1,47 @@ +import test from 'tape-async' +import helper from 'tipsi-appium-helper' + +const { driver, select, idFromXPath } = helper + +test('', async (t) => { + const expandGroupId = select({ + ios: idFromXPath(`// + XCUIElementTypeApplication/XCUIElementTypeWindow/XCUIElementTypeOther/ + XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther[2]/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther + `), + android: idFromXPath(`// + android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/ + android.widget.FrameLayout[1]/android.view.ViewGroup[1]/ + android.view.ViewGroup[2]/android.view.ViewGroup[1]/android.widget.ScrollView[1] + `), + }) + const expandItemId = select({ + ios: idFromXPath(`${expandGroupId}/XCUIElementTypeOther[2]/XCUIElementTypeOther`), + android: idFromXPath(` + ${expandGroupId}/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[2] + `), + }) + + try { + await helper.openExampleFor('', 60000) + await driver.waitForVisible(expandItemId, 10000) + t.pass(' example should be visible') + + const height = await driver.getElementSize(expandItemId, 'height') + await driver.click(expandItemId) + t.pass('Can click on first expand item') + const expandedHeight = await driver.getElementSize(expandItemId, 'height') + t.notEqual( + height, + expandedHeight, + 'Height of the element should be changed after the click' + ) + } catch (error) { + await helper.screenshot() + await helper.source() + + throw error + } +}) diff --git a/__tests__/e2e/12_Search.test.js b/__tests__/e2e/12_Search.test.js new file mode 100644 index 0000000..39ae852 --- /dev/null +++ b/__tests__/e2e/12_Search.test.js @@ -0,0 +1,57 @@ +import test from 'tape-async' +import helper from 'tipsi-appium-helper' + +const { driver, select, idFromXPath } = helper + +test('', async (t) => { + const textInputId = select({ + ios: idFromXPath(`// + XCUIElementTypeApplication/XCUIElementTypeWindow/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2] + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeScrollView/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther[2] + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTextField + `), + android: idFromXPath(`// + android.widget.LinearLayout[1]/android.widget.FrameLayout[1] + /android.widget.FrameLayout[1]/android.view.ViewGroup[1] + /android.view.ViewGroup[2]/android.view.ViewGroup[1] + /android.widget.ScrollView[1]/android.view.ViewGroup[1] + /android.view.ViewGroup[1]/android.widget.EditText[1] + `), + }) + const suggestionsId = select({ + ios: idFromXPath(`// + XCUIElementTypeApplication/XCUIElementTypeWindow/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[2] + /XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther + /XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther[3]`), + android: idFromXPath(`// + android.widget.LinearLayout[1]/android.widget.FrameLayout[1] + /android.widget.FrameLayout[1]/android.view.ViewGroup[1] + /android.view.ViewGroup[2]/android.view.ViewGroup[1] + /android.widget.ScrollView[1]/android.view.ViewGroup[1] + /android.view.ViewGroup[1]/android.view.ViewGroup[7]/android.widget.ScrollView[1] + `), + }) + + try { + await helper.openExampleFor('', 60000) + await driver.waitForVisible(textInputId, 30000) + t.pass(' example should be visible') + await driver.click(textInputId) + t.pass('Search field should be editable') + await driver.keys('Bl') + await driver.waitForVisible(suggestionsId, 30000) + t.pass('User should see suggestions') + } catch (error) { + await helper.screenshot() + await helper.source() + + throw error + } +}) diff --git a/__tests__/unit/__snapshots__/Storyshots.test.js.snap b/__tests__/unit/__snapshots__/Storyshots.test.js.snap index 31f8c0b..21bd0a6 100644 --- a/__tests__/unit/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/unit/__snapshots__/Storyshots.test.js.snap @@ -3684,6 +3684,413 @@ exports[`UIExplorer components Thickness of each dash - Prop: dashThick style={undefined} /> `; +exports[`UIExplorer components Children - Also you can pass your own component as children. 1`] = ` + + + + + WHAT TYPE OF WINES DO YOU PREFER? + + +  + + + + +`; + +exports[`UIExplorer components Default Expanded - Prop: defaultExpanded (Bool) 1`] = ` + + + + + Winemakers Notes: + + +  + + + + + The 2012 vintage in Napa Valley was about as close to ‘normal’ as it gets! Average rainfall ended with a nearly ideal budbreak, flowering and fruit set. The frost season was mild and while the harvest was a bit slow to start, it was beautifully abundant. We carefully harvest our Muscat block twice to get the best for both wines that we made this vintage. In September, we harvested clusters inside the canopy. These early clusters retained their bright acidity and classic Muscat character in a slightly sweet, low alcohol wine perfect for interesting food pairings. + + + + +`; + +exports[`UIExplorer components Other - View, Text and Image componants as children. 1`] = ` + + + + + Region: + + +  + + + + + Napa Valley + + + + +`; + +exports[`UIExplorer components Title and Description - Prop: title (String), description (String) 1`] = ` + + + + + Winemakers Notes: + + +  + + + + + The 2012 vintage in Napa Valley was about as close to ‘normal’ as it gets! Average rainfall ended with a nearly ideal budbreak, flowering and fruit set. The frost season was mild and while the harvest was a bit slow to start, it was beautifully abundant. We carefully harvest our Muscat block twice to get the best for both wines that we made this vintage. In September, we harvested clusters inside the canopy. These early clusters retained their bright acidity and classic Muscat character in a slightly sweet, low alcohol wine perfect for interesting food pairings. + + + + +`; + exports[`UIExplorer components