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

Commit

Permalink
Merge branch 'master' into checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
fox1t authored Oct 14, 2019
2 parents cc73115 + b9f48ae commit 7340739
Show file tree
Hide file tree
Showing 17 changed files with 1,031 additions and 9 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# [0.9.0](https://github.com/HospitalRun/components/compare/v0.8.0...v0.9.0) (2019-10-14)


### Bug Fixes

* **navbar:** changed the code to be more dynamically ([753c6c4](https://github.com/HospitalRun/components/commit/753c6c4))
* **navbar:** code modified ([c23b339](https://github.com/HospitalRun/components/commit/c23b339))


### Features

* **navbar:** add Navbar component ([3190238](https://github.com/HospitalRun/components/commit/3190238))
* **navbar:** adds unit test ([2e46f90](https://github.com/HospitalRun/components/commit/2e46f90))

# [0.8.0](https://github.com/HospitalRun/components/compare/v0.7.0...v0.8.0) (2019-10-13)


### Features

* **radios:** adds radio component ([2e91b6a](https://github.com/HospitalRun/components/commit/2e91b6a)), closes [#63](https://github.com/HospitalRun/components/issues/63)

# [0.7.0](https://github.com/HospitalRun/components/compare/v0.6.0...v0.7.0) (2019-10-13)


### Features

* **textinput:** adds TextInput component ([b2200bb](https://github.com/HospitalRun/components/commit/b2200bb)), closes [#20](https://github.com/HospitalRun/components/issues/20)

# [0.6.0](https://github.com/HospitalRun/components/compare/v0.5.0...v0.6.0) (2019-10-12)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![NPM Version](https://badgen.net/npm/v/@hospitalrun/components)](https://www.npmjs.com/package/@hospitalrun/components) [![Build Status](https://travis-ci.com/HospitalRun/components.svg?branch=master)](https://travis-ci.com/HospitalRun/components)
[![Build Status](https://dev.azure.com/HospitalRun/components/_apis/build/status/HospitalRun.components?branchName=master)](https://dev.azure.com/HospitalRun/components/_build?definitionId=1) [![GitHub CI](https://github.com/HospitalRun/components/workflows/GitHub%20CI/badge.svg)](https://github.com/HospitalRun/components/actions) [![Coverage Status](https://coveralls.io/repos/github/HospitalRun/components/badge.svg?branch=master)](https://coveralls.io/github/HospitalRun/components?branch=master)
[![Bundlephobia](https://badgen.net/bundlephobia/min/@hospitalrun/components)](https://bundlephobia.com/result?p=@hospitalrun/components)
[![dependabot](https://badgen.net/dependabot/dependabot/dependabot-core/?icon=dependabot)](https://github.com/HospitalRun/components) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![MIT](https://badgen.net/github/license/HospitalRun/components)](https://github.com/HospitalRun/components/blob/master/LICENSE)
![dependabot](https://api.dependabot.com/badges/status?host=github&repo=HospitalRun/components) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![MIT](https://badgen.net/github/license/HospitalRun/components)](https://github.com/HospitalRun/components/blob/master/LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Slack](https://hospitalrun-slackin.herokuapp.com/badge.svg)](https://hospitalrun-slackin.herokuapp.com) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/hospitalrun) [![Netlify Status](https://api.netlify.com/api/v1/badges/70c843de-c1b2-4e7d-abb5-61939f21f8cb/deploy-status)](https://app.netlify.com/sites/hospitalrun/deploys)

</div>
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hospitalrun/components",
"version": "0.6.0",
"version": "0.9.0",
"license": "MIT",
"main": "dist",
"module": "dist/components.esm.js",
Expand Down Expand Up @@ -61,14 +61,14 @@
},
"devDependencies": {
"@babel/core": "~7.5.5",
"@commitlint/cli": "~8.1.0",
"@commitlint/cli": "~8.2.0",
"@commitlint/config-conventional": "~8.2.0",
"@commitlint/prompt": "~8.2.0",
"@semantic-release/changelog": "~3.0.4",
"@semantic-release/commit-analyzer": "~6.3.0",
"@semantic-release/git": "~7.0.16",
"@semantic-release/github": "~5.4.3",
"@semantic-release/npm": "~5.1.15",
"@semantic-release/github": "~5.5.3",
"@semantic-release/npm": "~5.2.0",
"@semantic-release/release-notes-generator": "~7.3.0",
"@storybook/addon-actions": "~5.1.11",
"@storybook/addon-info": "~5.1.11",
Expand All @@ -80,7 +80,7 @@
"@types/enzyme": "~3.10.3",
"@types/jest": "~24.0.17",
"@types/react": "~16.9.1",
"@types/react-dom": "~16.8.5",
"@types/react-dom": "~16.9.1",
"@types/sinon": "~7.0.13",
"@types/storybook__addon-info": "~4.1.2",
"@types/storybook__react": "~4.0.2",
Expand All @@ -100,16 +100,16 @@
"jest-canvas-mock": "~2.1.1",
"lint-staged": "~9.2.5",
"prettier": "~1.18.2",
"react": "~16.9.0",
"react": "~16.10.2",
"react-bootstrap": "~1.0.0-beta.11",
"react-docgen": "~5.0.0-beta.1",
"react-docgen-typescript-loader": "~3.2.0",
"react-dom": "~16.9.0",
"react-dom": "~16.10.2",
"semantic-release": "~15.13.24",
"sinon": "~7.5.0",
"tsdx": "~0.9.0",
"tslib": "~1.10.0",
"typescript": "~3.5.3"
"typescript": "~3.6.4"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "~1.2.25",
Expand Down
120 changes: 120 additions & 0 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React, { Component } from 'react'
import NavbarRB from 'react-bootstrap/Navbar'
import Nav from 'react-bootstrap/Nav'
import Form from 'react-bootstrap/Form'
import FormControl, { FormControlProps } from 'react-bootstrap/FormControl'
import NavDropdown from 'react-bootstrap/NavDropdown'
import { ReplaceProps, BsPrefixProps } from 'react-bootstrap/helpers'

import { Button } from '../../../src'
import { NavLink, Brand } from './interfaces'

interface Props extends React.Props<any> {
/** Determines the navbar background color */
bg?: string
/** Determines the letters color. It should be combined with the background color (bg) */
variant?: 'light' | 'dark'
/** Determines the links names, theirs onClick methods and paths. It has children array which contain links to be used on a dropdown. */
navLinks: NavLink[]
/** Determines the hospital/clinic name to be shown at the navbar */
brand: Brand
/** Defines the button variant. By default is primary */
buttonColor?:
| 'primary'
| 'secondary'
| 'success'
| 'warning'
| 'danger'
| 'info'
| 'light'
| 'dark'
/** Handles the on click search button event */
onSeachButtonClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
/** Handles the on change search form event */
onSearchTextBoxChange: (
event: React.FormEvent<ReplaceProps<'input', BsPrefixProps<'input'> & FormControlProps>>,
) => void
}

/**
* Used to redirect users to the main topics.
*/
class Navbar extends Component<Props, any> {
render() {
const buttonColor = this.props.buttonColor ? this.props.buttonColor : 'primary'
let img

if (this.props.brand.src) {
img = (
<img
src={this.props.brand.src}
width="28"
height="28"
className="d-inline-block align-top"
/>
)
} else {
img = ''
}

return (
<NavbarRB
bg={this.props.bg ? this.props.bg : 'dark'}
variant={this.props.variant ? this.props.variant : 'dark'}
>
{/* <NavbarRB.Brand href={this.props.brand.href}> if this method is used, onClick: (event: React.MouseEvent<HTMLElement>) => void on the interface
<div onClick={this.props.brand.onClick.bind(this)} >
{img}
{` ${this.props.brand.label}`}
</div>
</NavbarRB.Brand> */}

<NavbarRB.Brand href={this.props.brand.href} onClick={this.props.brand.onClick.bind(this)}>
{img}
{` ${this.props.brand.label}`}
</NavbarRB.Brand>

<NavbarRB.Collapse id="responsive-navbar-nav">
<Nav className="mr-auto">
{this.props.navLinks.map((link, index) => {
return link.children.length == 0 ? (
<Nav.Link onClick={link.onClick} key={index}>
{link.label}
</Nav.Link>
) : (
<NavDropdown title={link.label} id="collasible-nav-dropdown" key={index}>
{link.children.map((subLink, i) => {
return (
<NavDropdown.Item
href={subLink.href ? subLink.href : ''}
key={i}
onClick={subLink.onClick}
>
{subLink.label}
</NavDropdown.Item>
)
})}
</NavDropdown>
)
})}
</Nav>
<Nav>
<Form inline>
<FormControl
type="text"
placeholder="Search"
className="mr-sm-2"
onChange={this.props.onSearchTextBoxChange}
/>
<Button color={buttonColor} onClick={this.props.onSeachButtonClick}>
Search
</Button>
</Form>
</Nav>
</NavbarRB.Collapse>
</NavbarRB>
)
}
}

export { Navbar }
1 change: 1 addition & 0 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Navbar'
24 changes: 24 additions & 0 deletions src/components/Navbar/interfaces.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface Brand {
/** Clinic/Hospital name */
label: string
/** Determina the href */
href?: string
/** A path which contain the company icon/image */
src?: string
/** A click handle which will redirect the user to the respectivel webpage/path */
onClick: (event: React.MouseEvent<any>) => void
}

export interface NavLinkElement {
/** The link name */
label: string
/** A click handle which will redirect the user to whenever it is clicked */
onClick: (event: React.MouseEvent<any>) => void
/** Determina the href */
href?: string
}

export interface NavLink extends NavLinkElement {
/** An array to hold a dropdown Links */
children: NavLinkElement[]
}
51 changes: 51 additions & 0 deletions src/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { ReactNode, Component } from 'react'
import { FormCheck } from 'react-bootstrap'

interface Props {
/** Label to display next to the Radio. */
label?: string | ReactNode
/** Necessary to link the label with the input. */
id?: string
/** Name to group Radios together. Two Radios with the same name can't be checked at the same time. */
name?: string
/** Value associated with the Radio. */
value?: string
/** When inline, Radio elements are stacked horizontally instead of vertically. Default is false. */
inline?: boolean
/** When disabled, the Radio cannot be clicked or changed by the user. Default is false. */
disabled?: boolean
/** When checked is true, the Radio button is selected. */
checked?: boolean
/** Determines whether the Radio should be rendered as invalid or not. Default is false. */
isInvalid?: boolean
/** Message to display when the Radio is invalid. */
feedback?: string | ReactNode
/** Listener will be called when the Radio is checked. */
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
}

class Radio extends Component<Props, {}> {
constructor(props: Props) {
super(props)
}

render() {
return (
<FormCheck
type="radio"
label={this.props.label}
name={this.props.name}
id={this.props.id}
value={this.props.value}
checked={this.props.checked}
disabled={this.props.disabled}
inline={this.props.inline}
isInvalid={this.props.isInvalid}
feedback={this.props.feedback}
onChange={this.props.onChange}
/>
)
}
}

export { Radio }
1 change: 1 addition & 0 deletions src/components/Radio/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Radio'
46 changes: 46 additions & 0 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react'
import Form from 'react-bootstrap/Form'

interface Props {
/** Defines the type of the input. Defaults to 'text' if not specified. */
type?: 'text' | 'number' | 'email'
/** Defines the size of the input. Defaults to 'lg' */
size?: 'sm' | 'lg'
/** The value of the input */
value?: string | ''
/** Handles the onChange event for the input */
onChange?: (e: React.FormEvent<Form>) => void
/** The name of the input */
name?: string | ''
/** The id value of the input */
id?: string | ''
/** Defines whether the input should be disabled or not. Defaults to false. */
disabled?: boolean
/** Defines whether the input should display as invalid. Defaults to false. */
isInvalid?: boolean
/** Defines whether the input should display as valid. Defaults to false */
isValid?: boolean
}

/**
* A flexible text input as a wrapper around the React Bootstrap Form Control.
*/

const TextInput = (props: Props) => {
return (
<Form.Control
as="input"
type={props.type || 'text'}
name={props.name}
id={props.id}
onChange={props.onChange}
disabled={props.disabled || false}
isInvalid={props.isInvalid || false}
isValid={props.isValid || false}
defaultValue={props.value}
size={props.size}
/>
)
}

export { TextInput }
1 change: 1 addition & 0 deletions src/components/TextInput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TextInput'
3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export * from './components/Icon'
export * from './components/Badge'
export * from './components/Pill'
export * from './components/Checkbox'
export * from './components/Navbar'
export * from './components/TextField'
export * from './components/Radio'
export * from './components/Alert'
export * from './components/TextInput'
Loading

0 comments on commit 7340739

Please sign in to comment.