rework tom's welcome page to fit in slightly better with riot's UI/UX

* moves login button to top-left
* switches from iframe to a request() to load the welcome page to inherit CSS (probably breaks RTS :/)
* namespace CSS
* change the layout a bit.
This commit is contained in:
Matthew Hodgson 2017-05-30 03:58:45 +01:00
parent 1af86405bd
commit 1f4f86b5f8
21 changed files with 548 additions and 238 deletions

View file

@ -20,6 +20,8 @@ limitations under the License.
import React from 'react';
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
import sdk from 'matrix-react-sdk';
import GeminiScrollbar from 'react-gemini-scrollbar';
import request from 'browser-request';
module.exports = React.createClass({
displayName: 'HomePage',
@ -34,17 +36,46 @@ module.exports = React.createClass({
homePageUrl: React.PropTypes.string,
},
render: function() {
let src = this.props.homePageUrl || '/home/home.html';
getInitialState: function() {
return {
page: ""
};
},
componentWillMount: function() {
// we use request() to inline the homepage into the react component
// so that it can inherit CSS and theming easily rather than mess around
// with iframes and trying to synchronise document.stylesheets.
let src = this.props.homePageUrl || '/home.html';
if (this.props.teamToken && this.props.teamServerUrl) {
src = `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`;
}
request(
{ method: "GET", url: src },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
console.log(error);
this.setState({ page: "Couldn't load home page" });
}
// We parse the JSON ourselves rather than use the JSON
// parameter, since this throws a parse error on empty
// which breaks if there's no config.json and we're
// loading from the filesystem (see above).
this.setState({ page: body });
}
);
},
render: function() {
return (
<div className="mx_HomePage">
<iframe src={src}/>
</div>
<GeminiScrollbar autoshow={true} className="mx_HomePage">
<div className="mx_HomePage_body" dangerouslySetInnerHTML={{ __html: this.state.page }}>
</div>
</GeminiScrollbar>
);
}
});