Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Input): update to v1 API #281

Merged
merged 25 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
74a9a24
Input Component updated to v1 API
jhchill666 Jun 24, 2016
1bcd072
fix(Input): fix props references
levithomason Sep 19, 2016
2813a04
refactor(docs): update Input docs to v1 files
levithomason Sep 19, 2016
0081a82
fix(docs): fix input variations typo
levithomason Sep 19, 2016
a2d4a59
refactor(docs): go stateless and rename Input docs
levithomason Sep 20, 2016
486d669
fix(Sidebar): remove input ref
levithomason Sep 20, 2016
5e05f31
docs(Input): update examples to v1 API
levithomason Sep 20, 2016
b011e82
feat(Input): update states to v1 API
levithomason Sep 20, 2016
6bf626d
feat(Input): add v1 icon support
levithomason Sep 21, 2016
952b52d
feat(Input): add labeled support
levithomason Sep 22, 2016
b064979
feat(Input): support labeled inputs
levithomason Sep 23, 2016
da1c0e1
feat(Input): begin labeled and action variations
levithomason Sep 27, 2016
fe63039
fix(docs): cleanup example layout
levithomason Sep 27, 2016
b37952c
feat(Dropdown): add missing `basic` prop
levithomason Sep 27, 2016
5f4c7db
test(Dropdown): add missing className tests
levithomason Sep 27, 2016
029dab7
feat(Input): support action inputs
levithomason Sep 27, 2016
1fedf9b
test(Input): add v1 API tests
levithomason Sep 27, 2016
15f89ce
docs(Input): add icon child example
levithomason Sep 27, 2016
adac980
feat(factories): allow deafultProps function
levithomason Sep 27, 2016
5478c62
refactor(common): complete Input todos
levithomason Sep 27, 2016
fe327fc
fix(docs): fix linter issues
levithomason Sep 27, 2016
59403ea
fix(BreadcrumbDivider-test): restore to original
levithomason Sep 27, 2016
72bf71d
fix(FormField): do not pass label to all controls
levithomason Sep 27, 2016
af405e9
refactor(ExampleSection): restore header style
levithomason Sep 28, 2016
e27f533
refactor(factories): add defaultProps object default
levithomason Sep 28, 2016
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
31 changes: 22 additions & 9 deletions docs/app/Components/ComponentDoc/ComponentExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ const showCodeStyle = {
right: '1rem',
}

const descriptionStyle = {
marginRight: '5em',
}

const codeIconStyle = {
fontWeight: 'bold',
}

const titleStyle = {
marginBottom: 0,
margin: 0,
}

const headerColumnStyle = {
// provide room for absolutely positions toggle code icons
minHeight: '4em',
paddingRight: '7em',
}

const childrenStyle = {
paddingTop: 0,
}

const renderedExampleStyle = {
paddingTop: 0,
paddingBottom: 0,
}

