MCPcopy Create free account
hub / github.com/PageBot/PageBot / build_css

Method build_css

Lib/pagebot/contexts/htmlcontext/htmlbuilder.py:523–575  ·  view source on GitHub ↗

Build the CSS output for the defined selector and style.

(self, scss, selector=None, e=None, message=None)

Source from the content-addressed store, hash-verified

521 scss[scssId+'-color'] = e.css('textFill').css
522
523 def build_css(self, scss, selector=None, e=None, message=None):
524 """Build the CSS output for the defined selector and style."""
525 css = ''
526 attributes = []
527 if e:
528 style = e.style
529 if upt(e.ml):
530 attributes.append('margin-left: %s;' % e.ml)
531 if upt(e.mt):
532 attributes.append('margin-top: %s;' % e.mt)
533 if upt(e.mb):
534 attributes.append('margin-bottom: %s;' % e.mb)
535 if upt(e.mr):
536 attributes.append('margin-right: %s;' % e.mr)
537 if upt(e.pl):
538 attributes.append('padding-left: %s;' % e.pl)
539 if upt(e.pt):
540 attributes.append('padding-top: %s;' % e.pt)
541 if upt(e.pb):
542 attributes.append('padding-bottom: %s;' % e.pb)
543 if upt(e.pr):
544 attributes.append('padding-right: %s;' % e.pr)
545 if style.get('font') is not None:
546 attributes.append('font-family: "%s";' % style['font'])
547 if style.get('fontSize') is not None:
548 attributes.append('font-size: %s;' % style['fontSize'])
549 if style.get('fontStyle') is not None:
550 attributes.append('font-style: %s;' % style['fontStyle'])
551 if style.get('fontWeight') is not None:
552 attributes.append('font-weight: %s;' % style['fontWeight'])
553 if style.get('tracking') is not None:
554 attributes.append('letter-spacing: %s;' % style['tracking'])
555 if style.get('fill') not in (noColor, None): # Must Color instance
556 attributes.append('background-color: %s;' % style['fill'].css)
557 if style.get('textFill') not in (noColor, None): # Must be Color instance
558 attributes.append('color: %s;' % style['textFill'].css)
559 value = style.get('transition')
560 if value is not None:
561 attributes.append('transition=%s;' % value)
562 attributes.append('-webkit-transition=%s;' % value)
563 attributes.append('-moz-transition=%s;' % value)
564 attributes.append('-o-transition=%s;' % value)
565
566 if selector is not None and attributes:
567 css += '%s {\n\t%s} ' % (selector, '\n\t'.join(attributes))
568 if message is not None:
569 css += '/* %s */' % message
570 css += '\n'
571 self.addCss(css)
572
573 b = HtmlBuilder()
574 # Write all collected cSS vatiables into one file
575 b.writeScss(self.DEFAULT_CSS_PATH)
576
577
578 # H T M L

Callers

nothing calls this directly

Calls 6

addCssMethod · 0.95
writeScssMethod · 0.95
uptFunction · 0.90
HtmlBuilderClass · 0.85
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected