@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
67 lines (53 loc) • 2.65 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import * as React from "react";
import { defaultTokens } from "@kiwicom/orbit-design-tokens";
import ThemeProvider from "../../ThemeProvider";
var RenderInRtl = /*#__PURE__*/function (_React$PureComponent) {
_inherits(RenderInRtl, _React$PureComponent);
var _super = _createSuper(RenderInRtl);
function RenderInRtl() {
var _this;
_classCallCheck(this, RenderInRtl);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "html", document.querySelector("html"));
return _this;
}
_createClass(RenderInRtl, [{
key: "componentDidMount",
value: function componentDidMount() {
if (this.html) {
this.html.setAttribute("dir", "rtl");
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.html) {
this.html.removeAttribute("dir");
}
}
}, {
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(ThemeProvider, {
theme: {
orbit: defaultTokens,
rtl: true
}
}, this.props.children);
}
}]);
return RenderInRtl;
}(React.PureComponent);
export default RenderInRtl;