UNPKG

wix-style-react

Version:
86 lines (68 loc) 2.45 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _Loader = require('./Loader.scss'); var _Loader2 = _interopRequireDefault(_Loader); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var hasClass = function hasClass(element, styles, cls) { return element.getAttribute('class').then(function (classes) { return classes.split(' ').some(function (c) { return c.includes(styles[cls]); }); }); }; var getLoaderTextElement = function getLoaderTextElement(component) { return component.$('[data-hook="loader-text"]'); }; var loaderDriverFactory = function loaderDriverFactory(component) { return { /** returns the driver element */ element: function element() { return component; }, /** true when using the tiny loader */ isTiny: function isTiny() { return hasClass(component, _Loader2.default, 'tiny'); }, /** true when using the small loader */ isSmall: function isSmall() { return hasClass(component, _Loader2.default, 'small'); }, /** true when using the medium loader */ isMedium: function isMedium() { return hasClass(component, _Loader2.default, 'medium'); }, /** true when using the large loader */ isLarge: function isLarge() { return hasClass(component, _Loader2.default, 'large'); }, /** returns the loader color ('blue' or 'white') */ getColor: function getColor() { return hasClass(component, _Loader2.default, 'blue').then(function (hasBlueClass) { return hasBlueClass ? 'blue' : 'white'; }); }, /** true if the element has text */ hasText: function hasText() { return getLoaderTextElement(component).isPresent(); }, /** returns the element text (will be in upper case) */ getText: function getText() { return getLoaderTextElement(component).getText(); }, /** true when loader is in error status */ isError: function isError() { return hasClass(component, _Loader2.default, 'error'); }, /** true when loader is in success status */ isSuccess: function isSuccess() { return hasClass(component, _Loader2.default, 'success'); }, /** true when loader is in loading status */ isLoading: function isLoading() { return hasClass(component, _Loader2.default, 'loading'); } }; }; exports.default = loaderDriverFactory;