Skip to content

Commit

Permalink
Refactored samples to pass linter
Browse files Browse the repository at this point in the history
  • Loading branch information
teodosii committed Sep 2, 2018
1 parent 2747814 commit f94778e
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 38 deletions.
16 changes: 8 additions & 8 deletions samples/js/components/Content.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import Highlight from "react-highlight";
import { install, usage } from "../helpers/code";
import ContainerExample from "./examples/ContainerExample";
import TypeExample from "./examples/TypeExample";
import InsertExample from "./examples/InsertExample";
import AnimationWrapper from "./examples/AnimationExample";
import CustomContentExample from "./examples/CustomContentExample";
import UsageExample from "./examples/UsageExample";
import { install, } from "helpers/code";
import ContainerExample from "components/examples/ContainerExample";
import TypeExample from "components/examples/TypeExample";
import InsertExample from "components/examples/InsertExample";
import AnimationWrapper from "components/examples/AnimationExample";
import CustomContentExample from "components/examples/CustomContentExample";
import UsageExample from "components/examples/UsageExample";

function NPMInstall() {
return (
Expand Down Expand Up @@ -34,7 +34,7 @@ function ExampleHeading() {
</div>
</div>
);
};
}

const Examples = ({ addNotification }) => {
return (
Expand Down
3 changes: 2 additions & 1 deletion samples/js/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

export default function Header({ instance }) {
export default function Header() {
return (
<div className="header">
<div className="header-content">
Expand All @@ -9,6 +9,7 @@ export default function Header({ instance }) {
<div className="header-buttons">
<a
target="_blank"
rel="noopener noreferrer"
className="btn btn-primary no-corner"
href={"https://github.com/teodosii/react-notifications-component"}
>
Expand Down
7 changes: 3 additions & 4 deletions samples/js/components/examples/AnimationExample.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import notification from "../../helpers/notification";
import notification from "helpers/notification";
import {
getContainer,
getType,
getMessage,
getTitle
} from "../../helpers/randomize";
getMessage
} from "helpers/randomize";

function AnimationInExample({ addNotification }) {
const add = (htmlClasses) => {
Expand Down
4 changes: 2 additions & 2 deletions samples/js/components/examples/ContainerExample.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import notification from "../../helpers/notification";
import notification from "helpers/notification";
import {
getType,
getMessage,
getTitle
} from "../../helpers/randomize";
} from "helpers/randomize";

export default class ContainerExample extends React.Component {
constructor(props) {
Expand Down
6 changes: 3 additions & 3 deletions samples/js/components/examples/CustomContentExample.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import notification from "../../helpers/notification";
import reactImage from "../../../images/react.png";
import { getContainer } from "../../helpers/randomize";
import notification from "helpers/notification";
import reactImage from "images/react.png";
import { getContainer } from "helpers/randomize";

export default class CustomContentExample extends React.Component {
constructor(props) {
Expand Down
5 changes: 2 additions & 3 deletions samples/js/components/examples/InsertExample.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import notification from "../../helpers/notification";
import notification from "helpers/notification";
import {
getContainer,
getType,
getMessage,
getTitle
} from "../../helpers/randomize";
} from "helpers/randomize";

export default function InsertExample({ addNotification }) {
const add = (insert) => {
Expand Down
4 changes: 2 additions & 2 deletions samples/js/components/examples/TypeExample.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import notification from "../../helpers/notification";
import notification from "helpers/notification";
import {
getContainer,
getMessage,
getTitle
} from "../../helpers/randomize";
} from "helpers/randomize";

export default class TypeExample extends React.Component {
constructor(props) {
Expand Down
6 changes: 2 additions & 4 deletions samples/js/components/examples/UsageExample.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import Highlight from "react-highlight";
import { usage } from "../../helpers/code";
import notification from "../../helpers/notification";
import notificationObject from "../../../../tests/mocks/notification.mock";
import { usage } from "helpers/code";

export default function UsageExample({ addNotification }) {
export default function UsageExample() {
return (
<div className="row">
<div className="col-lg-8 offset-lg-2 column col-md-10 offset-md-1 col-sm-12 heading">
Expand Down
5 changes: 3 additions & 2 deletions samples/js/helpers/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ class App extends React.Component {
constructor(props) {
super(props);
this.addNotification = this.addNotification.bind(this);
this.notificationDOMRef = React.createRef();
}
addNotification() {
this.notificationDOMRef.addNotification({
this.notificationDOMRef.current.addNotification({
title: "Awesomeness",
message: "Awesome Notifications!",
type: "success",
Expand All @@ -26,7 +27,7 @@ class App extends React.Component {
render() {
return (
<div className="app-content">
<ReactNotification ref={input => this.notificationDOMRef = input} />
<ReactNotification ref={this.notificationDOMRef} />
<button onClick={this.addNotification} className="btn btn-primary">
Add Awesome Notification
</button>
Expand Down
4 changes: 1 addition & 3 deletions samples/js/helpers/notification.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from "react";

export default {
title: "Awesomeness",
message: "Awesome Notifications!",
Expand Down Expand Up @@ -47,7 +45,7 @@ export default {
delay: 0
}
},

dismiss: {
duration: 5000
}
Expand Down
18 changes: 14 additions & 4 deletions samples/js/helpers/randomize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from "react";

const containers = ["top-left", "top-right", "bottom-left", "bottom-right"];
const containers = [
"top-left",
"top-right",
"bottom-left",
"bottom-right"
];

const types = ["success", "danger", "warning", "default", "info", "awesome"];
const types = [
"success",
"danger",
"warning",
"default",
"info",
"awesome"
];

const successMessages = [
"All your data has been successfully updated",
Expand Down
4 changes: 2 additions & 2 deletions samples/js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";
import "../styles/stylesheet.scss";
import App from "components/App";
import "styles/stylesheet.scss";
import "@babel/polyfill";

ReactDOM.render(<App />, document.getElementById("root"));

0 comments on commit f94778e

Please # to comment.