Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Upgrade/468 input (#475)
Browse files Browse the repository at this point in the history
* update notification and input component

* update input and Notification component

* update the notification and input component
  • Loading branch information
sureshHARDIYA committed Mar 16, 2017
1 parent 932f7b3 commit 0190e78
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function loadStories() {
require('../src/stories/Button')
require('../src/stories/Dropdown')
require('../src/stories/Modal')
require('../src/stories/Notify')
require('../src/stories/Notification')
require('../src/stories/Input')
}

Expand Down
2 changes: 1 addition & 1 deletion .storybook/uikit.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// uikit-react deps
//@import "../less/select.less";

@icon-font-path: "~uikit/dist/fonts";
//@icon-font-path: "~uikit/dist/fonts";

// Storybook specific
.tm-navbar {
Expand Down
3 changes: 1 addition & 2 deletions src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const Input = ({
'uk-form-success': success,
'uk-form-width-large': width === 'large',
'uk-form-width-medium': width === 'medium',
'uk-form-width-mini': width === 'mini',
'uk-form-width-small': width === 'small',
'uk-width-1-1': width === 'full',
})
Expand Down Expand Up @@ -50,7 +49,7 @@ Input.propTypes = {
large: PropTypes.bool,
small: PropTypes.bool,
success: PropTypes.bool,
width: PropTypes.oneOf(['full', 'large', 'medium', 'small', 'mini', false]),
width: PropTypes.oneOf(['full', 'large', 'medium', 'small', false]),
}

Input.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class NotifyMesssage extends Component {
icon: PropTypes.string,
isSticky: PropTypes.bool,
timeout: PropTypes.number,
type: PropTypes.oneOf(['info', 'success', 'danger', 'warning', false]),
type: PropTypes.oneOf(['info', 'success', 'danger', 'warning', 'primary', false]),
onClick: PropTypes.func, // eslint-disable-line react/require-default-props
}

Expand Down Expand Up @@ -38,11 +38,12 @@ export default class NotifyMesssage extends Component {

render() {
const { children, type, icon, onClick } = this.props
const className = cx('uk-notify-message', {
'uk-notify-message-info': type === 'info',
'uk-notify-message-success': type === 'success',
'uk-notify-message-danger': type === 'danger',
'uk-notify-message-warning': type === 'warning',
const className = cx('uk-notification-message', {
'uk-notification-message-info': type === 'info',
'uk-notification-message-success': type === 'success',
'uk-notification-message-danger': type === 'danger',
'uk-notification-message-warning': type === 'warning',
'uk-notification-message-primary': type === 'primary',
})
const styles = [
{ marginTop: '-64px' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`NotifyMesssage should render correctly 1`] = `
<div
className="uk-notify-message"
className="uk-notification-message"
style={
Object {
"marginTop": "-64px",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Notify should render correctly 1`] = `
exports[`Notification should render correctly 1`] = `
<Portal
isOpened={true}
onClose={[Function]}
>
<div
className="uk-notify uk-notify-top-center"
className="uk-notification uk-notification-top-center"
>
<div
className="uk-notify-message uk-notify-message-warning"
className="uk-notification-message uk-notification-message-warning"
style={
Object {
"marginTop": "-64px",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import renderer from 'react-test-renderer'

import Notify from '../index'
import Notification from '../index'

jest.mock('react-portal', () => 'Portal')

describe('Notify', () => {
describe('Notification', () => {
const defaultProps = {
notifications: [{ id: 1, type: 'warning', message: 'Notification #1', icon: 'check' }],
position: 'top-center',
}
const component = renderer.create(
<Notify {...defaultProps} />
<Notification {...defaultProps} />
)
it('should render correctly', () => {
expect(component.toJSON()).toMatchSnapshot()
Expand Down
18 changes: 9 additions & 9 deletions src/Notify/index.js → src/Notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import cx from 'classnames'

import NotifyMesssage from './NotifyMesssage'

export default class Notify extends Component {
export default class Notification extends Component {
static propTypes = {
notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
position: PropTypes.string,
}

static defaultProps = {
type: 'primary',
className: 'uk-notify',
className: 'uk-notification',
position: 'top-center',
notifications: [],
}
Expand All @@ -33,13 +33,13 @@ export default class Notify extends Component {
notifications,
} = this.props

const className = cx('uk-notify', {
'uk-notify-top-center': position === 'top-center',
'uk-notify-top-left': position === 'top-left',
'uk-notify-top-right': position === 'top-right',
'uk-notify-bottom-center': position === 'bottom-center',
'uk-notify-bottom-left': position === 'bottom-left',
'uk-notify-bottom-right': position === 'bottom-right',
const className = cx('uk-notification', {
'uk-notification-top-center': position === 'top-center',
'uk-notification-top-left': position === 'top-left',
'uk-notification-top-right': position === 'top-right',
'uk-notification-bottom-center': position === 'bottom-center',
'uk-notification-bottom-left': position === 'bottom-left',
'uk-notification-bottom-right': position === 'bottom-right',
})
return (
<Portal
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/Input-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports[`Input renders correctly 11`] = `

exports[`Input renders correctly 12`] = `
<input
className="uk-input uk-form-width-mini"
className="uk-input "
/>
`;

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export Button from './Button'
export Dropdown from './Dropdown'
export Modal from './Modal'
export Notify from './Notify'
export Notification from './Notification'
export Input from './Input'
24 changes: 11 additions & 13 deletions src/stories/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,48 @@ storiesOf('Input', module)
<Input placeholder="Text input" /> &nbsp;
<Input danger defaultValue="danger" /> &nbsp;
<Input success defaultValue="success" /> &nbsp;
<Input blank placeholder="blank" />
<Input blank placeholder="blank" />&nbsp;
<Input disabled placeholder="disabled" />&nbsp;
</form>
), { header: false, inline: true, propTables: [Input], mtrcConf: { // eslint-disable-line
a: ({ href, children }) => <a href={href} target="_blank">{children}</a>, // eslint-disable-line
} })
.addWithInfo('Size modifiers', '', () => (
<form className="uk-margin-bottom uk-form">
<div className="uk-form-row">
<div className="uk-margin">
<Input large placeholder="large" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input placeholder="default" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input small placeholder="small" />
</div>
</form>
), { header: false, inline: true })
.addWithInfo('Width modifiers', '', () => (
<form className="uk-margin-bottom uk-form">
<div className="uk-form-row">
<div className="uk-margin">
<Input placeholder="full" width="full" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input placeholder="large" width="large" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input placeholder="medium" width="medium" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input placeholder="small" width="small" />
</div>
<div className="uk-form-row">
<Input placeholder="mini" width="mini" />
</div>
</form>
), { header: false, inline: true })
.addWithInfo('Form and icons', '', () => (
<form className="uk-margin-bottom uk-form">
<div className="uk-form-row">
<div className="uk-margin">
<Input icon="calendar" /> &nbsp;
<Input flip icon="clock-o" />
</div>
<div className="uk-form-row">
<div className="uk-margin">
<Input icon="spinner" /> &nbsp;
<Input flip icon="refresh" />
</div>
Expand Down
42 changes: 32 additions & 10 deletions src/stories/Notify.js → src/stories/Notification.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { storiesOf, action } from '@kadira/storybook'
import { Notify, Button } from 'uikit-react'
import { Notification, Button } from 'uikit-react'
import { PureComponent, PropTypes } from 'react'

class NotificationsContainer extends PureComponent {
Expand Down Expand Up @@ -55,25 +55,47 @@ class NotificationsContainer extends PureComponent {
{this.props.onClick ? '- click' : ''}
{this.props.timeout ? '- timeout' : ''}
</Button>
<Notify
<Notification
notifications={notifications}
position={position}
/>
</div>)
}
}

storiesOf('Notify', module)
Notification.displayName = 'Notification'

storiesOf('Notification', module)
.addWithInfo('Basic Usage', '', () => (
<div className="uk-margin-bottom">
<NotificationsContainer type="info" />
<NotificationsContainer position="bottom-center" type="warning" />
<NotificationsContainer position="top-right" type="success" />
<NotificationsContainer position="top-left" type="danger" />
<NotificationsContainer isSticky position="top-right" type="info" />
<NotificationsContainer icon="check" position="bottom-right" type="success" />
</div>
), { header: false, inline: true, propTables: [Notification] })
.addWithInfo('Position', '', () => (
<div className="uk-margin-bottom">
<NotificationsContainer position="top-left" type="info" />
<NotificationsContainer position="top-center" type="info" />
<NotificationsContainer position="top-right" type="info" />
<NotificationsContainer position="bottom-left" type="info" />
<NotificationsContainer position="bottom-center" type="info" />
<NotificationsContainer position="bottom-right" type="info" />
</div>
), { header: false, inline: true, propTables: [Notification] })
.addWithInfo('Style', '', () => (
<div className="uk-margin-bottom">
<NotificationsContainer position="bottom-center" type="info" />
<NotificationsContainer position="top-left" type="primary" />
<NotificationsContainer position="top-center" type="success" />
<NotificationsContainer position="top-right" type="warning" />
<NotificationsContainer position="bottom-left" type="danger" />
</div>
), { header: false, inline: true, propTables: [Notification] })
.addWithInfo('Component options', '', () => (
<div className="uk-margin-bottom">
<NotificationsContainer icon="warning" position="bottom-left" timeout={10000} type="warning" />
<NotificationsContainer icon="warning" position="top-right" timeout={5000} type="danger" onClick={action('handleClick')} />

<NotificationsContainer position="top-center" type="success" />
<NotificationsContainer position="top-right" type="warning" />
<NotificationsContainer icon="danger" position="top-left" type="danger" />
</div>
), { header: false, inline: true, propTables: [Notify] })
), { header: false, inline: true, propTables: [Notification] })

0 comments on commit 0190e78

Please sign in to comment.