styleguide.ts 863 B

12345678910111213141516171819202122232425262728293031
  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. /** @ngInject **/
  11. constructor($http) {
  12. this.theme = config.bootData.user.lightTheme ? 'light': 'dark';
  13. $http.get('public/sass/styleguide.json').then(res => {
  14. this.colors = _.map(res.data[this.theme], (value, key) => {
  15. return {name: key, value: value};
  16. });
  17. });
  18. }
  19. switchTheme() {
  20. var other = this.theme === 'dark' ? 'light' : 'dark';
  21. window.location.href = config.appSubUrl + '/styleguide?theme=' + other;
  22. }
  23. }
  24. coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);