logo

pleroma-fe

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

button.style.js (4444B)


  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. focused: ':focus-visible',
  13. pressed: ':focus:active',
  14. hover: ':hover:not(:disabled)',
  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. editor: {
  26. aspect: '2 / 1'
  27. },
  28. // This lists all other components that can possibly exist within one. Recursion is currently not supported (and probably won't be supported ever).
  29. validInnerComponents: [
  30. 'Text',
  31. 'Icon'
  32. ],
  33. // Default rules, used as "default theme", essentially.
  34. defaultRules: [
  35. {
  36. component: 'Root',
  37. directives: {
  38. '--buttonDefaultHoverGlow': 'shadow | 0 0 1 2 --text / 0.4',
  39. '--buttonDefaultFocusGlow': 'shadow | 0 0 1 2 --link / 0.5',
  40. '--buttonDefaultShadow': 'shadow | 0 0 2 #000000',
  41. '--buttonDefaultBevel': 'shadow | $borderSide(#FFFFFF top 0.2 1), $borderSide(#000000 bottom 0.2 1)',
  42. '--buttonPressedBevel': 'shadow | inset 0 0 4 #000000, $borderSide(#FFFFFF bottom 0.2 1), $borderSide(#000000 top 0.2 1)'
  43. }
  44. },
  45. {
  46. // component: 'Button', // no need to specify components every time unless you're specifying how other component should look
  47. // like within it
  48. directives: {
  49. background: '--fg',
  50. shadow: ['--buttonDefaultShadow', '--buttonDefaultBevel'],
  51. roundness: 3
  52. }
  53. },
  54. {
  55. state: ['hover'],
  56. directives: {
  57. shadow: ['--buttonDefaultHoverGlow', '--buttonDefaultBevel']
  58. }
  59. },
  60. {
  61. state: ['focused'],
  62. directives: {
  63. shadow: ['--buttonDefaultFocusGlow', '--buttonDefaultBevel']
  64. }
  65. },
  66. {
  67. state: ['pressed'],
  68. directives: {
  69. shadow: ['--buttonDefaultShadow', '--buttonPressedBevel']
  70. }
  71. },
  72. {
  73. state: ['pressed', 'hover'],
  74. directives: {
  75. shadow: ['--buttonPressedBevel', '--buttonDefaultHoverGlow']
  76. }
  77. },
  78. {
  79. state: ['toggled'],
  80. directives: {
  81. background: '--accent,-24.2',
  82. shadow: ['--buttonDefaultShadow', '--buttonPressedBevel']
  83. }
  84. },
  85. {
  86. state: ['toggled', 'hover'],
  87. directives: {
  88. background: '--accent,-24.2',
  89. shadow: ['--buttonDefaultHoverGlow', '--buttonPressedBevel']
  90. }
  91. },
  92. {
  93. state: ['toggled', 'disabled'],
  94. directives: {
  95. background: '$blend(--accent 0.25 --parent)',
  96. shadow: ['--buttonPressedBevel']
  97. }
  98. },
  99. {
  100. state: ['disabled'],
  101. directives: {
  102. background: '$blend(--accent 0.25 --parent)',
  103. shadow: ['--buttonDefaultBevel']
  104. }
  105. },
  106. {
  107. component: 'Text',
  108. parent: {
  109. component: 'Button',
  110. state: ['disabled']
  111. },
  112. directives: {
  113. textOpacity: 0.25,
  114. textOpacityMode: 'blend'
  115. }
  116. },
  117. {
  118. component: 'Icon',
  119. parent: {
  120. component: 'Button',
  121. state: ['disabled']
  122. },
  123. directives: {
  124. textOpacity: 0.25,
  125. textOpacityMode: 'blend'
  126. }
  127. }
  128. ]
  129. }