Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

theme-select.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export const ThemeSelect = {
  2. props: ['query'],
  3. template: `
  4. <div class="pv-built-css">
  5. <select ref="themeSelect" class="pv-built-css__select" @change="changeTheme($event)">
  6. <option v-for="theme in themes" :value="theme">{{theme}}.css</option>
  7. </select>
  8. <button class="pv-built-css__button" @click="download($event)">Download</button>
  9. </div>
  10. `,
  11. data() {
  12. return {
  13. themes: window.themes
  14. };
  15. },
  16. mounted() {
  17. if (this.query.theme) {
  18. this.$refs.themeSelect.value = this.query.theme;
  19. }
  20. },
  21. methods: {
  22. download(event) {
  23. const theme = this.$refs.themeSelect.value;
  24. if (!theme) {
  25. window.open('/onsen-css-components.css');
  26. } else {
  27. window.open(`${theme}.css`);
  28. }
  29. event.preventDefault();
  30. },
  31. changeTheme(event) {
  32. const theme = event.target.value;
  33. const suffix = this.query.platform ? `platform=${this.query.platform}` : '';
  34. if (theme === 'onsen-css-components') {
  35. if (suffix === '') {
  36. page.show(location.pathname);
  37. } else {
  38. page.show(`${location.pathname}?${suffix}`);
  39. }
  40. } else {
  41. page.show(`${location.pathname}?theme=${theme}${suffix === '' ? '' : `&${suffix}`}`);
  42. }
  43. }
  44. }
  45. };