mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
sundry PR feedback
This commit is contained in:
parent
44a0fa19ae
commit
f499c60b12
7 changed files with 23 additions and 47 deletions
|
@ -14,17 +14,11 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var dis = require('./dispatcher');
|
// The colour keys to be replaced as referred to in SVGs
|
||||||
|
|
||||||
var registered = false;
|
|
||||||
if (!registered) {
|
|
||||||
dis.register(_onAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
var keyRgb = [
|
var keyRgb = [
|
||||||
"rgb(118, 207, 166)",
|
"rgb(118, 207, 166)", // Vector Green
|
||||||
"rgb(234, 245, 240)",
|
"rgb(234, 245, 240)", // Vector Light Green
|
||||||
"rgba(118, 207, 166, 0.2)",
|
"rgba(118, 207, 166, 0.2)", // BottomLeftMenu overlay (20% Vector Green)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Some algebra workings for calculating the tint % of Vector Green & Light Green
|
// Some algebra workings for calculating the tint % of Vector Green & Light Green
|
||||||
|
@ -34,10 +28,11 @@ var keyRgb = [
|
||||||
// (255 - 118) x = 255 - 234
|
// (255 - 118) x = 255 - 234
|
||||||
// x = (255 - 234) / (255 - 118) = 0.16
|
// x = (255 - 234) / (255 - 118) = 0.16
|
||||||
|
|
||||||
|
// The colour keys to be replaced as referred to in SVGs
|
||||||
var keyHex = [
|
var keyHex = [
|
||||||
"#76CFA6",
|
"#76CFA6", // Vector Green
|
||||||
"#EAF5F0",
|
"#EAF5F0", // Vector Light Green
|
||||||
"#D3EFE1",
|
"#D3EFE1", // BottomLeftMenu overlay (20% Vector Green overlaid on Vector Light Green)
|
||||||
];
|
];
|
||||||
|
|
||||||
// cache of our replacement colours
|
// cache of our replacement colours
|
||||||
|
@ -85,10 +80,11 @@ function calcCssFixups() {
|
||||||
var ss = document.styleSheets[i];
|
var ss = document.styleSheets[i];
|
||||||
for (var j = 0; j < ss.cssRules.length; j++) {
|
for (var j = 0; j < ss.cssRules.length; j++) {
|
||||||
var rule = ss.cssRules[j];
|
var rule = ss.cssRules[j];
|
||||||
|
if (!rule.style) continue;
|
||||||
for (var k = 0; k < cssAttrs.length; k++) {
|
for (var k = 0; k < cssAttrs.length; k++) {
|
||||||
var attr = cssAttrs[k];
|
var attr = cssAttrs[k];
|
||||||
for (var l = 0; l < keyRgb.length; l++) {
|
for (var l = 0; l < keyRgb.length; l++) {
|
||||||
if (rule.style && rule.style[attr] === keyRgb[l]) {
|
if (rule.style[attr] === keyRgb[l]) {
|
||||||
cssFixups.push({
|
cssFixups.push({
|
||||||
style: rule.style,
|
style: rule.style,
|
||||||
attr: attr,
|
attr: attr,
|
||||||
|
@ -143,17 +139,6 @@ function applySvgFixups(fixups) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _onAction(payload) {
|
|
||||||
if (payload.action !== "svg_onload") return;
|
|
||||||
// XXX: we should probably faff around with toggling the visibility of the node to avoid flashing the wrong colour.
|
|
||||||
// (although this would result in an even worse flicker as the element redraws)
|
|
||||||
var fixups = calcSvgFixups([ payload.svg ]);
|
|
||||||
if (fixups.length) {
|
|
||||||
svgFixups = svgFixups.concat(fixups); // XXX: this leaks fixups
|
|
||||||
applySvgFixups(fixups);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hexToRgb(color) {
|
function hexToRgb(color) {
|
||||||
if (color[0] === '#') color = color.slice(1);
|
if (color[0] === '#') color = color.slice(1);
|
||||||
if (color.length === 3) {
|
if (color.length === 3) {
|
||||||
|
@ -210,5 +195,15 @@ module.exports = {
|
||||||
// updated would be a PITA, so just brute-force search for the
|
// updated would be a PITA, so just brute-force search for the
|
||||||
// key colour; cache the element and apply.
|
// key colour; cache the element and apply.
|
||||||
applySvgFixups(svgFixups);
|
applySvgFixups(svgFixups);
|
||||||
|
},
|
||||||
|
|
||||||
|
tintSvg: function(svg) {
|
||||||
|
// XXX: we should probably faff around with toggling the visibility of the node to avoid flashing the wrong colour.
|
||||||
|
// (although this would result in an even worse flicker as the element redraws)
|
||||||
|
var fixups = calcSvgFixups([ svg ]);
|
||||||
|
if (fixups.length) {
|
||||||
|
svgFixups = svgFixups.concat(fixups); // XXX: this leaks fixups
|
||||||
|
applySvgFixups(fixups);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1093,10 +1093,6 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSvgLoad: function(event) {
|
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
||||||
var MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
var MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
||||||
|
|
|
@ -19,6 +19,7 @@ limitations under the License.
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var ReactDOM = require("react-dom");
|
var ReactDOM = require("react-dom");
|
||||||
var dis = require("../../../dispatcher");
|
var dis = require("../../../dispatcher");
|
||||||
|
var Tinter = require("../../../Tinter");
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'TintableSvg',
|
displayName: 'TintableSvg',
|
||||||
|
@ -41,7 +42,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad: function(event) {
|
onLoad: function(event) {
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
Tinter.tintSvg(event.target);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -47,10 +47,6 @@ module.exports = React.createClass({
|
||||||
return linkText;
|
return linkText;
|
||||||
},
|
},
|
||||||
|
|
||||||
onSvgLoad: function(event) {
|
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var content = this.props.mxEvent.getContent();
|
var content = this.props.mxEvent.getContent();
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
|
|
|
@ -97,10 +97,6 @@ module.exports = React.createClass({
|
||||||
return MatrixClientPeg.get().mxcUrlToHttp(content.url, 480, 360);
|
return MatrixClientPeg.get().mxcUrlToHttp(content.url, 480, 360);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSvgLoad: function(event) {
|
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
var content = this.props.mxEvent.getContent();
|
var content = this.props.mxEvent.getContent();
|
||||||
|
|
|
@ -457,10 +457,6 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSvgLoad: function(event) {
|
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var me = this.props.room.getMember(MatrixClientPeg.get().credentials.userId);
|
var me = this.props.room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||||
var uploadInputStyle = {display: 'none'};
|
var uploadInputStyle = {display: 'none'};
|
||||||
|
|
|
@ -67,10 +67,6 @@ module.exports = React.createClass({
|
||||||
return this.refs.name_edit.value;
|
return this.refs.name_edit.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
onSvgLoad: function(event) {
|
|
||||||
dis.dispatch({ action: "svg_onload", svg: event.target });
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var EditableText = sdk.getComponent("elements.EditableText");
|
var EditableText = sdk.getComponent("elements.EditableText");
|
||||||
var RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
|
var RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
|
||||||
|
|
Loading…
Reference in a new issue