@politicalwatch/tipi-uikit 1.0.0-dev

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