color.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <?php
  2. header("Content-type: text/css");
  3. require_once "../../../include/init.php";
  4. //https://gist.github.com/bedeabza/10463089
  5. function hexToHsl($hex) {
  6. $hex = array($hex[0].$hex[1], $hex[2].$hex[3], $hex[4].$hex[5]);
  7. $rgb = array_map(function($part) {
  8. return hexdec($part) / 255;
  9. }, $hex);
  10. $max = max($rgb);
  11. $min = min($rgb);
  12. $l = ($max + $min) / 2;
  13. if ($max == $min) {
  14. $h = $s = 0;
  15. } else {
  16. $diff = $max - $min;
  17. $s = $l > 0.5 ? $diff / (2 - $max - $min) : $diff / ($max + $min);
  18. switch($max) {
  19. case $rgb[0]:
  20. $h = ($rgb[1] - $rgb[2]) / $diff + ($rgb[1] < $rgb[2] ? 6 : 0);
  21. break;
  22. case $rgb[1]:
  23. $h = ($rgb[2] - $rgb[0]) / $diff + 2;
  24. break;
  25. case $rgb[2]:
  26. $h = ($rgb[0] - $rgb[1]) / $diff + 4;
  27. break;
  28. }
  29. $h /= 6;
  30. }
  31. return array(360*$h, 100*$s, 100*$l);
  32. }
  33. //$link = "hsl("..", ".."%, ".."%)";
  34. $color = hexToHsl($theme['lc']);
  35. $link = "hsl(".$color[0].", ".$color[1]."%, ".$color[2]."%)";
  36. $color = hexToHsl($theme['tx']);
  37. $text = "hsl(".$color[0].", ".$color[1]."%, ".$color[2]."%)";
  38. $color = hexToHsl($theme['bc']);
  39. $border = "hsl(".$color[0].", ".$color[1]."%, ".$color[2]."%)";
  40. $color = hexToHsl($theme['bg']);
  41. $background = "hsl(".$color[0].", ".$color[1]."%, ".$color[2]."%)";
  42. $backgroundDark = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] > 10 ? $color[2] - 10 : 0 )."%)";
  43. $backgroundDarker = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] > 18 ? $color[2] - 18 : 0 )."%)";
  44. $backgroundLight = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] < 90 ? $color[2] + 10 : 100 )."%)";
  45. $backgroundLighter = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] < 70 ? $color[2] + 30 : 100 )."%)";
  46. $backgroundL = $color[2];
  47. $color = hexToHsl($theme['fg']);
  48. $foreground = "hsl(".$color[0].", ".$color[1]."%, ".$color[2]."%)";
  49. $foregroundDark = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] > 10 ? $color[2] - 10 : 0 )."%)";
  50. $foregroundDarker = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] > 18 ? $color[2] - 18 : 0 )."%)";
  51. $foregroundLight = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] < 90 ? $color[2] + 10 : 100 )."%)";
  52. $foregroundLighter = "hsl(".$color[0].", ". $color[1] ."%, ".($color[2] < 82 ? $color[2] + 18 : 100 )."%)";
  53. $foregroundL = $color[2];
  54. ?>
  55. p,div,span {
  56. color:<?php echo $text; ?>;
  57. }
  58. a, .link {
  59. color: <?php echo $link; ?>;
  60. }
  61. textarea,input[type="text"],select,.flex{
  62. background-color: <?php echo ($foregroundL < 50 ? $foregroundLight : $foregroundDark) ?>;
  63. color:<?php echo $text; ?>;
  64. border:0px;
  65. }
  66. body {
  67. background-color: <?php echo $background; ?>;
  68. }
  69. label {
  70. color: gray;
  71. }
  72. input[type="radio"]:checked+label {
  73. color: black;
  74. }
  75. input[type="checkbox"]:checked+label {
  76. color: red;
  77. }
  78. .topbar {
  79. background-color: <?php echo $backgroundDarker ?>;
  80. }
  81. .gotop {
  82. background-color: rgba(255, 255, 255, 0.5);
  83. }
  84. .gotop a {
  85. color: <?php echo $link; ?>;
  86. }
  87. .topicon {
  88. color: <?php echo $backgroundLighter; ?>;
  89. }
  90. .toggleblur {
  91. background-color: <?php echo $link; ?>;
  92. color: <?php echo $foreground; ?>;
  93. }
  94. .polloption{
  95. display:block;
  96. margin:5px;
  97. padding:5px;
  98. background-color: <?php echo $foregroundLighter; ?>;
  99. color: <?php echo $link; ?>;
  100. }
  101. .polloption:hover:not(.fixed),.voted{
  102. cursor: pointer;
  103. background-color: <?php echo $foregroundDarker; ?>;
  104. color: white;
  105. }
  106. .voteBar{
  107. background-color: <?php echo $link; ?>;
  108. }
  109. .tiselected {
  110. border-bottom: 2px solid <?php echo $foreground; ?>;
  111. }
  112. .alert {
  113. background-color: red;
  114. }
  115. #notifications {
  116. background-color:<?php echo $foreground; ?>;
  117. box-shadow: 1px 1px 1px black;
  118. }
  119. .notif{
  120. border-bottom:<?php echo $theme['bw']; ?>px solid #<?php echo $theme['bc']; ?>;
  121. background-color:<?php echo $foreground; ?>;
  122. color:<?php echo $text; ?> !important;
  123. }
  124. .notif .post_buttons{
  125. background-color:<?php echo $foreground; ?>;
  126. }
  127. .notif .text{
  128. color:<?php echo $text; ?> !important;
  129. }
  130. input[type="submit"] {
  131. background-color: <?php echo $link; ?>;
  132. color: <?php echo $foreground; ?>;
  133. border:0px;
  134. }
  135. .new {
  136. background-color:<?php echo $foreground; ?>;
  137. }
  138. .side_element {
  139. background-color: #455f78;
  140. /*box-shadow: 1px 1px 1px black;*/
  141. }
  142. .side_element li:hover,.menu li:hover {
  143. background-color: <?php echo $backgroundDarker; ?> !important;
  144. }
  145. .side_element li:active {
  146. background-color: rgba(255, 255, 255, 0.25);
  147. }
  148. .uploadBox {
  149. box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
  150. }
  151. .delpic {
  152. color:red;
  153. background-color:white;
  154. }
  155. .formbtn {
  156. color:<?php echo $link; ?>;
  157. }
  158. .formbtn label{
  159. color:<?php echo $link; ?>;
  160. }
  161. .profile,.loader {
  162. background-color:<?php echo $topbar; ?>;
  163. color:<?php echo $foreground; ?>;
  164. }
  165. .listmenu li {
  166. background-color:black;
  167. color:white;
  168. }
  169. .listmenu li:hover {
  170. background-color:white;
  171. color:black;
  172. }
  173. .autl:hover li{
  174. background-color:lightgreen !important;
  175. }
  176. .rutl:hover li{
  177. background-color:crimson !important;
  178. }
  179. .unblock,.unmute,.block,.mute,.follow,
  180. .unfollow,
  181. .nsfw,
  182. .unnsfw,
  183. .profileMenu,
  184. .listmenu,.profileButton {
  185. background-color: black;
  186. color: white;
  187. cursor: pointer;
  188. }
  189. .mute:hover,.block:hover,.follow:hover,
  190. .nsfw:hover,.profileButton:hover {
  191. background-color: lime;
  192. }
  193. .unmute:hover,.unblock:hover,.unfollow:hover,
  194. .unnsfw:hover{
  195. background-color: crimson !important;
  196. }
  197. .unbookmark{
  198. color: crimson !important;
  199. }
  200. .unfav, .unreblog{
  201. color: red !important;
  202. }
  203. .element_pad > .post {
  204. border-left:2px solid <?php echo $link; ?>;
  205. }
  206. .post,
  207. .rb,
  208. .textonly,
  209. .loadmore,
  210. .postform,
  211. .side_element,
  212. .searchmobile
  213. {
  214. border: <?php echo $theme['bw']; ?>px solid #<?php echo $theme['bc']; ?>;
  215. border-radius: <?php echo $theme['br']; ?>px !important;
  216. background-color: <?php echo $foreground; ?>;
  217. box-shadow: <?php echo $theme['dr']; ?>px <?php echo $theme['dr']; ?>px <?php echo $theme['dr']; ?>px rgba(0,0,0,0.5);
  218. }
  219. .mobilemenu{
  220. background-color: <?php echo $foreground; ?>;
  221. border-left: 2px solid <?php echo $background; ?>;
  222. }
  223. .menu,.menu li {
  224. background-color: <?php echo ($foregroundL < 50 ? $foregroundLight : $foregroundDark) ?> !important;
  225. }
  226. .menu li:hover a {
  227. color: <?php echo $foreground; ?> !important;
  228. }
  229. .menu li a {
  230. color: <?php echo $link; ?> !important;
  231. }
  232. .menu {
  233. box-shadow: 1px 1px 2px black;
  234. }
  235. .previewpost,.userinfo {
  236. background-color: <?php echo ($foregroundL < 50 ? $foregroundLight : $foregroundDark) ?>;
  237. border: 1px solid <?php echo ($foregroundL < 50 ? $foregroundLight : $foregroundDark) ?>;
  238. box-shadow: 1px 1px 1px rgba(0,0,0,1);
  239. }
  240. .icon {
  241. background-color: black;
  242. }
  243. .post_footer {
  244. background-color: <?php echo ($foregroundL < 50 ? $foregroundLighter : $foregroundDarker) ?>;
  245. border-radius: 0px 0px <?php echo $theme['br']; ?>px <?php echo $theme['br']; ?>px;
  246. }
  247. .felem a:hover > span {
  248. color: <?php echo $backgroundLighter; ?>;
  249. background-color: <?php echo $backgroundDarker ?> !important;
  250. border: <?php echo $theme['bw']; ?>px solid #<?php echo $theme['bc']; ?>;
  251. border-radius:3px;
  252. }
  253. .public::after {
  254. content: '';
  255. }
  256. .unlisted::after {
  257. content: '';
  258. }
  259. .private::after {
  260. content: '';
  261. }
  262. .direct::after {
  263. content: '';
  264. }
  265. .sensitive::after {
  266. content: '';
  267. }
  268. .post_buttons {
  269. color: #404040;
  270. }
  271. .reply {
  272. background-color: <?php echo ($foregroundL < 50 ? $foregroundLighter : $foregroundDarker) ?>;
  273. border-bottom: 2px solid <?php echo $foreground; ?>;
  274. }
  275. .note {
  276. background-color: #ccc;
  277. }
  278. .button {
  279. background-color: white;
  280. }
  281. .setting label {
  282. background-color: lightgray;
  283. box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
  284. }
  285. .setting input[type="radio"]:checked+label,.setting input[type="checkbox"]:checked+label {
  286. background-color: <?php echo $link; ?>; ;
  287. box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  288. color: <?php echo $foreground; ?>; ;
  289. }