Advertisement
adolphuZ

Untitled

Jun 5th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. class CssBuilder:
  2.     def __init__(self):
  3.         self.css = ""
  4.  
  5.     def add_style(self, style):
  6.         self.css += style.render()
  7.  
  8.     def get_css(self):
  9.         return self.css
  10.  
  11. class CssStyle(ABC):
  12.     @abstractmethod
  13.     def render(self):
  14.         pass
  15.  
  16. class DivStyle(CssStyle):
  17.     def render(self):
  18.         return "div { margin: 10px; }\n"
  19.  
  20. class LabelStyle(CssStyle):
  21.     def render(self):
  22.         return "label { font-size: 14px; color: #333; }\n"
  23.  
  24. class InputStyle(CssStyle):
  25.     def render(self):
  26.         return "input[type='text'] { padding: 5px; }\n"
  27.  
  28. class SelectStyle(CssStyle):
  29.     def render(self):
  30.         return "select { width: 100px; }\n"
  31.  
  32. class SubmitStyle(CssStyle):
  33.     def render(self):
  34.         return "input[type='submit'] { background-color: #4CAF50; color: white; }\n"
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement