@politicalwatch/tipi-uikit 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/.browserslistrc +2 -0
  2. package/.editorconfig +7 -0
  3. package/.eslintrc.js +11 -0
  4. package/.postcssrc.json +5 -0
  5. package/.prettierrc.js +7 -0
  6. package/.stylelintrc +24 -0
  7. package/README.md +21 -0
  8. package/package.json +45 -0
  9. package/src/assets/.gitkeep +0 -0
  10. package/src/assets/birthday_bg.png +0 -0
  11. package/src/assets/party_logos/bildu.png +0 -0
  12. package/src/assets/party_logos/bng.png +0 -0
  13. package/src/assets/party_logos/ca.jpeg +0 -0
  14. package/src/assets/party_logos/ciudadanos.png +0 -0
  15. package/src/assets/party_logos/compromis.jpg +0 -0
  16. package/src/assets/party_logos/cup.png +0 -0
  17. package/src/assets/party_logos/eajpnv.png +0 -0
  18. package/src/assets/party_logos/encomupodem.jpg +0 -0
  19. package/src/assets/party_logos/erc.png +0 -0
  20. package/src/assets/party_logos/fac.png +0 -0
  21. package/src/assets/party_logos/icon/bng.svg +4 -0
  22. package/src/assets/party_logos/icon/coalicioncanaria.svg +7 -0
  23. package/src/assets/party_logos/icon/compromis.svg +3 -0
  24. package/src/assets/party_logos/icon/cs.svg +3 -0
  25. package/src/assets/party_logos/icon/cup.svg +4 -0
  26. package/src/assets/party_logos/icon/ehbildu.svg +4 -0
  27. package/src/assets/party_logos/icon/encomu.svg +3 -0
  28. package/src/assets/party_logos/icon/erc.svg +5 -0
  29. package/src/assets/party_logos/icon/foroasturias.svg +4 -0
  30. package/src/assets/party_logos/icon/iu.svg +3 -0
  31. package/src/assets/party_logos/icon/jxcat.svg +3 -0
  32. package/src/assets/party_logos/icon/maspais.svg +3 -0
  33. package/src/assets/party_logos/icon/nuevacanaria.svg +3 -0
  34. package/src/assets/party_logos/icon/pdecat.svg +3 -0
  35. package/src/assets/party_logos/icon/pnv.svg +4 -0
  36. package/src/assets/party_logos/icon/podemos.svg +3 -0
  37. package/src/assets/party_logos/icon/pp.svg +4 -0
  38. package/src/assets/party_logos/icon/prc.svg +5 -0
  39. package/src/assets/party_logos/icon/psoe.svg +3 -0
  40. package/src/assets/party_logos/icon/sumar.svg +73 -0
  41. package/src/assets/party_logos/icon/teruelexiste.svg +3 -0
  42. package/src/assets/party_logos/icon/unidaspodemos.svg +27 -0
  43. package/src/assets/party_logos/icon/upn.svg +5 -0
  44. package/src/assets/party_logos/icon/vox.svg +4 -0
  45. package/src/assets/party_logos/iu.png +0 -0
  46. package/src/assets/party_logos/jxcat.png +0 -0
  47. package/src/assets/party_logos/mas-pais.jpg +0 -0
  48. package/src/assets/party_logos/nueva_canarias.png +0 -0
  49. package/src/assets/party_logos/pdecat.png +0 -0
  50. package/src/assets/party_logos/podemos.jpg +0 -0
  51. package/src/assets/party_logos/pp.png +0 -0
  52. package/src/assets/party_logos/prc.png +0 -0
  53. package/src/assets/party_logos/psc.png +0 -0
  54. package/src/assets/party_logos/pse-ee.png +0 -0
  55. package/src/assets/party_logos/psoe.png +0 -0
  56. package/src/assets/party_logos/teruelexiste.svg +4 -0
  57. package/src/assets/party_logos/unidaspodemos.png +0 -0
  58. package/src/assets/party_logos/upn.jpg +0 -0
  59. package/src/assets/party_logos/vox.png +0 -0
  60. package/src/assets/svg/icon-advanced.svg +3 -0
  61. package/src/assets/svg/icon-bell.svg +3 -0
  62. package/src/assets/svg/icon-birthday.svg +18 -0
  63. package/src/assets/svg/icon-building.svg +3 -0
  64. package/src/assets/svg/icon-calendar.svg +4 -0
  65. package/src/assets/svg/icon-chevron-down.svg +3 -0
  66. package/src/assets/svg/icon-chevron-left.svg +3 -0
  67. package/src/assets/svg/icon-chevron-right.svg +3 -0
  68. package/src/assets/svg/icon-chevron-up.svg +3 -0
  69. package/src/assets/svg/icon-clock.svg +4 -0
  70. package/src/assets/svg/icon-close-menu.svg +3 -0
  71. package/src/assets/svg/icon-close.svg +3 -0
  72. package/src/assets/svg/icon-conversation.svg +3 -0
  73. package/src/assets/svg/icon-denied.svg +3 -0
  74. package/src/assets/svg/icon-document.svg +4 -0
  75. package/src/assets/svg/icon-download.svg +3 -0
  76. package/src/assets/svg/icon-error.svg +3 -0
  77. package/src/assets/svg/icon-github.svg +9 -0
  78. package/src/assets/svg/icon-hamburger.svg +1 -0
  79. package/src/assets/svg/icon-info.svg +3 -0
  80. package/src/assets/svg/icon-less.svg +3 -0
  81. package/src/assets/svg/icon-location.svg +3 -0
  82. package/src/assets/svg/icon-mail.svg +4 -0
  83. package/src/assets/svg/icon-more.svg +5 -0
  84. package/src/assets/svg/icon-open-blank.svg +3 -0
  85. package/src/assets/svg/icon-plus.svg +3 -0
  86. package/src/assets/svg/icon-search.svg +4 -0
  87. package/src/assets/svg/icon-success.svg +3 -0
  88. package/src/assets/svg/icon-twitter.svg +3 -0
  89. package/src/assets/svg/icon-upload.svg +3 -0
  90. package/src/components/CSVDownload/CSVDownload.vue +77 -0
  91. package/src/components/Charts/Barchart/d3.barchart.js +488 -0
  92. package/src/components/Charts/Barchart/d3.barchart.vue +16 -0
  93. package/src/components/Charts/Sliceschart/d3.sliceschart.js +272 -0
  94. package/src/components/Charts/Sliceschart/d3.sliceschart.vue +20 -0
  95. package/src/components/Charts/Sunburst/d3.sunburst.js +416 -0
  96. package/src/components/Charts/Sunburst/d3.sunburst.vue +23 -0
  97. package/src/components/Charts/WordsCloud/d3.wordscloud.js +336 -0
  98. package/src/components/Charts/WordsCloud/d3.wordscloud.vue +16 -0
  99. package/src/components/Charts/d3.chart.js +242 -0
  100. package/src/components/Charts/d3.chart.vue +80 -0
  101. package/src/components/Charts/styles.scss +92 -0
  102. package/src/components/CongressLink/CongressLink.vue +17 -0
  103. package/src/components/Deputy/Deputy.vue +119 -0
  104. package/src/components/Header/Header.vue +15 -0
  105. package/src/components/Icon/Icon.vue +33 -0
  106. package/src/components/InitiativeCard/InitiativeCard.vue +98 -0
  107. package/src/components/InitiativeMeta/InitiativeMeta.vue +85 -0
  108. package/src/components/Loader/Loader.vue +27 -0
  109. package/src/components/Message/Message.vue +29 -0
  110. package/src/components/Navbar/Navbar.vue +96 -0
  111. package/src/components/Neuron/Neuron.vue +209 -0
  112. package/src/components/PartyLogo/PartyLogo.vue +59 -0
  113. package/src/components/PartyLogo/PartyLogoIcon.vue +229 -0
  114. package/src/components/Results/Results.vue +109 -0
  115. package/src/components/Splash/Splash.vue +42 -0
  116. package/src/components/Text/Text.vue +59 -0
  117. package/src/components/TipiCharts/TipiBarchart.vue +204 -0
  118. package/src/components/TopicCard/TopicCard.vue +40 -0
  119. package/src/components/TopicLink/TopicLink.vue +33 -0
  120. package/src/components/TopicPill/TopicPill.vue +69 -0
  121. package/src/components/Topics/Topics.vue +84 -0
  122. package/src/components/TwoCircles/TwoCircles.vue +138 -0
  123. package/src/components/index.js +53 -0
  124. package/src/main.js +11 -0
  125. package/src/styles/01_settings/_settings__breakpoints.scss +28 -0
  126. package/src/styles/01_settings/_settings__colors.scss +30 -0
  127. package/src/styles/01_settings/_settings__fonts.scss +3 -0
  128. package/src/styles/01_settings/_settings__icons.scss +0 -0
  129. package/src/styles/01_settings/_settings__variables.scss +45 -0
  130. package/src/styles/02_tools/_tools__functions.scss +19 -0
  131. package/src/styles/02_tools/_tools__mixins.scss +321 -0
  132. package/src/styles/03_generic/_generic__box-sizing.scss +12 -0
  133. package/src/styles/03_generic/_generic__global.scss +20 -0
  134. package/src/styles/03_generic/_generic__normalize.scss +371 -0
  135. package/src/styles/04_base/_base__anchors.scss +8 -0
  136. package/src/styles/04_base/_base__blockquotes.scss +8 -0
  137. package/src/styles/04_base/_base__forms.scss +32 -0
  138. package/src/styles/04_base/_base__headings.scss +23 -0
  139. package/src/styles/04_base/_base__images.scss +4 -0
  140. package/src/styles/04_base/_base__lists.scss +66 -0
  141. package/src/styles/04_base/_base__paragraphs.scss +11 -0
  142. package/src/styles/04_base/_base__tables.scss +95 -0
  143. package/src/styles/05_objects/_objects__columns.scss +29 -0
  144. package/src/styles/05_objects/_objects__container.scss +19 -0
  145. package/src/styles/05_objects/_objects__grid.scss +57 -0
  146. package/src/styles/05_objects/_objects__masonry.scss +11 -0
  147. package/src/styles/05_objects/_objects__media.scss +24 -0
  148. package/src/styles/05_objects/_objects__section.scss +21 -0
  149. package/src/styles/06_components/_components__button.scss +178 -0
  150. package/src/styles/06_components/_components__congress-link.scss +12 -0
  151. package/src/styles/06_components/_components__decorator.scss +10 -0
  152. package/src/styles/06_components/_components__deputy.scss +167 -0
  153. package/src/styles/06_components/_components__disclaimer.scss +24 -0
  154. package/src/styles/06_components/_components__forms.scss +454 -0
  155. package/src/styles/06_components/_components__header.scss +36 -0
  156. package/src/styles/06_components/_components__icon.scss +17 -0
  157. package/src/styles/06_components/_components__initiative-card.scss +49 -0
  158. package/src/styles/06_components/_components__initiative-meta.scss +91 -0
  159. package/src/styles/06_components/_components__loader.scss +125 -0
  160. package/src/styles/06_components/_components__menu.scss +104 -0
  161. package/src/styles/06_components/_components__message.scss +66 -0
  162. package/src/styles/06_components/_components__navbar.scss +114 -0
  163. package/src/styles/06_components/_components__party-logo.scss +21 -0
  164. package/src/styles/06_components/_components__splash.scss +29 -0
  165. package/src/styles/06_components/_components__text.scss +69 -0
  166. package/src/styles/06_components/_components__topic-card.scss +36 -0
  167. package/src/styles/06_components/_components__topic-link.scss +37 -0
  168. package/src/styles/06_components/_components__topics.scss +107 -0
  169. package/src/styles/07_trumps/_trumps__borders.scss +1 -0
  170. package/src/styles/07_trumps/_trumps__colors.scss +3 -0
  171. package/src/styles/07_trumps/_trumps__grid.scss +1 -0
  172. package/src/styles/07_trumps/_trumps__helpers.scss +17 -0
  173. package/src/styles/07_trumps/_trumps__texts.scss +39 -0
  174. package/src/styles/07_trumps/_trumps__visibility.scss +56 -0
  175. package/src/styles/main.scss +54 -0
  176. package/src/utils/index.js +26 -0
  177. package/svgo.config.js +16 -0
  178. package/vite.config.js +57 -0
