Skip to content

Commit

Permalink
Fixed style settings. Changed all components. Added radio and switch …
Browse files Browse the repository at this point in the history
…components.
  • Loading branch information
w3aseL committed Jul 22, 2020
1 parent 739a53d commit 5f07e47
Show file tree
Hide file tree
Showing 17 changed files with 446 additions and 45 deletions.
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
"@emotion/core": "10.x",
"@emotion/styled": "10.x",
"react": "^16.x",
"react-dom": "^16.x"
"react-dom": "^16.x",
"reactstrap": "^8.x",
"@revibe-dev/revibe-blk-system-styles": "^1.x",
"react-bootstrap-switch": "^15.x"
},
"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/core": "^7.10.5",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@fortawesome/fontawesome-free": "^5.13.1",
"@revibe-dev/revibe-blk-system-styles": "^1.0.1",
"@revibe-dev/revibe-blk-system-styles": "^1.0.2",
"@testing-library/react": "^10.4.5",
"babel-loader": "^8.1.0",
"babel-plugin-module-resolver": "^4.0.0",
Expand All @@ -40,14 +43,14 @@
"postcss-loader": "^3.0.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-bootstrap-switch": "^15.5.3",
"react-dom": "^16.13.1",
"react-styleguidist": "^11.0.8",
"reactstrap": "^8.5.1",
"rsg-components": "^3.0.0",
"sass-loader": "^9.0.2",
"style-loader": "^1.2.1",
"webpack": "^4.43.0"
},
"dependencies": {
"bootstrap": "^4.5.0",
"reactstrap": "^8.5.1"
}
"dependencies": {}
}
44 changes: 38 additions & 6 deletions src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,63 @@ class Button extends React.Component {
/**
* Sets the href target of a button.
*/
target: PropTypes.string
target: PropTypes.string,
/**
* Sets the social media of choice for the button. Overrides color.
*
* List: [ twitter, facebook, google, linkedin, pinterest, youtube, tumblr, github, behance, dribble, reddit ]
*/
social: PropTypes.string
}

static defaultProps = {
color: "primary",
active: false,
disabled: false
}

getIconClassBySocial = social => {
switch(social) {
case "twitter":
return "fab fa-twitter";
case "facebook":
return "fab fa-facebook";
case "google":
return "fab fa-linkedin";
case "linkedin":
return "fab fa-linkedin";
case "pinterest":
return "fab fa-pinterest";
case "youtube":
return "fab fa-youtube";
case "tumblr":
return "fab fa-tumblr";
case "github":
return "fab fa-github";
case "behance":
return "fab fa-behance";
case "dribble":
return "fab fa-dribble";
case "reddit":
return "fab fa-reddit";
}
}

