UNPKG

router-view-dom

Version:
2 lines 14.8 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{280:function(module,__webpack_exports__,__webpack_require__){"use strict";var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),react__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(47),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_1__);__webpack_require__(7);function GetInstall(props){return console.log(props),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1",null,"Getting Started"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p",null,"Router View Dom is wrapper on simple react-router-dom providing a good development with routing for programmers."),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("pre",null,"npm install router-view-dom --save"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_1___default.a,{language:"javascript"},"\nimport React from 'react';\nimport RouterView, { RouterWrapper, Link } from 'router-view-dom';\n\n\n\n\nconst routers = [\n {\n path: '/first',\n key: 'first',\n component: () => (<h2>first</h2>),\n\n },\n {\n path: '/second',\n strict: true,\n key: 'second',\n component: () => (<h2>second</h2>),\n\n\n },\n];\n\n\n\nfunction App(props) {\n\n return (\n <div className=\"App\">\n <RouterWrapper>\n <Link to=\"/first\">first page</Link>\n <Link to=\"/second\"> second page </Link>\n <div>\n <RouterView routers={routers} />\n </div>\n \n </RouterWrapper>\n </div>\n );\n}\n\nexport default App;\n\n\n ")))}__webpack_exports__.a=GetInstall,GetInstall.__docgenInfo={description:"",methods:[],displayName:"GetInstall"},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/pages/GetInstall.jsx"]={name:"GetInstall",docgenInfo:GetInstall.__docgenInfo,path:"src/pages/GetInstall.jsx"})},281:function(module,__webpack_exports__,__webpack_require__){"use strict";var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),react__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__),router_view_dom__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7),router_view_dom__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(router_view_dom__WEBPACK_IMPORTED_MODULE_1__),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(47),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2__),routers=[{path:"/first",key:"first",component:function component(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2",null,"first")}},{path:"/second",strict:!0,key:"second",component:function component(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2",null,"second")}}];function SimpleRouter(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.RouterWrapper,null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1",null," Simple Router"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2___default.a,{language:"javascript"},"\nconst routers = [\n {\n path: '/first',\n key: 'first',\n component: () => (<h2>first</h2>),\n\n },\n {\n path: '/second',\n strict: true,\n key: 'second',\n component: () => (<h2>second</h2>),\n\n\n },\n];\n "),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.Link,{to:"/first"},"first page"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.Link,{to:"/second"}," second page "),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1___default.a,{routers:routers})))}__webpack_exports__.a=SimpleRouter,SimpleRouter.__docgenInfo={description:"",methods:[],displayName:"SimpleRouter"},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/pages/SimpleRouter/SimpleRouter.jsx"]={name:"SimpleRouter",docgenInfo:SimpleRouter.__docgenInfo,path:"src/pages/SimpleRouter/SimpleRouter.jsx"})},282:function(module,__webpack_exports__,__webpack_require__){"use strict";var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),react__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__),router_view_dom__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7),router_view_dom__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(router_view_dom__WEBPACK_IMPORTED_MODULE_1__),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(47),react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2__),isAuth=!1,routers=[{path:"/first",key:"first",component:function component(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2",null,"first",react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button",{onClick:function onClick(){isAuth=!0}},"login"))}},{path:"/second",strict:!0,key:"second",component:function component(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2",null,"second",react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("button",{onClick:function onClick(){isAuth=!1,router_view_dom__WEBPACK_IMPORTED_MODULE_1__.history.push("/first")}},"logout"))},before:function before(){return isAuth?Object(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.next)():Object(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.next)("/forbidden")}},{path:"/forbidden",strict:!0,key:"second",component:function component(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2",null,"forbidden")}}];function AuthRouter(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.RouterWrapper,null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h1",null,"Router with Auth"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_syntax_highlighter__WEBPACK_IMPORTED_MODULE_2___default.a,{language:"javascript"},"\nlet isAuth = false;\nconst routers = [\n {\n path: '/first',\n key: 'first',\n component: () => (\n <h2>\n first\n <button\n onClick={() => {\n isAuth = true;\n }}\n >\n login\n </button>\n </h2>\n ),\n\n },\n {\n path: '/second',\n strict: true,\n key: 'second',\n component: () => (<h2>second\n <button\n onClick={() => {\n isAuth = false;\n history.push(\"/first\");\n }}\n >\n logout\n </button></h2>),\n before: () => {\n if (isAuth) {\n return next();\n }\n\n return next('/forbidden');\n },\n\n\n }, {\n path: '/forbidden',\n strict: true,\n key: 'second',\n component: () => (<h2>forbidden</h2>),\n\n\n },\n];\n\n\n "),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.Link,{to:"/first"},"first page"),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1__.Link,{to:"/second"}," second page "),react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(router_view_dom__WEBPACK_IMPORTED_MODULE_1___default.a,{routers:routers})))}__webpack_exports__.a=AuthRouter,AuthRouter.__docgenInfo={description:"",methods:[],displayName:"AuthRouter"},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/pages/AuthRouter/AuthRouter.jsx"]={name:"AuthRouter",docgenInfo:AuthRouter.__docgenInfo,path:"src/pages/AuthRouter/AuthRouter.jsx"})},283:function(module,__webpack_exports__,__webpack_require__){"use strict";var react=__webpack_require__(0),react_default=__webpack_require__.n(react),build=__webpack_require__(7),build_default=__webpack_require__.n(build),react_syntax_highlighter=__webpack_require__(47),react_syntax_highlighter_default=__webpack_require__.n(react_syntax_highlighter);function SubPage(){return react_default.a.createElement("div",null,react_default.a.createElement("h2",null,"SubPage"))}SubPage.__docgenInfo={description:"",methods:[],displayName:"SubPage"},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/pages/SubPage.jsx"]={name:"SubPage",docgenInfo:SubPage.__docgenInfo,path:"src/pages/SubPage.jsx"});var ChildRouter_routers=[{path:"/first",key:"first",component:function component(){return react_default.a.createElement("h2",null,"first")}},{path:"/second",strict:!0,key:"second",component:function component(props){var routers=props.route.routers;return react_default.a.createElement("div",null,react_default.a.createElement("h2",null,"second"),react_default.a.createElement(build.Link,{to:"/second/sub"}," second page "),react_default.a.createElement(build_default.a,{routers:routers}))},routers:[{key:"second-sub",path:"/second/sub",exact:!0,component:function component(){return react_default.a.createElement("h2",null,"second sub page")}}]}];function ChildRouter(){return react_default.a.createElement(build.RouterWrapper,null,react_default.a.createElement("h1",null,"Router with children"),react_default.a.createElement(react_syntax_highlighter_default.a,{language:"javascript"},"\nrouters = [\n {\n path: '/first',\n key: 'first',\n component: () => (<h2>first</h2>),\n\n },\n {\n path: '/second',\n strict: true,\n key: 'second',\n component: (props) => {\n const { route: { routers } } = props;\n return (\n <div>\n <h2>second</h2>\n <Link to=\"/second/sub\"> second page </Link>\n\n <RouterView routers={routers} />\n </div>\n );\n },\n routers: [\n {\n key: 'second-sub',\n path: '/second/sub',\n exact: true,\n component: () => (<h2>second sub page</h2>),\n }\n ],\n\n\n },\n];\n "),react_default.a.createElement(build.Link,{to:"/first"},"first page"),react_default.a.createElement(build.Link,{to:"/second"}," second page "),react_default.a.createElement("div",null,react_default.a.createElement(build_default.a,{routers:ChildRouter_routers})))}__webpack_exports__.a=ChildRouter;ChildRouter.__docgenInfo={description:"",methods:[],displayName:"ChildRouter"},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/pages/ChildRouter/ChildRouter.jsx"]={name:"ChildRouter",docgenInfo:ChildRouter.__docgenInfo,path:"src/pages/ChildRouter/ChildRouter.jsx"})},284:function(module,exports,__webpack_require__){__webpack_require__(285),__webpack_require__(393),module.exports=__webpack_require__(394)},306:function(module,exports){},394:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){var _storybook_react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(60);Object(_storybook_react__WEBPACK_IMPORTED_MODULE_0__.addParameters)({options:{name:"Router View Dom",url:"#",goFullScreen:!1,showStoriesPanel:!0,showAddonPanel:!1,showSearchBox:!1,addonPanelInRight:!1,hierarchySeparator:null,hierarchyRootSeparator:null,sidebarAnimations:!0,enableShortcuts:!1,isToolshown:!1}});var req=__webpack_require__(600);Object(_storybook_react__WEBPACK_IMPORTED_MODULE_0__.configure)((function loadStories(){req.keys().forEach((function(filename){return req(filename)}))}),module)}.call(this,__webpack_require__(204)(module))},600:function(module,exports,__webpack_require__){var map={"./stories/App.stories.jsx":601};function webpackContext(req){var id=webpackContextResolve(req);return __webpack_require__(id)}function webpackContextResolve(req){if(!__webpack_require__.o(map,req)){var e=new Error("Cannot find module '"+req+"'");throw e.code="MODULE_NOT_FOUND",e}return map[req]}webpackContext.keys=function webpackContextKeys(){return Object.keys(map)},webpackContext.resolve=webpackContextResolve,module.exports=webpackContext,webpackContext.id=600},601:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),react__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__),_storybook_react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(60),_pages_GetInstall__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(280),_pages_SimpleRouter_SimpleRouter__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(281),_pages_ChildRouter_ChildRouter__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(283),_pages_AuthRouter_AuthRouter__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(282);Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("Welcome",module).add("get install",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_pages_GetInstall__WEBPACK_IMPORTED_MODULE_2__.a,null)})),Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("examples",module).add("simple router",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_pages_SimpleRouter_SimpleRouter__WEBPACK_IMPORTED_MODULE_3__.a,null)})).add("router with children",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_pages_ChildRouter_ChildRouter__WEBPACK_IMPORTED_MODULE_4__.a,null)})).add("router with auth",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_pages_AuthRouter_AuthRouter__WEBPACK_IMPORTED_MODULE_5__.a,null)}))}.call(this,__webpack_require__(204)(module))}},[[284,1,2]]]); //# sourceMappingURL=main.6212fa286a71f4ebb653.bundle.js.map