@@ -0,0 +1,209 @@
1
+ <template>
2
+ <svg v-if="topics" style="width: 100%; height: 200px;"></svg>
3
+ </template>
4
+
5
+ <script>
6
+ import { select } from 'd3-selection';
7
+ import { easeBackOut } from 'd3-ease';
8
+
9
+ export default {
10
+ name: 'TipiNeuron',
11
+ props: {
12
+ initiative: Object,
13
+ topics: Array,
14
+ styles: {
15
+ type: Object,
16
+ default: function() {
17
+ return { topics: {}, defaultColor: '#cecece' };
18
+ },
19
+ },
20
+ },
21
+ methods: {
22
+ loadVizz: function(topics, initiative, styles, color = { center: '#222' }) {
23
+ //Mapping ranges
24
+ function map(x, in_min, in_max, out_min, out_max) {
25
+ return ((x - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
26
+ }
27
+
28
+ //Converting polar coordinates to cartesian coordinates
29
+ function polar(angle, radius) {
30
+ return [Math.cos(angle) * radius, Math.sin(angle) * radius];
31
+ }
32
+
33
+ //Calculate the transform of a node
34
+ function calculateTransform(d, i) {
35
+ let pos = calculatePosition(d, i);
36
+ return `translate(${pos[0]},${pos[1]})`;
37
+ }
38
+
39
+ //Calculate the position of a node
40
+ function calculatePosition(d, i) {
41
+ let angle = map(i, 0, data.length, 0, Math.PI * 2);
42
+ let pos = polar(angle, d['related'] ? 100 : 75);
43
+ return [pos[0] + width / 2, pos[1] + height / 2];
44
+ }
45
+
46
+ //Configurations
47
+ color = {
48
+ related: {
49
+ 'ODS 1': '#eb1c2d',
50
+ 'ODS 2': '#d3a029',
51
+ 'ODS 3': '#4c9f38',
52
+ 'ODS 4': '#c52333',
53
+ 'ODS 5': '#ed4135',
54
+ 'ODS 6': '#00aed9',
55
+ 'ODS 7': '#fdb713',
56
+ 'ODS 8': '#8f1838',
57
+ 'ODS 9': '#f06a38',
58
+ 'ODS 10': '#dd1367',
59
+ 'ODS 11': '#f69c39',
60
+ 'ODS 12': '#cf8d2a',
61
+ 'ODS 13': '#48773e',
62
+ 'ODS 14': '#007dbc',
63
+ 'ODS 15': '#5cb84d',
64
+ 'ODS 16': '#02558b',
65
+ 'ODS 17': '#183668',
66
+ },
67
+ notRelated: '#cecece',
68
+ center: '#222',
69
+ line: '#cecece',
70
+ };
71
+
72
+ //TODO: Encapsulate this in a class so we can have multiple vizualisations in one page.
73
+ //Globals
74
+ let data = [];
75
+ let svg = select(this.$el);
76
+ svg.selectAll('*').remove();
77
+ let width = +svg.node().getBoundingClientRect().width;
78
+ let height = +svg.node().getBoundingClientRect().height;
79
+ function onDataReady(topics, initiative) {
80
+ for (let d = 0; d < topics.length; d++) {
81
+ let newNode = { name: topics[d].name, related: false, intensity: 0 };
82
+ for (let t = 0; t < initiative['topics'].length; t++) {
83
+ if (initiative['topics'][t] == newNode['name']) {
84
+ newNode['related'] = true;
85
+ }
86
+ }
87
+
88
+ for (let i = 0; i < initiative['tags'].length; i++) {
89
+ if (initiative['tags'][i]['topic'] == newNode['name']) {
90
+ newNode['intensity']++;
91
+ }
92
+ }
93
+ //intensity goes from 0 to 1 (percentage of tags)
94
+ newNode['intensity'] = newNode['intensity'] / initiative['tags'].length;
95
+ data.push(newNode);
96
+ }
97
+ createNodes();
98
+ }
99
+
100
+ function createNodes() {
101
+ svg
102
+ .selectAll('.connection')
103
+ .data(data)
104
+ .enter()
105
+ .append('path')
106
+ .transition()
107
+ .duration(700)
108
+ .delay((d, i) => i * i + 500)
109
+ .ease(easeBackOut)
110
+ .attr('d', (d, i) => {
111
+ let pos = calculatePosition(d, i);
112
+ return 'M ' + width / 2 + ' ' + height / 2 + 'L ' + pos[0] + ' ' + pos[1];
113
+ })
114
+ .attr('stroke-width', d => (d['related'] ? '3px' : '1px'))
115
+ .attr('stroke', d =>
116
+ d['related'] && styles.topics[d['name']]
117
+ ? styles.topics[d['name']].color
118
+ : styles.defaultColor
119
+ );
120
+
121
+ let node = svg
122
+ .selectAll('.node')
123
+ .data(data)
124
+ .enter()
125
+ .append('g')
126
+ .attr('class', 'node')
127
+ .attr('transform', () => `translate(${width / 2},${height / 2})`);
128
+
129
+ node
130
+ .transition()
131
+ .duration(700)
132
+ .delay((d, i) => i * i)
133
+ .ease(easeBackOut)
134
+ .attr('transform', calculateTransform);
135
+
136
+ node
137
+ .append('circle')
138
+ .attr('class', d => (d['related'] ? 'related' : ''))
139
+ .attr('r', d => (d['related'] ? 15 : 10))
140
+ .style('fill', d =>
141
+ d['related'] && styles.topics[d['name']]
142
+ ? styles.topics[d['name']].color
143
+ : styles.defaultColor
144
+ );
145
+
146
+ node
147
+ .append('path')
148
+ .attr(
149
+ 'd',
150
+ d3
151
+ .arc()
152
+ .innerRadius(d => (d['related'] ? 20 : 15))
153
+ .outerRadius(d => (d['related'] ? 25 : 20))
154
+ .startAngle(0)
155
+ .endAngle(d => Math.PI * 2 * d['intensity'])
156
+ )
157
+ .attr('class', d => (d['related'] ? 'related' : ''))
158
+ .style('fill', d =>
159
+ d['related'] && styles.topics[d['name']]
160
+ ? styles.topics[d['name']].color
161
+ : styles.defaultColor
162
+ );
163
+
164
+ node
165
+ .append('text')
166
+ .attr('class', 'label_name')
167
+ .attr('text-anchor', 'middle')
168
+ .attr('alignment-baseline', 'central')
169
+ .text(d => (d['related'] ? d['name'].split('-')[0].trim() : ''));
170
+
171
+ let center = svg
172
+ .append('g')
173
+ .attr('class', 'center')
174
+ .attr('transform', `translate(${width / 2},${height / 2})`);
175
+
176
+ center
177
+ .append('circle')
178
+ .attr('r', 5)
179
+ .attr('fill', color['center'])
180
+ .transition()
181
+ .duration(700)
182
+ .ease(easeBackOut)
183
+ .attr('r', 20);
184
+ }
185
+ onDataReady(topics, initiative);
186
+ },
187
+ },
188
+ watch: {
189
+ $route: function() {
190
+ this.loadVizz(this.$props.topics, this.$props.initiative, this.$props.styles);
191
+ },
192
+ },
193
+ mounted: function() {
194
+ this.loadVizz(this.$props.topics, this.$props.initiative, this.$props.styles);
195
+ },
196
+ };
197
+ </script>
198
+
199
+ <style lang="scss">
200
+ .node {
201
+ font-family: Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif;
202
+ font-size: 10px;
203
+
204
+ .label_name {
205
+ font-size: 13px;
206
+ font-weight: bold;
207
+ }
208
+ }
209
+ </style>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <div class="c-party_logo__container">
3
+ <img class="c-party_logo__image" :src="getLogoSrc()" :alt="'Logo de ' + party"/>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'PartyLogo',
10
+ data: function () {
11
+ return {
12
+ logos: {
13
+ 'Vox': 'vox.png',
14
+ '¡Teruel Existe!': 'teruelexiste.svg',
15
+ 'UPN': 'upn.jpg',
16
+ 'UP': 'unidaspodemos.png',
17
+ 'PsdeG-PSOE': 'psoe.png',
18
+ 'PSOE': 'psoe.png',
19
+ 'PSE-EE-PSOE': 'pse-ee.png',
20
+ 'PSC-PSOE': 'psc.png',
21
+ 'PRC': 'prc.png',
22
+ 'PP - FORO': 'pp.png',
23
+ 'PP': 'pp.png',
24
+ 'PDeCAT': 'pdecat.png',
25
+ 'NC-CCa-PNC': 'nueva_canarias.png',
26
+ 'MÉS COMPROMÍS': 'compromis.jpg',
27
+ 'MÁS PAÍS-EQUO': 'mas-pais.jpg',
28
+ 'JxCat-JUNTS': 'jxcat.png',
29
+ 'IU': 'iu.png',
30
+ 'FAC': 'fac.png',
31
+ 'ERC-S': 'erc.png',
32
+ 'EH Bildu': 'bildu.png',
33
+ 'ECP-GUAYEM EL CANVI': 'encomupodem.jpg',
34
+ 'EC-UP': 'podemos.jpg',
35
+ 'EAJ-PNV': 'eajpnv.png',
36
+ 'Cs': 'ciudadanos.png',
37
+ 'CUP-PR': 'cup.png',
38
+ 'CCa-NC': 'ca.jpeg',
39
+ 'BNG': 'bng.png',
40
+ },
41
+ };
42
+ },
43
+ props: {
44
+ party: String,
45
+ },
46
+ methods: {
47
+ getLogoSrc: function () {
48
+ let logo = '';
49
+ if (this.party in this.logos) {
50
+ logo = import(`../../assets/party_logos/${this.logos[this.party]}`);
51
+ }
52
+ return logo;
53
+ },
54
+ },
55
+ };
56
+ </script>
57
+
58
+ <style scoped lang="scss">
59
+ </style>
@@ -0,0 +1,229 @@
1
+ <template>
2
+ <div class="c-party_logo_icon" :style="getBackground">
3
+ <figure class="c-party_logo_icon__image" :alt="'Logo de ' + getName">
4
+ <component :is="svg"></component>
5
+ </figure>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import { defineAsyncComponent } from 'vue';
11
+
12
+ export default {
13
+ name: 'PartyLogoIcon',
14
+ props: {
15
+ party: String,
16
+ },
17
+ data: function() {
18
+ return {
19
+ parties: {
20
+ Cs: {
21
+ name: 'Ciudadanos',
22
+ logo: 'cs',
23
+ color: '#ff4f00',
24
+ },
25
+ VOX: {
26
+ name: 'VOX',
27
+ logo: 'vox',
28
+ color: '#5ac035',
29
+ },
30
+ ERC: {
31
+ name: 'Esquerra Republicana',
32
+ logo: 'erc',
33
+ color: '#ffbf41',
34
+ },
35
+ 'ERC-S': {
36
+ name: 'Esquerra Republicana',
37
+ logo: 'erc',
38
+ color: '#ffbf41',
39
+ },
40
+ PP: {
41
+ name: 'Partido Popular',
42
+ logo: 'pp',
43
+ color: '#0056a3',
44
+ },
45
+ 'PP - FORO': {
46
+ name: 'Partido Popular',
47
+ logo: 'pp',
48
+ color: '#0056a3',
49
+ },
50
+ 'MÉS COMPROMÍS': {
51
+ name: 'Compromís',
52
+ logo: 'compromis',
53
+ color: 'linear-gradient(204deg, #f29127 100%, #ec8427 80%, #de6527 42%, #d13b27 3%)',
54
+ },
55
+ 'MÁS PAÍS-EQUO': {
56
+ name: 'Más País',
57
+ logo: 'maspais',
58
+ color: '#0a7565',
59
+ },
60
+ PDeCAT: {
61
+ name: 'Partit Demòcrata',
62
+ logo: 'pdecat',
63
+ color: '#114488',
64
+ },
65
+ 'JxCAT-JUNTS': {
66
+ name: 'Junts per Catalunya',
67
+ logo: 'jxcat',
68
+ color: '#40e0d0',
69
+ },
70
+ 'JxCat-JUNTS (Junts)': {
71
+ name: 'Junts per Catalunya',
72
+ logo: 'jxcat',
73
+ color: '#40e0d0',
74
+ },
75
+ BNG: {
76
+ name: 'Bloque Nacionalista Galego',
77
+ logo: 'bng',
78
+ color: '#76b3dd',
79
+ },
80
+ SUMAR: {
81
+ name: 'SUMAR',
82
+ logo: 'sumar',
83
+ color: '#e51c55',
84
+ },
85
+ UP: {
86
+ name: 'Unidas Podemos',
87
+ logo: 'unidaspodemos',
88
+ color: '#ffffff',
89
+ },
90
+ 'EC-UP': {
91
+ name: 'Podemos',
92
+ logo: 'podemos',
93
+ color: '#6b1f5f',
94
+ },
95
+ IU: {
96
+ name: 'Izquierda Unida',
97
+ logo: 'iu',
98
+ color: '#b1132f',
99
+ },
100
+ 'ECP-GUAYEM EL CANVI': {
101
+ name: 'En Comú Podem',
102
+ logo: 'encomu',
103
+ color: 'linear-gradient(135deg, #dc2a15 15%, #6d2d5c 85%)',
104
+ },
105
+ CCa: {
106
+ name: 'Coalición Canaria',
107
+ logo: 'coalicioncanaria',
108
+ color: '#02abd6',
109
+ },
110
+ 'CCa-NC': {
111
+ name: 'Coalición Canaria',
112
+ logo: 'coalicioncanaria',
113
+ color: '#02abd6',
114
+ },
115
+ 'NC-CCa-PNC': {
116
+ name: 'Nueva Canaria',
117
+ logo: 'nuevacanaria',
118
+ color: '#81c045',
119
+ },
120
+ 'CUP-PR': {
121
+ name: "Candidatura d'Unitat Popular",
122
+ logo: 'cup',
123
+ color: '#fff200',
124
+ },
125
+ UPN: {
126
+ name: 'Unión del Pueblo Navarro',
127
+ logo: 'upn',
128
+ color: '#0856b3',
129
+ },
130
+ '¡Teruel Existe!': {
131
+ name: 'Teruel Existe',
132
+ logo: 'teruelexiste',
133
+ color: '#227e57',
134
+ },
135
+ FAC: {
136
+ name: 'Foro Asturias',
137
+ logo: 'foroasturias',
138
+ color: '#19375b',
139
+ },
140
+ PRC: {
141
+ name: 'Partido Regionalista de Cantabria',
142
+ logo: 'prc',
143
+ color: '#bfcd16',
144
+ },
145
+ PSOE: {
146
+ name: 'Partido Socialista Obrero Español',
147
+ logo: 'psoe',
148
+ color: '#e30613',
149
+ },
150
+ 'PSC-PSOE': {
151
+ name: 'Partido Socialista Obrero Español',
152
+ logo: 'psoe',
153
+ color: '#e30613',
154
+ },
155
+ 'PSE-EE-PSOE': {
156
+ name: 'Partido Socialista Obrero Español',
157
+ logo: 'psoe',
158
+ color: '#e30613',
159
+ },
160
+ 'PsdeG-PSOE': {
161
+ name: 'Partido Socialista Obrero Español',
162
+ logo: 'psoe',
163
+ color: '#e30613',
164
+ },
165
+ 'EAJ-PNV': {
166
+ name: 'Partido Nacionalista Vasco',
167
+ logo: 'pnv',
168
+ color: 'linear-gradient(135deg, #dc2a15 15%, #6d2d5c 85%)',
169
+ },
170
+ 'EH Bildu': {
171
+ name: 'Euskal Herria Bildu',
172
+ logo: 'ehbildu',
173
+ color: '#b4cc16',
174
+ },
175
+ },
176
+ };
177
+ },
178
+ computed: {
179
+ svg() {
180
+ let svg = '';
181
+ try {
182
+ svg = defineAsyncComponent(() =>
183
+ import(`../../assets/party_logos/icon/${this.parties[this.party].logo}.svg`)
184
+ );
185
+ } catch (error) {
186
+ svg = this.icon;
187
+ }
188
+ return svg;
189
+ },
190
+ getBackground: function() {
191
+ const bg = this.parties[this.party]?.color ? this.parties[this.party].color : '';
192
+ if (bg.length == 7) {
193
+ return 'background-color:' + bg;
194
+ }
195
+ return 'background-image:' + bg;
196
+ },
197
+ getName: function() {
198
+ return this.parties[this.party]?.name ? this.parties[this.party].name : '';
199
+ },
200
+ },
201
+ };
202
+ </script>
203
+
204
+ <style scoped lang="scss">
205
+ .c-party_logo_icon {
206
+ display: block;
207
+ border-radius: 50%;
208
+ object-fit: cover;
209
+ width: 5rem;
210
+ height: 5rem;
211
+ position: absolute;
212
+ left: -1.25rem;
213
+ bottom: -1.25rem;
214
+ border-radius: 50%;
215
+ overflow: hidden;
216
+ }
217
+
218
+ .c-party_logo_icon__image {
219
+ position: absolute;
220
+ margin: 0;
221
+ top: calc(50% - 1.5rem);
222
+ left: calc(50% - 1.5rem);
223
+
224
+ svg {
225
+ width: 3rem;
226
+ height: 3rem;
227
+ }
228
+ }
229
+ </style>
@@ -0,0 +1,109 @@
1
+ <template>
2
+ <div>
3
+ <tipi-loader
4
+ v-if="this.loadingResults"
5
+ title="Cargando resultados"
6
+ subtitle="Puede llevar algun tiempo"
7
+ />
8
+ <section
9
+ class="o-masonry o-grid"
10
+ v-if="this.initiatives && this.initiatives.length && !this.loadingResults"
11
+ >
12
+ <div
13
+ class="o-grid__col u-12 u-4@sm o-masonry__item"
14
+ v-for="(initiative, index) in this.initiatives"
15
+ :key="index"
16
+ >
17
+ <tipi-initiative-card
18
+ :initiative="initiative"
19
+ :extendedLayout="extendedLayout"
20
+ :topicsStyles="topicsStyles"
21
+ :metaDeputies="metaDeputies"
22
+ :metaGroupsOthers="metaGroupsOthers"
23
+ :metaColors="metaColors"
24
+ />
25
+ </div>
26
+ </section>
27
+ <div class="o-grid o-grid--center" v-if="this.$listeners.loadMore && isMoreResults">
28
+ <div class="o-grid__col">
29
+ <a href="#" class="c-button c-button--secondary" @click.prevent="loadMore">
30
+ Cargar más {{ nextResultsLabel }}
31
+ </a>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </template>
36
+
37
+ <script>
38
+ import TipiInitiativeCard from '../InitiativeCard/InitiativeCard.vue';
39
+ import TipiLoader from '../Loader/Loader.vue';
40
+ import Masonry from 'masonry-layout';
41
+
42
+ export default {
43
+ name: 'TipiResults',
44
+ components: {
45
+ TipiInitiativeCard,
46
+ TipiLoader,
47
+ },
48
+ props: {
49
+ loadingResults: Boolean,
50
+ initiatives: {
51
+ type: Array,
52
+ default: function() {
53
+ return [];
54
+ },
55
+ },
56
+ queryMeta: Object,
57
+ layout: String,
58
+ topicsStyles: Object,
59
+ metaDeputies: { type: String, default: 'Diputada/o' },
60
+ metaGroupsOthers: { type: String, default: 'Autor' },
61
+ metaColors: { type: Object, default: undefined },
62
+ },
63
+ computed: {
64
+ isMoreResults: function() {
65
+ return !this.loadingResults && this.queryMeta.page < this.queryMeta.pages;
66
+ },
67
+ nextResultsLabel: function() {
68
+ let nextResult = this.queryMeta.page * this.queryMeta.per_page + 1;
69
+ let lastResult = nextResult + this.queryMeta.per_page - 1;
70
+ return `(${nextResult}-${lastResult})`;
71
+ },
72
+ extendedLayout: function() {
73
+ return this.layout != 'tiny';
74
+ },
75
+ },
76
+ methods: {
77
+ loadMore: function() {
78
+ this.$emit('loadMore');
79
+ },
80
+ setupMasonry: function() {
81
+ let grid = document.querySelector('.o-masonry');
82
+ if (grid) {
83
+ let msnry = new Masonry(grid, {
84
+ columnWidth: '.o-masonry__item',
85
+ percentPosition: true,
86
+ itemSelector: '.o-masonry__item',
87
+ });
88
+ msnry.layout();
89
+ }
90
+ },
91
+ },
92
+ watch: {
93
+ initiatives: function() {
94
+ if (this.initiatives && this.initiatives.length && !this.loadingResults) {
95
+ this.setupMasonry();
96
+ }
97
+ },
98
+ },
99
+ mounted: function() {
100
+ this.setupMasonry();
101
+ window.addEventListener(
102
+ 'resize',
103
+ function() {
104
+ this.setupMasonry();
105
+ }.bind(this)
106
+ );
107
+ },
108
+ };
109
+ </script>
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div class="c-splash" v-if="!closedSplash">
3
+ <div class="c-splash__outer">
4
+ <div class="c-splash__inner">
5
+ <slot></slot>
6
+ <p><a class="c-splash__close" :class="closeClass" href="#" @click="closeSplash">{{ closeText }}</a></p>
7
+ </div>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ name: 'TipiSplash',
15
+ props: {
16
+ closeClass: {
17
+ type: String,
18
+ default: 'c-button c-button--primary',
19
+ },
20
+ closeText: {
21
+ type: String,
22
+ default: 'Comenzar',
23
+ },
24
+ },
25
+ data: function () {
26
+ return {
27
+ closedMessage: false,
28
+ };
29
+ },
30
+ computed: {
31
+ closedSplash: function () {
32
+ return JSON.parse(window.sessionStorage.getItem('closedSplash')) || this.closedMessage ? true : false;
33
+ },
34
+ },
35
+ methods: {
36
+ closeSplash: function() {
37
+ window.sessionStorage.setItem('closedSplash', true);
38
+ this.closedMessage = true;
39
+ },
40
+ },
41
+ };
42
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <div class="c-text" v-if="is(value)">
3
+ <h6 class="c-text__label">{{ meta }}</h6>
4
+ <p v-if="!source" class="c-text__value" v-html="show(value)"></p>
5
+ <ul class="c-text__list" v-if="source">
6
+ <li v-for="(v, i) in value" :key="i" class="c-text__list-item" :class="{ 'c-text__list-item--image' : hasImage(v) }">
7
+ <router-link
8
+ :to="{ name: type, params: {id: getPeopleFromName(v).id }}" v-if="hasImage(v)">
9
+ <img class="c-text__image" :alt="v" :src="getPeopleFromName(v).image" />
10
+ </router-link>
11
+
12
+ <div class="c-text__wrapper" v-if="getPeopleFromName(v)">
13
+ <router-link
14
+ :to="{ name: type, params: {id: getPeopleFromName(v).id }}">
15
+ {{ getPeopleFromName(v).name }} <span v-if="!hideGroup">{{ getPeopleFromName(v).parliamentarygroup }}</span>
16
+ </router-link>
17
+ </div>
18
+
19
+ <span v-else>{{ v }}</span>
20
+ </li>
21
+ </ul>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ name: 'TipiText',
28
+ props: {
29
+ meta: String,
30
+ value: [String, Array],
31
+ type: String,
32
+ source: Array,
33
+ hideGroup: Boolean,
34
+ },
35
+ methods: {
36
+ getPeopleFromName: function (string) {
37
+ if (string.hasOwnProperty('name')) return string;
38
+ let regex_id = /\[.*\]/;
39
+ let has_id = regex_id.exec(string);
40
+ if (!has_id) return this.source.find(s => s.name == string);
41
+ let peopleId = has_id[0].replace('[', '').replace(']', '');
42
+ return this.source.find(s => s.id == peopleId);
43
+ },
44
+ show: function(value) {
45
+ if (value.constructor === Array) return value.join('<br/>');
46
+ return value;
47
+ },
48
+ hasImage: function(name) {
49
+ return this.getPeopleFromName(name) && this.getPeopleFromName(name).image;
50
+ },
51
+ is: function(value) {
52
+ if (value === undefined) return false;
53
+ if (value.constructor === String && value != "") return true;
54
+ if (value.constructor === Array && value.length > 0) return true;
55
+ return false;
56
+ },
57
+ },
58
+ };
59
+ </script>