/**
Expand Down Expand Up @@ -109,6 +115,8 @@ export default class ComponentExample extends Component {
return (
<Grid style={style} divided={active} columns='1'>
<Grid.Column style={headerColumnStyle}>
{title && <Header as='h3' style={titleStyle}>{title}</Header>}
{description && <p>{description}</p>}
<div style={showCodeStyle}>
<Icon
link
Expand All @@ -126,11 +134,16 @@ export default class ComponentExample extends Component {
onClick={this.toggleShowHTML}
/>
</div>
{title && <Header as='h3' style={titleStyle}>{title}</Header>}
{description && <p style={descriptionStyle}>{description}</p>}
{children}
</Grid.Column>
<Grid.Column className={`rendered-example ${this.getKebabExamplePath()}`}>
{children && (
<Grid.Column style={childrenStyle}>
{children}
</Grid.Column>
)}
<Grid.Column
className={`rendered-example ${this.getKebabExamplePath()}`}
style={renderedExampleStyle}
>
{createElement(this.component, rest)}
</Grid.Column>
{showCode && this.renderCode()}
Expand Down
3 changes: 1 addition & 2 deletions docs/app/Components/ComponentDoc/ExampleSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import React, { PropTypes } from 'react'

import { Grid, Header } from 'src'

const headerStyle = { marginBottom: '1.5em' }
const sectionStyle = { background: '#fff', boxShadow: '0 2px 2px rgba(0, 0, 0, 0.1)' }

const ExampleSection = ({ title, children }) => (
<Grid padded style={sectionStyle}>
<Grid.Column>
<Header as='h2' style={headerStyle}>
<Header as='h2'>
{title}
</Header>
{children}
Expand Down
12 changes: 9 additions & 3 deletions docs/app/Components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,21 @@ export default class Sidebar extends Component {

componentDidMount() {
document.addEventListener('keydown', this.handleDocumentKeyDown)
this.setSearchInput()
}

componentDidUpdate(prevProps, prevState) {
this.setSearchInput()
}

componentWillUnmount() {
document.removeEventListener('keydown', this.handleDocumentKeyDown)
}

setSearchInput() {
this._searchInput = findDOMNode(this).querySelector('.ui.input input')
Copy link
Member

Choose a reason for hiding this comment

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

Input is now a stateless component, so no refs are available. Updated the doc sidebar to use a regular query selector instead.

}

handleDocumentKeyDown = (e) => {
const code = keyboardKey.getCode(e)
const isAZ = code >= 65 && code <= 90
Expand Down Expand Up @@ -197,9 +206,6 @@ export default class Sidebar extends Component {
value={query}
onChange={this.handleSearchChange}
onKeyDown={this.handleSearchKeyDown}
ref={(c) => {
if (c !== null) this._searchInput = findDOMNode(c).querySelector('input')
}}
/>
</div>
{query ? this.renderSearchItems() : this.menuItemsByType}
Expand Down
16 changes: 0 additions & 16 deletions docs/app/Examples/elements/Input/InputExamples.js

This file was deleted.

8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/States/InputDisabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputDisabled = () => (
<Input disabled placeholder='Search...' />
)

export default InputDisabled
10 changes: 0 additions & 10 deletions docs/app/Examples/elements/Input/States/InputDisabledExample.js

This file was deleted.

8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/States/InputError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputError = () => (
<Input error placeholder='Search...' />
)

export default InputError
10 changes: 0 additions & 10 deletions docs/app/Examples/elements/Input/States/InputErrorExample.js

This file was deleted.

8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/States/InputFocus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputFocus = () => (
<Input focus placeholder='Search...' />
)

export default InputFocus
10 changes: 0 additions & 10 deletions docs/app/Examples/elements/Input/States/InputFocusExample.js

This file was deleted.

8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/States/InputLeftLoading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputLeftLoading = () => (
<Input loading icon='user' iconPosition='left' placeholder='Search...' />
)

export default InputLeftLoading
8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/States/InputLoading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputLoading = () => (
<Input loading icon='user' placeholder='Search...' />
)

export default InputLoading
10 changes: 0 additions & 10 deletions docs/app/Examples/elements/Input/States/InputLoadingExample.js

This file was deleted.

33 changes: 0 additions & 33 deletions docs/app/Examples/elements/Input/States/InputStatesExamples.js

This file was deleted.

37 changes: 37 additions & 0 deletions docs/app/Examples/elements/Input/States/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

import { Message } from 'src'

const InputStates = () => (
Copy link
Member

Choose a reason for hiding this comment

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

Var name might be States

Copy link
Member

Choose a reason for hiding this comment

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

In order to aide in searching, let's always keep the component name in the default export name. Let's also keep the filename the same as the default export (except for index.js files of course).

This way the default export matches the filename and we can easily search for either. This makes automated refactors much easier to work with. Once we're done with the legacy components I plan to update all doc files to be consistent.

<ExampleSection title='States'>
<ComponentExample
title='Focus'
description='An input field can show a user is currently interacting with it'
examplePath='elements/Input/States/InputFocus'
/>
<ComponentExample
title='Loading'
description='An icon input field can show that it is currently loading data'
examplePath='elements/Input/States/InputLoading'
>
<Message>
Loading inputs automatically modify the input's icon on loading state to show loading indication
</Message>
</ComponentExample>
<ComponentExample examplePath='elements/Input/States/InputLeftLoading' />
<ComponentExample
title='Disabled'
description='An input field can show that it is disabled'
examplePath='elements/Input/States/InputDisabled'
/>
<ComponentExample
title='Error'
description='An input field can show that the data contains errors'
examplePath='elements/Input/States/InputError'
/>
</ExampleSection>
)

export default InputStates
8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/Types/InputInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputInput = () => (
<Input placeholder='Search...' />
)

export default InputInput
10 changes: 0 additions & 10 deletions docs/app/Examples/elements/Input/Types/InputInputExample.js

This file was deleted.

17 changes: 0 additions & 17 deletions docs/app/Examples/elements/Input/Types/InputTypesExamples.js

This file was deleted.

15 changes: 15 additions & 0 deletions docs/app/Examples/elements/Input/Types/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

const InputTypes = () => (
Copy link
Member

Choose a reason for hiding this comment

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

^^

<ExampleSection title='Types'>
<ComponentExample
title='Input'
description='A standard input field'
examplePath='elements/Input/Types/InputInput'
/>
</ExampleSection>
)

export default InputTypes
8 changes: 8 additions & 0 deletions docs/app/Examples/elements/Input/Variations/InputAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Input } from 'stardust'

const InputAction = () => (
<Input action='Search' placeholder='Search...' />
)

export default InputAction
19 changes: 19 additions & 0 deletions docs/app/Examples/elements/Input/Variations/InputActionDropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import { Dropdown, Input } from 'stardust'

const options = [
{ text: 'This Page', value: 'page' },
{ text: 'This Organization', value: 'org' },
{ text: 'Entire Site', value: 'site' },
]

const InputActionDropdown = () => (
<Input
action={<Dropdown basic floating options={options} defaultValue='page' />}
icon='search'
iconPosition='left'
placeholder='Search...'
/>
)

export default InputActionDropdown
18 changes: 0 additions & 18 deletions docs/app/Examples/elements/Input/Variations/InputActionExample.js

This file was deleted.

Loading