Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

<FileTabs /> #8

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

<FileTabs /> #8

wants to merge 38 commits into from

Conversation

itsmepetrov
Copy link
Contributor

No description provided.

@itsmepetrov itsmepetrov requested a review from isnifer January 17, 2017 16:13
render() {
const {
color,
name,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add active prop here

Copy link
Contributor

Choose a reason for hiding this comment

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

done

this.props.active ? styles.tabContainerActive : styles.tabContainer,
{ backgroundColor: color },
]}>
<Text style={styles.text}>{name.toUpperCase()}</Text>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove forced toUpperCase

{Children.map(this.props.children.filter(c => c), child => (
child.props.id === this.state.selected ?
cloneElement(child, { active: true, onPress: this.handleTabPress }) :
cloneElement(child, { active: false, onPress: this.handleTabPress })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewrite like:

{Children.map(children, child => cloneElement(child, {
  active: child.props.id === this.state.selected,
  onPress: this.handleTabPress
}))}


static Item = Item

constructor(props) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use class properties for initial state instead of constructor:

class Example {
  state = { value: 10 }
}

}

const styles = StyleSheet.create({
tabContainer: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rename to container

alignItems: 'center',
height: 40,
},
tabContainerActive: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rename to active

onPress={this.handlePress}>
<View
style={[
active ? styles.tabContainerActive : styles.tabContainer,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

move container styles logic to render body:

const containerStyles = [
  styles.container,
  { backgroundColor: color },
  active && styles.active
]


static defaultProps = {
active: false,
onPess: () => (console.log('onPess')),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove console.log


export default class Item extends Component {
static propTypes = {
id: PropTypes.string,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make required

id: PropTypes.string,
active: PropTypes.bool,
color: PropTypes.string,
name: PropTypes.string,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same

active: PropTypes.bool,
color: PropTypes.string,
name: PropTypes.string,
onPress: PropTypes.func,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same

Copy link
Contributor

Choose a reason for hiding this comment

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

The same as with "active" - we don't pas "onPress" to every item. So, if we make it required and pass single onPress to entire component, we have warning.

import React, { Component, PropTypes } from 'react'
import { View, Text, TouchableWithoutFeedback, StyleSheet } from 'react-native'

export default class Item extends Component {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change name to ColoredTabsItem

render() {
return (
<View style={styles.container}>
<View style={styles.tabContainer}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we really need this View wrapper?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can get rid it.

justifyContent: 'center',
alignItems: 'center',
},
tabContainer: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

change name to wrapper

@itsmepetrov
Copy link
Contributor Author

Blocked by #4

@itsmepetrov itsmepetrov changed the title [WIP] <ColoredTabs /> <ColoredTabs /> Jan 18, 2017
@itsmepetrov
Copy link
Contributor Author

@fAns1k please rebase

@itsmepetrov
Copy link
Contributor Author

Rename to FileTabs, make text font size larger and bold, add more examples.

<ColoredTabs.Item id="1" name="Two" color="orange" />
<ColoredTabs.Item id="2" name="Three" color="chartreuse" />
<ColoredTabs.Item id="3" name="Four" color="dodgerblue" />
< /ColoredTabs>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove empty space


| Name | Desc | Type | Default
| --- | --- | --- | --- |
| `name` | Text of tab. | String | `undefined`
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if you rename this prop into title like in other components // @itsmepetrov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree

@itsmepetrov itsmepetrov changed the title <ColoredTabs /> <FileTabs /> Jan 24, 2017
dmitriy and others added 20 commits January 24, 2017 14:10
* Implemented Carousel component

* Implemented Carousel tests

* Updated tests for Carousel, some fixes in openExamplesFor method

* Updated e2e tests

* Updated e2e tests

* Updated e2e tests

* Updated e2e tests

* Added Dash component

* Added info about Carousel component n README.md

* Updated info about Carousel component in README.md

* Added info about Dash component in README.md

* Updated Carousel.Item component

* Updated unit tests

* Updated openExamplesFor tests
| Name | Desc | Type | Default
| --- | --- | --- | --- |
| `selected` | id of selected tab. | String | `undefined`
| `onPress` | Handle press on tab action. Receive id of selected tab as argument. | Function | `undefined`
Copy link
Contributor

Choose a reason for hiding this comment

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

this function has default value () => {}

| `color` | Color of tab | String | `undefined`
| `id` | Tab id. This id will passed to `onPress` for identify action. | String | `undefined`
| `active` | Show item as active | Boolean | `false`
| `onPress` | Handle press action | Function | `undefined`
Copy link
Contributor

Choose a reason for hiding this comment

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

this function has default value () => {}

<ColoredTabs.Item id="2" name="Three" color="chartreuse" />
<ColoredTabs.Item id="3" name="Four" color="dodgerblue" />
< /ColoredTabs>
)
Copy link
Contributor

Choose a reason for hiding this comment

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

your example is not working, rewrite like this:

import React, { PureComponent } from 'react'
import { ColoredTabs } from 'tipsi-ui-kit'

class Example extends PureComponent {
  handlePress = id => console.log(`Tab with id ${id} is clicked!`)

  const Example = () => (
    <ColoredTabs onPress={this.handlePress}>
      <ColoredTabs.Item id="0" title="One" color="crimson" />
      <ColoredTabs.Item id="1" title="Two" color="orange" />
      <ColoredTabs.Item id="2" title="Three" color="chartreuse" />
      <ColoredTabs.Item id="3" title="Four" color="dodgerblue" />
    </ColoredTabs>
  )
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Also please check eslint-plugin in your editor. We use 2 spaces as tab length

container: { backgroundColor: ThemeConstants.BLACK },
})

export default themeable('Label', baseStyles, {
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs, not Label

- when 'selected' does not defined - set first tab, as selected.
@@ -3,6 +3,52 @@ React Native Tipsi custom UI elements

## Components

### `<ColoredTabs />`
Copy link
Contributor

Choose a reason for hiding this comment

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

No description provided.


Customizable colored tabs.

#### ColoredTabs Props
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs

| `onPress` | Handle press on tab action. Receive id of selected tab as argument. | Function | `undefined`


#### ColoredTabs.Item Props
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs


```js
import React from 'react'
import { ColoredTabs } from 'tipsi-ui-kit'
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs

handlePress = (id) => (console.log(`Tab with id ${id} is clicked!`)

const Example = () => (
<ColoredTabs onPress={this.handlePress}>
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs


const Example = () => (
<ColoredTabs onPress={this.handlePress}>
<ColoredTabs.Item id="0" name="One" color="crimson" />
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs


```js
import React, { PureComponent } from 'react'
import { ColoredTabs } from 'tipsi-ui-kit'
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs

<ColoredTabs.Item id="1" title="Two" color="orange" />
<ColoredTabs.Item id="2" title="Three" color="chartreuse" />
<ColoredTabs.Item id="3" title="Four" color="dodgerblue" />
</ColoredTabs>
Copy link
Contributor

Choose a reason for hiding this comment

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

FileTabs

@itsmepetrov
Copy link
Contributor Author

Please rebase

@isnifer
Copy link
Contributor

isnifer commented Feb 14, 2017

Also, don't forget check my messages too :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants