Skip to content

Commit

Permalink
Create feature to check if a component is visible #56
Browse files Browse the repository at this point in the history
  • Loading branch information
marlyk committed Feb 29, 2020
1 parent 6595a49 commit bc698f7
Show file tree
Hide file tree
Showing 19 changed files with 459 additions and 108 deletions.
26 changes: 18 additions & 8 deletions epyk/core/css/catalogs/CatalogButton.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
"""
"""

from epyk.core.css.catalogs import Catalog

from epyk.core.css.styles.classes import CssStylesButton


class CatalogButton(Catalog.CatalogGroup):
"""

"""
def basic(self):
""" Basic style for a button """
"""
Description:
-----------
Basic style for a button
"""
return self._set_class(CssStylesButton.CssButtonBasic)

def border_rounded(self):
"""
Description:
-----------
"""
pass

def reset(self):
""" """
"""
Description:
-----------
"""
return self._set_class(CssStylesButton.CssButtonReset)

def success(self):
""" """
"""
Description:
-----------
"""
return self._set_class(CssStylesButton.CssButtonSuccess)
69 changes: 56 additions & 13 deletions epyk/core/css/catalogs/CatalogInput.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,94 @@
"""
"""

from epyk.core.css.catalogs import Catalog

from epyk.core.css.styles.classes import CssStylesLabel, CssStylesDates, CssStylesInput


class CatalogInput(Catalog.CatalogGroup):
def active(self):
"""
"""
return self._set_class(CssStylesInput.CssUIActive)

def basic(self):
""" Basic style for an input component """
"""
Description:
-----------
Basic style for an input component
"""
return self._set_class(CssStylesInput.CssInput)

def range(self):
""" CSS Style for the input range component """
"""
Description:
-----------
CSS Style for the input range component
"""
return self._set_class(CssStylesInput.CssInputRange)

def range_thumb(self):
""" CSS Style for the thumb of the input range component """
"""
Description:
-----------
CSS Style for the thumb of the input range component
"""
return self._set_class(CssStylesInput.CssInputRangeThumb)

def label(self):
""" CSS Style for the label attached to an input component """
"""
Description:
-----------
CSS Style for the label attached to an input component
"""
return self._set_class(CssStylesInput.CssInputLabel)

def label_hover(self):
""" CSS Style to change the label background color on mouse hover """
"""
Description:
-----------
CSS Style to change the label background color on mouse hover
"""
return self._set_class(CssStylesLabel.CssLabelCheckMarkHover)

def label_disable(self):
""" CSS Style to set the label to be disabled """
"""
Description:
-----------
CSS Style to set the label to be disabled
"""
return self._set_class(CssStylesLabel.CssLabelContainerDisabled)

def integer(self):
""" Basic style for an input integer component """
"""
Description:
-----------
Basic style for an input integer component
"""
return self._set_class(CssStylesInput.CssInputInteger)

def text(self):
""" Basic style for an input text component """
"""
Description:
-----------
Basic style for an input text component
"""
return self._set_class(CssStylesInput.CssInputText)

def textarea(self):
""" Basic style for an input textarea component """
"""
Description:
-----------
Basic style for an input textarea component
"""
return self._set_class(CssStylesInput.CssInputTextArea)

def is_valid(self):
""" Basic style for an input component with a valid condition """
"""
Description:
-----------
Basic style for an input component with a valid condition
"""
return self._set_class(CssStylesInput.CssInputValid)


Expand Down
15 changes: 12 additions & 3 deletions epyk/core/css/styles/GrpClsButton.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
Group CSS class for all the buttons components
"""

from epyk.core.css.styles import GrpCls
from epyk.core.css.styles.attributes import AttrClsButtons
Expand All @@ -13,7 +10,10 @@ class ClassButton(GrpCls.ClassHtml):
@property
def css(self):
"""
Description:
-----------
Property to the underlying CSS definition to be added to the style HTML tag of a component
:rtype: AttrClsButtons.AttrButton
"""
if self._css_struct is None:
Expand All @@ -23,8 +23,11 @@ def css(self):
@property
def css_class(self):
"""
Description:
-----------
The internal class used to put a custom Style to this object.
Only 1 CSS class can be added to an HTML object
:rtype: Classes.CatalogButton.CatalogButton
"""
if self._css_class is None:
Expand All @@ -36,7 +39,10 @@ class ClassBadge(GrpCls.ClassHtml):
@property
def css(self):
"""
Description:
-----------
Property to the underlying CSS definition to be added to the style HTML tag of a component
:rtype: AttrClsButtons.AttrBadge
"""
if self._css_struct is None:
Expand All @@ -49,7 +55,10 @@ class ClassButtonCheckBox(GrpCls.ClassHtml):
@property
def css(self):
"""
Description:
-----------
Property to the underlying CSS definition to be added to the style HTML tag of a component
:rtype: AttrClsButtons.AttrButton
"""
if self._css_struct is None:
Expand Down
22 changes: 22 additions & 0 deletions epyk/core/css/styles/GrpClsJqueryUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@


class ClassSlider(GrpCls.ClassHtml):
def __init__(self, htmlObj):
super(ClassSlider, self).__init__(htmlObj)
self._css_ui_active = None
self.classList['main'].add(self.cls_ui_active)

@property
def css(self):
"""
Description:
-----------
Property to the underlying CSS definition to be added to the style HTML tag of a component
:rtype: AttrInput.AttrInput
"""
if self._css_struct is None:
Expand All @@ -18,11 +26,25 @@ def css(self):
@property
def css_class(self):
"""
Description:
-----------
The internal class used to put a custom Style to this object.
Only 1 CSS class can be added to an HTML object
:rtype: Classes.CatalogInput.CatalogInput
"""
if self._css_class is None:
self._css_class = Classes.CatalogInput.CatalogInput(self.htmlObj._report, self.classList['main']).basic()
return self._css_class

@property
def cls_ui_active(self):
"""
Description:
-----------
:rtype: Classes.CatalogInput.CatalogInput
"""
if self._css_ui_active is None:
self._css_ui_active = Classes.CatalogInput.CatalogInput(self.htmlObj._report, self.classList['main']).active()
return self._css_ui_active
5 changes: 1 addition & 4 deletions epyk/core/css/styles/classes/CssStylesButton.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
CSS Style module for the Button components
"""