render() {
const { icon, simple, round, children, color, size, active, disabled, onClick, link, href, target } = this.props
const { icon, simple, round, children, color, size, active, disabled, onClick, link, href, target, social } = this.props

return (
<ReactstrapButton
color={link ? "link" : color}
color={link ? "link" : social ? social : !color ? "primary" : color}
size={size}
active={active}
disabled={disabled}
onClick={onClick}
className={`${round ? "btn-round" : ""} ${simple ? "btn-simple" : ""} ${icon && !children ? "btn-icon" : ""}`}
className={`${round ? "btn-round" : ""} ${simple ? "btn-simple" : ""} ${(icon || social) && !children ? "btn-icon" : ""}`}
link={link}
href={href}
target={target}
>
{icon && icon}{icon && children && ""}{icon && children}{!icon && (children || (!children && "Default text!"))}
{social && <i className={this.getIconClassBySocial(social)} />}{icon && !social && icon}{(icon || social) && children && " "}{icon && children}{!icon && !social && (children || (!children && "Default text!"))}
</ReactstrapButton>
)
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/Button/Button.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ import { Button } from 'revibe-component-library'
```js padded
<Button link href="/#button" >Button Link</Button>
<Button link href="https://revibe.tech" target="_blank">External Link</Button>
```

### Social Media Buttons
```js padded
<Button social="twitter" simple round />
<Button social="facebook" simple round />
<Button social="google" simple round />
<Button social="twitter" round />
<Button social="facebook" round />
<Button social="google" round />
```
25 changes: 21 additions & 4 deletions src/components/Checkbox/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,41 @@ class Checkbox extends React.Component {
/**
* The label text.
*/
label: PropTypes.string
label: PropTypes.string,
/**
* Function to handle change.
*/
onChange: PropTypes.func,
/**
* Sets whether the checkbox is enabled or disabled.
*/
disabled: PropTypes.bool,
/**
* Sets whether the checkbox is inline or not.
*/
inline: PropTypes.bool
}

static defaultProps = {
label: "Default text!"
}

render() {
const { label } = this.props
const { label, onChange, disabled, inline } = this.props

return (
<FormGroup check className="text-left">
<FormGroup check inline={inline} disabled={disabled}>
<Label check>
<Input
type="checkbox"
onChange={onChange}
disabled={disabled}
/>
<span className="form-check-sign" />
{' '}
{label}
<span className="form-check-sign">
<span className="check"></span>
</span>
</Label>
</FormGroup>
)
Expand Down
12 changes: 11 additions & 1 deletion src/components/Checkbox/Checkbox.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Checkbox Syntax

Importing the button.
Importing the checkbox.
```js static
import Checkbox from 'revibe-component-library/Checkbox'

Expand All @@ -12,5 +12,15 @@ import { Checkbox } from 'revibe-component-library'
<div className="content">
<Checkbox />
<Checkbox label="Test Label" />
<Checkbox disabled label="Disabled" />
</div>
```

### Checkbox Inline Examples
```js padded
<div className="content">
<Checkbox inline />
<Checkbox inline label="Test Label" />
<Checkbox inline disabled label="Disabled" />
</div>
```
76 changes: 76 additions & 0 deletions src/components/Radio/Radio.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react'

import PropTypes from 'prop-types'

import { FormGroup, Input, Label } from 'reactstrap'

// Add your info to the docs if you edit this!

/**
* ### Baseline radio!
*
* @version 0.0.1
* @author Noah Templet ([w3aseL](https://github.com/w3aseL))
*/
class Radio extends React.Component {
constructor(props) {
super(props)
}

static propTypes = {
/**
* The label text.
*/
label: PropTypes.string,
/**
* Function to handle change.
*/
onChange: PropTypes.func,
/**
* Value of the radio.
*/
value: PropTypes.string,
/**
* Name of the group that radios belong to. REQUIRED!
*/
name: PropTypes.string.isRequired,
/**
* Sets whether the checkbox is inline or not.
*/
inline: PropTypes.bool,
/**
* Sets whether the checkbox is enabled or disabled.
*/
disabled: PropTypes.bool
}

static defaultProps = {
label: "Default text!"
}

render() {
const { label, onChange, value, name, inline, disabled } = this.props

return (
<div className="content">
<FormGroup check inline={inline} disabled={disabled} className="form-check-radio">
<Label className="form-check-label">
<Input
type="radio"
onChange={onChange}
value={value}
name={name}
disabled={disabled}
/>
{label}
<span className="form-check-sign" />
</Label>
</FormGroup>
</div>
)
}
}

export { Radio }

export default Radio
26 changes: 26 additions & 0 deletions src/components/Radio/Radio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### Radio Syntax

Importing the radio.
```js static
import Radio from 'revibe-component-library/Checkbox'

import { Radio } from 'revibe-component-library'
```

### Radio Text Examples
```js padded
<div className="content">
<Radio name="examples1" value="option1" />
<Radio name="examples1" value="option2" label="Test Label" />
<Radio disabled name="examples1" value="option3" label="Disabled" />
</div>
```

### Radio Inline Examples
```js padded
<div className="content">
<Radio inline name="examples2" value="option1" />
<Radio inline name="examples2" value="option2" label="Test Label" />
<Radio disabled inline name="examples2" value="option3" label="Disabled" />
</div>
```
3 changes: 3 additions & 0 deletions src/components/Radio/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"main": "Radio.jsx"
}
67 changes: 67 additions & 0 deletions src/components/Switch/Switch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react'
import PropTypes from 'prop-types'

import ToggleSwitch from 'react-bootstrap-switch'

// Add your info to the docs if you edit this!

/**
* ### Baseline radio!
*
* @version 0.0.1
* @author Noah Templet ([w3aseL](https://github.com/w3aseL))
*/
class Switch extends React.Component {
constructor(props) {
super(props)
}

static propTypes = {
/**
* The color when the switch is on.
*/
onColor: PropTypes.string,
/**
* The color when the switch is off.
*/
offColor: PropTypes.string,
/**
* The default value of the switch
*/
defaultValue: PropTypes.bool,
/**
* The text when the switch is on.
*/
onText: PropTypes.node,
/**
* The text when the switch is off.
*/
offText: PropTypes.node
}

static defaultProps = {
onColor: "default",
offColor: "default",
defaultValue: false,
onText: "",
offText: ""
}

render() {
const { onColor, offColor, defaultValue, onText, offText } = this.props

return (
<ToggleSwitch
defaultValue={defaultValue}
onColor={onColor}
offColor={offColor}
onText={onText}
offText={offText}
/>
)
}
}

export { Switch }

export default Switch
15 changes: 15 additions & 0 deletions src/components/Switch/Switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Switch Syntax

Importing the switch.
```js static
import Switch from 'revibe-component-library/Checkbox'

import { Switch } from 'revibe-component-library'
```

### Switch Examples
```js padded
<Switch />
<Switch onText="On" onColor="primary" offText="Off" offColor="secondary" />
<Switch onText={<i className="fas fa-bell" />} onColor="primary" offText={<i className="far fa-bell" />} offColor="secondary" />
```
Empty file.
Loading

0 comments on commit 5f07e47

Please sign in to comment.