Skip to content

Commit dd1695f

Browse files
Sireesh PSireesh P
authored andcommitted
lib
1 parent 7cb608e commit dd1695f

File tree

31 files changed

+1010
-18
lines changed

31 files changed

+1010
-18
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-app"]
3+
}

lib/App.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2+
3+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
4+
5+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6+
7+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8+
9+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
10+
11+
import React, { Component } from "react";
12+
import Routes from "./components/routes";
13+
import Navbar from "./components/navbar";
14+
15+
var App = function (_Component) {
16+
_inherits(App, _Component);
17+
18+
function App() {
19+
_classCallCheck(this, App);
20+
21+
return _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).apply(this, arguments));
22+
}
23+
24+
_createClass(App, [{
25+
key: "render",
26+
value: function render() {
27+
var _props = Object.assign({}, this.props),
28+
Schema = _props.Schema;
29+
30+
var routes = [].concat(_toConsumableArray(Schema.leftLinks.links), _toConsumableArray(Schema.rightLinks.links)).reduce(function (a, b) {
31+
return b.children ? a.concat.apply(a, _toConsumableArray(b.children)).concat(b) : a.concat(b);
32+
}, []).map(function (_) {
33+
return {
34+
url: _.path,
35+
json: _.json,
36+
text: _.text,
37+
title: _.title,
38+
links: _.links,
39+
metas: _.metas
40+
};
41+
});
42+
43+
return React.createElement(
44+
"div",
45+
{ className: "w3-row" },
46+
React.createElement(Navbar, { links: Schema }),
47+
React.createElement(
48+
"div",
49+
{ className: "w3-margin-top" },
50+
React.createElement(Routes, { routeList: routes })
51+
)
52+
);
53+
}
54+
}]);
55+
56+
return App;
57+
}(Component);
58+
59+
export default App;

lib/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**W3 CSS React Components**
2+
Usage
3+
import initReactAPP from 'react-w3-components';
4+
5+
initReactAPP('root', schemaObject);

lib/components/alert/index.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2+
3+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4+
5+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
6+
7+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8+
9+
import React from "react";
10+
import { IAlert } from "../../types/";
11+
/**
12+
* <Alert alertText="dfadfa" className="w3-red"/>
13+
* @param {*} param0
14+
*/
15+
16+
var Alert = function (_React$Component) {
17+
_inherits(Alert, _React$Component);
18+
19+
function Alert(props) {
20+
_classCallCheck(this, Alert);
21+
22+
var _this = _possibleConstructorReturn(this, (Alert.__proto__ || Object.getPrototypeOf(Alert)).call(this, props));
23+
24+
_this.onCloseClick = _this.onCloseClick.bind(_this);
25+
_this.state = {
26+
toggleClass: "show"
27+
};
28+
return _this;
29+
}
30+
31+
_createClass(Alert, [{
32+
key: "onCloseClick",
33+
value: function onCloseClick() {
34+
this.setState({
35+
toggleClass: "none"
36+
});
37+
}
38+
}, {
39+
key: "render",
40+
value: function render() {
41+
var _props = this.props,
42+
alertText = _props.alertText,
43+
className = _props.className;
44+
45+
return React.createElement(
46+
"div",
47+
{ className: "w3-panel w3-theme " + this.state.toggleClass + " " + className },
48+
React.createElement(
49+
"span",
50+
{
51+
className: "w3-button w3-large w3-right",
52+
onClick: this.onCloseClick
53+
},
54+
"\xD7"
55+
),
56+
React.createElement(
57+
"p",
58+
null,
59+
alertText
60+
)
61+
);
62+
}
63+
}]);
64+
65+
return Alert;
66+
}(React.Component);
67+
68+
export default Alert;

lib/components/badge/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react";
2+
3+
var Badge = function Badge(_ref) {
4+
var onClick = _ref.onClick,
5+
className = _ref.className;
6+
7+
return React.createElement("span", { className: "w3-badge w3-border " + className, onClick: onClick });
8+
};
9+
10+
export default Badge;

lib/components/dropdown/index.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2+
3+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4+
5+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
6+
7+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
8+
9+
import React from "react";
10+
import uuid from "uuid";
11+
import RenderNavLink from "./renderNavLink";
12+
13+
var Dropdown = function (_React$Component) {
14+
_inherits(Dropdown, _React$Component);
15+
16+
function Dropdown(props) {
17+
_classCallCheck(this, Dropdown);
18+
19+
var _this = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this, props));
20+
21+
_this.dropdownClick = _this.dropdownClick.bind(_this);
22+
_this.updateDropdownClass = _this.updateDropdownClass.bind(_this);
23+
24+
_this.state = {
25+
dropdownClass: "none"
26+
};
27+
return _this;
28+
}
29+
30+
_createClass(Dropdown, [{
31+
key: "dropdownClick",
32+
value: function dropdownClick(e) {
33+
e.preventDefault();
34+
this.updateDropdownClass();
35+
}
36+
}, {
37+
key: "updateDropdownClass",
38+
value: function updateDropdownClass() {
39+
var dropdownClass = this.state.dropdownClass === "none" ? "show" : "none";
40+
this.setState({
41+
dropdownClass: dropdownClass
42+
});
43+
}
44+
}, {
45+
key: "render",
46+
value: function render() {
47+
var _this2 = this;
48+
49+
var link = this.props.link;
50+
51+
return React.createElement(
52+
"div",
53+
{ className: "w3-dropdown-click" },
54+
React.createElement(
55+
"a",
56+
{
57+
onClick: this.dropdownClick,
58+
className: "w3-button " + link.className
59+
},
60+
link.text,
61+
" ",
62+
React.createElement("i", { className: "caret-down" })
63+
),
64+
React.createElement(
65+
"div",
66+
{
67+
className: "w3-dropdown-content w3-bar-block mobile-nav " + this.state.dropdownClass
68+
},
69+
link.children.map(function (sublink) {
70+
return React.createElement(RenderNavLink, {
71+
key: uuid.v4(),
72+
link: sublink,
73+
onClick: _this2.updateDropdownClass
74+
});
75+
})
76+
)
77+
);
78+
}
79+
}]);
80+
81+
return Dropdown;
82+
}(React.Component);
83+
84+
export default Dropdown;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import { NavLink } from "react-router-dom";
3+
var RenderNavLink = function RenderNavLink(_ref) {
4+
var link = _ref.link,
5+
onClick = _ref.onClick;
6+
var path = link.path,
7+
text = link.text,
8+
className = link.className,
9+
activeClassName = link.activeClassName;
10+
11+
return React.createElement(
12+
NavLink,
13+
{
14+
to: path,
15+
onClick: onClick,
16+
activeClassName: "w3-active " + activeClassName,
17+
className: "w3-button w3-bar-item " + className
18+
},
19+
text
20+
);
21+
};
22+
23+
export default RenderNavLink;

0 commit comments

Comments
 (0)