from epyk.core.css.styles.classes import CssStyle

Expand All @@ -11,7 +8,7 @@ class CssBorderRadius(CssStyle.Style):

class CssButtonBasic(CssStyle.Style):
# Static properties for this class
_attrs = {'font-weight': 'bold', 'padding': '1px 10px', 'margin': '2px 0 2px 0', 'text-decoration': 'none',
_attrs = {'font-weight': 'bold', 'padding': '2px 10px', 'margin': '2px 0 2px 0', 'text-decoration': 'none',
'border-radius': '5px', 'white-space': 'nowrap', 'display': 'inline-block',
'-webkit-appearance': 'none', '-moz-appearance': 'none'}
_hover = {'text-decoration': 'none', 'cursor': 'pointer'}
Expand Down
13 changes: 9 additions & 4 deletions epyk/core/css/styles/classes/CssStylesInput.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
CSS Style module for the Input components
"""

from epyk.core.html import Defaults as Defaults_html
from epyk.core.css import Defaults as Defaults_css
Expand Down Expand Up @@ -87,11 +84,19 @@ class CssInputTextArea(CssStyle.Style):
def customize(self):
self.css({"background-color": self.rptObj.theme.colors[0], "color": self.rptObj.theme.greys[-1],
'border': '1px solid %s' % self.rptObj.theme.colors[1]})
self.hover.css.update({'color': self.rptObj.theme.greys[-1]})
self.hover.css({'color': self.rptObj.theme.greys[-1]})


class CssInputValid(CssStyle.Style):
_valid = {'color': 'red'}
_invalid = {'color': 'yellow', "background": "url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/check.svg)",
"background-size": "10px", "background-repeat": 'no-repeat', "background-position": "0"}


class CssUIActive(CssStyle.Style):
classname = "ui-state-active"

def customize(self):
self.css({"border": "1px solid %s" % self.rptObj.theme.success[1], 'background-color': self.rptObj.theme.success[1]}, important=True)
self.hover.css({"border": "1px solid %s" % self.rptObj.theme.success[1],
'background-color': self.rptObj.theme.success[1]})
1 change: 1 addition & 0 deletions epyk/core/html/HtmlButton.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import re
import json

Expand Down
2 changes: 2 additions & 0 deletions epyk/core/html/HtmlEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def style(self):
@property
def dom(self):
"""
Description:
-----------
The Javascript Dom object
:rtype: JsHtmlJqueryUI.JsHtmlSlider
Expand Down
2 changes: 1 addition & 1 deletion epyk/core/html/HtmlImage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

import re

from epyk.core.html import Html
Expand Down
22 changes: 22 additions & 0 deletions epyk/core/js/Js.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,28 @@ def __init__(self, src=None):
self.log = self.console.log
self._breadcrumb, self.__data, self.__location = None, None, None

@property
def viewHeight(self):
"""
Description:
-----------
Return the current View port height visible in the browser
"""
return JsNumber.JsNumber("Math.max(%s, %s)" % (self.documentElement.clientHeight, self.window.innerHeight))

@property
def documentElement(self):
"""
Description:
-----------
Document.documentElement returns the Element that is the root element of the document (for example, the <html> element for HTML documents).
Related Pages:
--------------
https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement
"""
return JsNodeDom.JsDoms.get("document.documentElement")

@property
def navigator(self):
"""
Expand Down
21 changes: 21 additions & 0 deletions epyk/core/js/fncs/JsFncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from epyk.core.js.objects import JsChartDC
from epyk.core.js.objects import JsChartPlotly

from epyk.core.js.primitives import JsObject

from epyk.core.js import JsUtils


Expand Down Expand Up @@ -526,3 +528,22 @@ def __str__(self):
:return:
"""
return "%s(%s)" % (self.fncName, ", ".join([str(a) for a in self.__jsArgs]))


class JsAnonymous(object):

def __init__(self, jsFncs):
self.__strFnc, self.__returnFnc = jsFncs, ""

def return_(self, value):
self.__returnFnc = value
return self

def call(self):
return JsObject.JsObject("%s()" % self)

def __str__(self):
return "(function () {%s; return %s})" % (self.__strFnc, self.__returnFnc)

def toStr(self):
return str(self.__strFnc)

0 comments on commit bc698f7

Please sign in to comment.