logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

button.style.js (3826B)


  1. export default {
  2. name: 'Button', // Name of the component
  3. selector: '.button-default', // CSS selector/prefix
  4. // outOfTreeSelector: '' // out-of-tree selector is used when other components are laid over it but it's not part of the tree, see Underlay component
  5. // States, system witll calculate ALL possible combinations of those and prepend "normal" to them + standalone "normal" state
  6. states: {
  7. // States are a bit expensive - the amount of combinations generated is about (1/6)n^3+n, so adding more state increased number of combination by an order of magnitude!
  8. // All states inherit from "normal" state, there is no other inheirtance, i.e. hover+disabled only inherits from "normal", not from hover nor disabled.
  9. // However, cascading still works, so resulting state will be result of merging of all relevant states/variants
  10. // normal: '' // normal state is implicitly added, it is always included
  11. toggled: '.toggled',
  12. pressed: ':active',
  13. hover: ':hover:not(:disabled)',
  14. focused: ':focus-within',
  15. disabled: ':disabled'
  16. },
  17. // Variants are mutually exclusive, each component implicitly has "normal" variant, and all other variants inherit from it.
  18. variants: {
  19. // Variants save on computation time since adding new variant just adds one more "set".
  20. // normal: '', // you can override normal variant, it will be appenended to the main class
  21. danger: '.danger'
  22. // Overall the compuation difficulty is N*((1/6)M^3+M) where M is number of distinct states and N is number of variants.
  23. // This (currently) is further multipled by number of places where component can exist.
  24. },
  25. // This lists all other components that can possibly exist within one. Recursion is currently not supported (and probably won't be supported ever).
  26. validInnerComponents: [
  27. 'Text',
  28. 'Icon'
  29. ],
  30. // Default rules, used as "default theme", essentially.
  31. defaultRules: [
  32. {
  33. component: 'Root',
  34. directives: {
  35. '--defaultButtonHoverGlow': 'shadow | 0 0 4 --text',
  36. '--defaultButtonShadow': 'shadow | 0 0 2 #000000',
  37. '--defaultButtonBevel': 'shadow | $borderSide(#FFFFFF, top, 0.2) | $borderSide(#000000, bottom, 0.2)',
  38. '--pressedButtonBevel': 'shadow | $borderSide(#FFFFFF, bottom, 0.2)| $borderSide(#000000, top, 0.2)'
  39. }
  40. },
  41. {
  42. // component: 'Button', // no need to specify components every time unless you're specifying how other component should look
  43. // like within it
  44. directives: {
  45. background: '--fg',
  46. shadow: ['--defaultButtonShadow', '--defaultButtonBevel'],
  47. roundness: 3
  48. }
  49. },
  50. {
  51. state: ['hover'],
  52. directives: {
  53. shadow: ['--defaultButtonHoverGlow', '--defaultButtonBevel']
  54. }
  55. },
  56. {
  57. state: ['pressed'],
  58. directives: {
  59. shadow: ['--defaultButtonShadow', '--pressedButtonBevel']
  60. }
  61. },
  62. {
  63. state: ['hover', 'pressed'],
  64. directives: {
  65. shadow: ['--defaultButtonHoverGlow', '--pressedButtonBevel']
  66. }
  67. },
  68. {
  69. state: ['toggled'],
  70. directives: {
  71. background: '--inheritedBackground,-14.2',
  72. shadow: ['--defaultButtonShadow', '--pressedButtonBevel']
  73. }
  74. },
  75. {
  76. state: ['toggled', 'hover'],
  77. directives: {
  78. background: '--inheritedBackground,-14.2',
  79. shadow: ['--defaultButtonHoverGlow', '--pressedButtonBevel']
  80. }
  81. },
  82. {
  83. state: ['disabled'],
  84. directives: {
  85. background: '$blend(--inheritedBackground, 0.25, --parent)',
  86. shadow: ['--defaultButtonBevel']
  87. }
  88. },
  89. {
  90. component: 'Text',
  91. parent: {
  92. component: 'Button',
  93. state: ['disabled']
  94. },
  95. directives: {
  96. textOpacity: 0.25,
  97. textOpacityMode: 'blend'
  98. }
  99. }
  100. ]
  101. }