diff --git a/src/css/notifications.sass b/src/css/notifications.sass new file mode 100644 index 0000000..caf6ee7 --- /dev/null +++ b/src/css/notifications.sass @@ -0,0 +1 @@ +@import 'react-notifications/lib/notifications.css' diff --git a/src/pages/add.js b/src/pages/add.js index a1ab699..a128f33 100644 --- a/src/pages/add.js +++ b/src/pages/add.js @@ -1,17 +1,23 @@ import React from "react" import AniLink from "gatsby-plugin-transition-link/AniLink" -import { NotificationManager, NotificationContainer } from 'react-notifications' -import 'react-notifications/lib/notifications.css' +import { NotificationManager, NotificationContainer } from "react-notifications" import Seo from "../components/seo" import axios from "../axios" import "../css/base.sass" import "../css/url.sass" +import "../css/notifications.sass" const AddURLPage = () => { const [url, setURL] = React.useState('') + const handleKeypress = e => { + if (e.charCode === 13 || e.keyCode === 13) { + addURL() + } + } + const changeURLHandler = event => { const value = event.target.value setURL(value) @@ -61,7 +67,8 @@ const AddURLPage = () => { className="input" placeholder="URL" value={url} - onChange={changeURLHandler} /> + onChange={changeURLHandler} + onKeyPress={handleKeypress} />