styleguide.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import coreModule from 'app/core/core_module';
  2. import config from 'app/core/config';
  3. import _ from 'lodash';
  4. class StyleGuideCtrl {
  5. colors: any = [];
  6. theme: string;
  7. buttonNames = ['primary', 'secondary', 'inverse', 'success', 'warning', 'danger'];
  8. buttonSizes = ['btn-small', '', 'btn-large'];
  9. buttonVariants = ['-', '-outline-'];
  10. page: any;
  11. pages = ['colors', 'buttons'];
  12. /** @ngInject **/
  13. constructor(private $http, $routeParams) {
  14. this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
  15. this.page = {};
  16. if ($routeParams.page) {
  17. this.page[$routeParams.page] = 1;
  18. } else {
  19. this.page.colors = true;
  20. }
  21. if (this.page.colors) {
  22. this.loadColors();
  23. }
  24. }
  25. loadColors() {
  26. this.$http.get('public/sass/styleguide.json').then(res => {
  27. this.colors = _.map(res.data[this.theme], (value, key) => {
  28. return {name: key, value: value};
  29. });
  30. });
  31. }
  32. switchTheme() {
  33. var other = this.theme === 'dark' ? 'light' : 'dark';
  34. window.location.href = window.location.href + '?theme=' + other;
  35. }
  36. }
  37. coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);