Skip to content

Commit bb384de

Browse files
Sireesh PSireesh P
authored andcommitted
update json
1 parent a933abf commit bb384de

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

lib/App.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,46 @@ import React, { Component } from "react";
1212
import Routes from "./components/routes";
1313
import Navbar from "./components/navbar";
1414
import Footer from "./components/footer";
15+
import * as api from "react-json-schema-form/api";
16+
import RenderJson from "./components/renderJson";
1517

1618
var App = function (_Component) {
1719
_inherits(App, _Component);
1820

19-
function App() {
21+
function App(props) {
2022
_classCallCheck(this, App);
2123

22-
return _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).apply(this, arguments));
24+
var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this, props));
25+
26+
_this.state = {
27+
Schema: props.Schema
28+
};
29+
return _this;
2330
}
2431

2532
_createClass(App, [{
33+
key: "componentDidMount",
34+
value: function componentDidMount() {
35+
var _this2 = this;
36+
37+
if (!this.props.Schema && this.props.SchemaUrl) {
38+
api.get(this.props.SchemaUrl, function (json) {
39+
return _this2.setState({ Schema: json });
40+
});
41+
}
42+
}
43+
}, {
2644
key: "render",
2745
value: function render() {
28-
var _props = Object.assign({}, this.props),
29-
Schema = _props.Schema;
30-
31-
var leftLinks = Schema.leftLinks,
32-
rightLinks = Schema.rightLinks,
33-
footer = Schema.footer;
46+
if (!this.state.Schema) {
47+
return null;
48+
}
49+
var _state$Schema = this.state.Schema,
50+
leftLinks = _state$Schema.leftLinks,
51+
rightLinks = _state$Schema.rightLinks,
52+
footer = _state$Schema.footer,
53+
logo = _state$Schema.logo,
54+
others = _state$Schema.others;
3455

3556
var routes = [].concat(_toConsumableArray(leftLinks.links), _toConsumableArray(rightLinks.links)).reduce(function (a, b) {
3657
return b.children ? a.concat.apply(a, _toConsumableArray(b.children)).concat(b) : a.concat(b);
@@ -44,14 +65,15 @@ var App = function (_Component) {
4465
metas: _.metas
4566
};
4667
});
47-
68+
routes.push({ url: logo.link });
4869
return React.createElement(
4970
"div",
5071
{ className: "w3-row w3-wrapper" },
51-
React.createElement(Navbar, { links: Schema }),
72+
React.createElement(Navbar, { links: this.state.Schema }),
5273
React.createElement(
5374
"div",
5475
{ className: "w3-main" },
76+
React.createElement(RenderJson, { json: others }),
5577
React.createElement(Routes, { routeList: routes })
5678
),
5779
React.createElement("div", { className: "w3-push" }),

lib/components/navbar/index.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,34 @@ var Navbar = function (_Component) {
6969
key: "renderLogo",
7070
value: function renderLogo(logo) {
7171
var link = logo.link,
72-
image = logo.image;
72+
image = logo.image,
73+
textClassName = logo.textClassName;
7374

7475

7576
return React.createElement(
7677
Link,
7778
{
78-
to: link.to ? link.to : "/",
79+
to: link.path ? link.path : "/",
7980
className: "w3-bar-item w3-button w3-wide w3-padding w3-logo-link " + link.className
8081
},
81-
image ? React.createElement(Img, image) : image.alt ? image.alt : "Logo"
82+
image ? React.createElement(Img, image) : image.alt ? image.alt : "",
83+
link.text ? React.createElement(
84+
"span",
85+
{ className: textClassName },
86+
link.text
87+
) : ""
8288
);
8389
}
8490
}, {
8591
key: "renderLinks",
8692
value: function renderLinks(links) {
8793
return links.map(function (link) {
88-
if (link.children && link.children.length > 0) {
89-
return React.createElement(Dropdown, { link: link, key: uuid.v4() });
90-
} else {
91-
return React.createElement(RenderNavLink, { link: link, key: uuid.v4() });
94+
if (!link.hiddenNav) {
95+
if (link.children && link.children.length > 0) {
96+
return React.createElement(Dropdown, { link: link, key: uuid.v4() });
97+
} else {
98+
return React.createElement(RenderNavLink, { link: link, key: uuid.v4() });
99+
}
92100
}
93101
});
94102
}
@@ -116,7 +124,7 @@ var Navbar = function (_Component) {
116124
return React.createElement(
117125
"nav",
118126
{
119-
className: "w3-sidebar w3-bar-block w3-card-2 w3-animate-left w3-hide-medium w3-hide-large w3-theme " + mobileNavClassName + " " + this.state.mobileNavClass
127+
className: "w3-sidebar w3-bar-block w3-card-2 w3-animate-left w3-hide-medium w3-hide-large " + mobileNavClassName + " " + this.state.mobileNavClass
120128
},
121129
React.createElement(
122130
"a",
@@ -140,7 +148,7 @@ var Navbar = function (_Component) {
140148

141149
return React.createElement(
142150
"div",
143-
{ className: "w3-bar w3-theme " + navbarClassName, id: "topNavbar" },
151+
{ className: "w3-bar " + navbarClassName, id: "topNavbar" },
144152
this.renderToggleNav(toggleNav),
145153
this.renderLogo(logo),
146154
this.renderNavLinks(leftLinks, "w3-left"),

lib/components/renderPage/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from "react";
22
import uuid from "uuid";
33
import { Helmet } from "react-helmet";
44
import RenderJson from "../renderJson";
5-
import { IJson, IMeta, ILink } from "../../types";
65

76
var RenderPage = function RenderPage(_ref) {
87
var json = _ref.json,

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import ReactDOM from "react-dom";
33
import App from "./App";
44
import { BrowserRouter } from "react-router-dom";
55
import "./index.css";
6-
export default function initReactAPP(id, schema) {
6+
export default function initReactAPP(id, schema, schemaUrl) {
77
ReactDOM.render(React.createElement(
88
BrowserRouter,
99
null,
10-
React.createElement(App, { Schema: schema })
10+
React.createElement(App, { Schema: schema, SchemaUrl: schemaUrl })
1111
), document.getElementById(id));
12-
}
12+
}

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-w3-components",
3-
"version": "1.0.5",
3+
"version": "1.0.8",
44
"description": "React JS W3 CSS Components and JSON Parser",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)