@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,69 @@
1
+ <template>
2
+ <div class="c-text" v-if="is()">
3
+ <h6 class="c-text__label">{{ meta }}</h6>
4
+ <p v-if="!source" class="c-text__value" v-html="show()"></p>
5
+ <ul class="c-text__list" v-if="source">
6
+ <li
7
+ v-for="(v, i) in value"
8
+ :key="i"
9
+ class="c-text__list-item"
10
+ :class="{ 'c-text__list-item--image': hasImage(v) }"
11
+ >
12
+ <router-link
13
+ :to="{ name: type, params: { id: getPeopleFromName(v).id } }"
14
+ v-if="hasImage(v)"
15
+ >
16
+ <img class="c-text__image" :alt="v" :src="getPeopleFromName(v).image" />
17
+ </router-link>
18
+
19
+ <div class="c-text__wrapper" v-if="getPeopleFromName(v)">
20
+ <router-link :to="{ name: type, params: { id: getPeopleFromName(v).id } }">
21
+ {{ getPeopleFromName(v).name }}
22
+ <span v-if="!hideGroup">{{ getPeopleFromName(v).parliamentarygroup }}</span>
23
+ </router-link>
24
+ </div>
25
+
26
+ <span v-else>{{ v }}</span>
27
+ </li>
28
+ </ul>
29
+ </div>
30
+ </template>
31
+
32
+ <script setup>
33
+ import { toRefs } from 'vue';
34
+
35
+ const props = defineProps({
36
+ meta: String,
37
+ value: [String, Array],
38
+ type: String,
39
+ source: Array,
40
+ hideGroup: Boolean,
41
+ });
42
+
43
+ const { meta, value, type, source, hideGroup } = toRefs(props);
44
+
45
+ const getPeopleFromName = (string) => {
46
+ if (string.hasOwnProperty('name')) return string;
47
+ const regex_id = /\[.*\]/;
48
+ const has_id = regex_id.exec(string);
49
+ if (!has_id) return source.value.find((s) => s.name == string);
50
+ const peopleId = has_id[0].replace('[', '').replace(']', '');
51
+ return source.value.find((s) => s.id == peopleId);
52
+ };
53
+
54
+ const show = () => {
55
+ if (value.value.constructor === Array) return value.value.join('<br/>');
56
+ return value.value;
57
+ };
58
+
59
+ const hasImage = (name) => {
60
+ return getPeopleFromName(name) && getPeopleFromName(name).image;
61
+ };
62
+
63
+ const is = () => {
64
+ if (value.value === undefined) return false;
65
+ if (value.value.constructor === String && value.value != '') return true;
66
+ if (value.value.constructor === Array && value.value.length > 0) return true;
67
+ return false;
68
+ };
69
+ </script>
@@ -0,0 +1,204 @@
1
+ <template>
2
+ <transition-group tag="div" class="tipichart" name="barfade">
3
+ <div class="tipichart__row" v-for="d in rows" :key="d.topic" :style="rowStyle">
4
+
5
+ <div class="tipichart__tooltip" :style="{bottom: `${barHeight}px`}">
6
+ <div class="tipichart__tip">{{ d.topic }} {{ d.percent }}%</div>
7
+ </div>
8
+
9
+ <div class="tipichart__icon" :style="d.iconStyle"></div>
10
+
11
+ <div class="tipichart__bar">
12
+ <div class="tipichart__backbar" :style="d.backbarStyle"></div>
13
+ <div class="tipichart__overbar" :style="d.overbarStyle"></div>
14
+ </div>
15
+
16
+ </div>
17
+ </transition-group>
18
+ </template>
19
+
20
+
21
+ <script>
22
+ import * as Utils from '../../utils';
23
+
24
+ export default {
25
+ name: 'TipiBarchart',
26
+ data() {
27
+ return {
28
+ rows: [],
29
+ };
30
+ },
31
+ props: {
32
+ result: {
33
+ type: Object,
34
+ required: true,
35
+ default: () => ({}),
36
+ },
37
+ styles: {
38
+ type: Object,
39
+ required: true,
40
+ default: () => ({}),
41
+ },
42
+ barHeight: {
43
+ type: Number,
44
+ required: false,
45
+ default: 24,
46
+ },
47
+ barGap: {
48
+ type: Number,
49
+ required: false,
50
+ default: 12,
51
+ },
52
+ barColor: {
53
+ type: String,
54
+ required: false,
55
+ default: '#fbc239',
56
+ },
57
+ barBackgroundColor: {
58
+ type: String,
59
+ required: false,
60
+ default: '#f4f6f8',
61
+ },
62
+ barOrder: {
63
+ type: String,
64
+ required: false,
65
+ default: 'desc', // Options: alphabetically, asc, desc
66
+ },
67
+ knowledgebase: {
68
+ type: String,
69
+ required: true,
70
+ },
71
+ },
72
+ mounted() {
73
+ this.calculeRows();
74
+ },
75
+ computed: {
76
+ rowStyle() {
77
+ return {
78
+ height: `${this.barHeight}px`,
79
+ marginBottom: `${this.barGap}px`,
80
+ };
81
+ },
82
+ },
83
+ methods: {
84
+ calculeRows() {
85
+ const tagged = this.getTagged();
86
+ const tags = tagged.tags;
87
+ const rows = [];
88
+ const totalTimes = tags
89
+ .reduce((cnt, o) => (cnt + o.times), 0);
90
+
91
+
92
+ tags.forEach(d => {
93
+ const idx = rows.map(r => r.topic).indexOf(d.topic);
94
+ if(idx === -1) {
95
+ // New topic -> construct object
96
+ rows.push({
97
+ topic: d.topic,
98
+ times: d.times,
99
+ percent: Math.ceil((d.times/totalTimes)*100),
100
+ iconStyle: {
101
+ flex: `0 0 ${this.barHeight}px`,
102
+ height: `${this.barHeight}px`,
103
+ backgroundSize: `${this.barHeight}px`,
104
+ backgroundImage: `url(/img/topics/${this.styles.topics[d.topic].image})`,
105
+ },
106
+ backbarStyle: {
107
+ height: `${this.barHeight}px`,
108
+ backgroundColor: this.barBackgroundColor,
109
+ },
110
+ overbarStyle: {
111
+ height: `${this.barHeight}px`,
112
+ width: `${(d.times/totalTimes)*100}%`,
113
+ backgroundColor: this.barColor,
114
+ },
115
+ });
116
+ } else {
117
+ // Existing topic -> update values (sum ocurrences)
118
+ rows[idx].times += d.times;
119
+ rows[idx].overbarStyle.width = `${(rows[idx].times/totalTimes)*100}%`;
120
+ rows[idx].percent = Math.ceil((rows[idx].times/totalTimes)*100);
121
+ }
122
+ });
123
+ this.rows = this.barOrder === 'alphabetically'
124
+ ? rows.sort((a, b) => Utils.naturalSort(a.topic, b.topic))
125
+ : this.barOrder === 'asc'
126
+ ? rows.sort((a, b) => a.times - b.times)
127
+ : rows.sort((a, b) => b.times - a.times);
128
+ },
129
+ getTagged() {
130
+ return this.result.tagged.filter(e => e.knowledgebase == this.knowledgebase).pop();
131
+ },
132
+ },
133
+ };
134
+ </script>
135
+
136
+ <style lang="scss">
137
+ .tipichart {
138
+ &__row {
139
+ display: flex;
140
+ position: relative;
141
+ &:hover .tipichart__tooltip {
142
+ display: block;
143
+ }
144
+ }
145
+ &__tooltip {
146
+ position: absolute;
147
+ left: 0;
148
+ width: 100%;
149
+ z-index: 99;
150
+ text-align: center;
151
+ display: none;
152
+ pointer-events: none;
153
+ }
154
+ &__tip {
155
+ background: black;
156
+ color: white;
157
+ font-size: small;
158
+ display: inline-block;
159
+ padding: 0 4px;
160
+ line-height: 1.5;
161
+ border-radius: 3px;
162
+ }
163
+ &__icon {
164
+ background-repeat: no-repeat;
165
+ background-position: center;
166
+ margin-right: 6px;
167
+ }
168
+ &__bar {
169
+ flex: 1 1 auto;
170
+ overflow: hidden;
171
+ border-radius: 3px;
172
+ position: relative;
173
+ }
174
+ &__backbar {
175
+ width: 100%;
176
+ }
177
+ &__overbar {
178
+ position: absolute;
179
+ z-index: 9;
180
+ top: 0;
181
+ left: 0;
182
+ transition: width 500ms cubic-bezier(0.59, 0.12, 0.34, 0.95) 350ms;
183
+ }
184
+ }
185
+
186
+ /* Animation */
187
+ .barfade {
188
+ &-enter-active,
189
+ &-leave-active,
190
+ &-move {
191
+ transition: 350ms cubic-bezier(0.59, 0.12, 0.34, 0.95);
192
+ transition-property: opacity, transform;
193
+ .tipichart__overbar {
194
+ width: 0 !important;
195
+ }
196
+ }
197
+ &-enter,
198
+ &-leave-to {
199
+ opacity: 0;
200
+ transform: translateX(50px);
201
+ }
202
+ }
203
+
204
+ </style>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <div :style="`background-color: ${getColor()}`" class="c-topic-card">
3
+ <div class="o-container">
4
+ <div class="o-grid o-grid--reverse">
5
+ <div class="o-grid__col u-12 u-3@sm u-offset-1@sm">
6
+ <img
7
+ :src="`/img/topics/${getIcon()}`"
8
+ :alt="`Imagen de ${topic.name}`"
9
+ class="c-topic-card__image"
10
+ />
11
+ </div>
12
+ <div class="o-grid__col u-12 u-8@sm">
13
+ <h1 class="c-topic-card__title">{{ topic.name }}</h1>
14
+ <div class="c-topic-card__description">
15
+ <p v-for="d in topic.description" :key="d">
16
+ {{ d }}
17
+ </p>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script setup>
26
+ import { toRefs } from 'vue';
27
+
28
+ const props = defineProps({
29
+ topic: Object,
30
+ topicsStyles: {
31
+ type: Object,
32
+ default: function () {
33
+ return {};
34
+ },
35
+ },
36
+ });
37
+
38
+ const { topic } = toRefs(props);
39
+ const { topicsStyles } = props;
40
+
41
+ const getIcon = () => {
42
+ return topicsStyles.hasOwnProperty(topic.value.name) && topicsStyles[topic.value.name].image
43
+ ? topicsStyles[topic.value.name].image
44
+ : topic.value.icon;
45
+ };
46
+
47
+ const getColor = () => {
48
+ return topicsStyles.hasOwnProperty(topic.value.name) && topicsStyles[topic.value.name].color
49
+ ? topicsStyles[topic.value.name].color
50
+ : '#000';
51
+ };
52
+ </script>
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <div>
3
+ <div class="c-topic-link">
4
+ <router-link
5
+ :to="{ name: 'topic', params: { id: topic.id } }"
6
+ class="c-topic-link__image-link"
7
+ :style="`background-color: ${color}`"
8
+ >
9
+ <img :src="topicImage" :alt="`Imagen de ${topic.name}`" class="c-topic-link__image" />
10
+ </router-link>
11
+ <h4 class="c-topic-link__name">
12
+ <router-link :to="{ name: 'topic', params: { id: topic.id } }">
13
+ {{ topic.name }}
14
+ </router-link>
15
+ </h4>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { toRefs, computed } from 'vue';
22
+
23
+ const props = defineProps({
24
+ color: {
25
+ type: String,
26
+ default: '#000',
27
+ },
28
+ image: String,
29
+ topic: Object,
30
+ });
31
+
32
+ const { color, image, topic } = toRefs(props);
33
+
34
+ const topicImage = computed(() => {
35
+ return `/img/topics/${image.value}` || `/img/topics/${topic.value.icon}`;
36
+ });
37
+ </script>
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <div class="c-topics">
3
+ <span v-html="getTopics()" />
4
+ <div
5
+ v-if="limit && limit < topics.length"
6
+ class="c-topics__topic c-topics__topic__small"
7
+ style="background-color: #2d4252"
8
+ >
9
+ <tipi-icon icon="more" />
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { toRefs } from 'vue';
16
+
17
+ import TipiIcon from '../Icon/Icon.vue';
18
+ import * as Utils from '../../utils';
19
+
20
+ const props = defineProps({
21
+ topics: Array,
22
+ topicsStyles: Object,
23
+ withLinks: Boolean,
24
+ limit: Number,
25
+ order: {
26
+ type: Boolean,
27
+ default: true,
28
+ },
29
+ });
30
+
31
+ const { topics, withLinks, limit, order } = toRefs(props);
32
+ const { topicsStyles } = props;
33
+
34
+ const getTopics = () => {
35
+ let topicsTemp = topics.value;
36
+ if (limit.value) {
37
+ topicsTemp = topicsTemp.slice(0, limit.value);
38
+ }
39
+ if (topicsStyles && topicsTemp.length) {
40
+ let returnedTopics = order.value
41
+ ? topicsTemp.slice().sort(Utils.naturalSort)
42
+ : topicsTemp.slice();
43
+ return returnedTopics
44
+ .map((element, i) => {
45
+ if (withLinks.value) {
46
+ return `
47
+ <a href="#topic-${i}" class="c-topics__topic c-topics__topic__small" style="background-color:${topicsStyles[element].color}">
48
+ ${topicsStyles[element].shortname}
49
+ </a>
50
+ `;
51
+ } else {
52
+ return `
53
+ <div class="c-topics__topic c-topics__topic__small" style="background-color:${topicsStyles[element].color}">
54
+ ${topicsStyles[element].shortname}
55
+ </div>
56
+ `;
57
+ }
58
+ })
59
+ .join('');
60
+ }
61
+ return topicsTemp.length
62
+ ? topicsTemp.join('<br/>')
63
+ : `<div class="c-topics__topic c-topics__topic__small" style="background-color: #ccc; color: #444;">
64
+ ${topicsStyles['no-topic'] ? topicsStyles['no-topic'].shortname : 'Sin temática'}
65
+ </div>`;
66
+ };
67
+ </script>
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <div class="c-topics c-topics--extended" v-if="topics">
3
+ <h6 class="c-topics__label">{{ meta }}</h6>
4
+ <ul class="c-topics__list">
5
+ <li v-for="(topic, i) in sortedTopics" :key="topic" class="c-topics__list-topic">
6
+ <router-link
7
+ :id="`topic-${i}`"
8
+ class="c-topics__topic"
9
+ :style="`background-color:${topicsStyles[topic].color}`"
10
+ :to="{ name: 'results', params: { data: paramsData(topic) } }"
11
+ >
12
+ {{ topic }}
13
+ </router-link>
14
+
15
+ <ul v-if="getSubtopics(topic)" class="c-topics__list-subtopic">
16
+ <li
17
+ v-for="subtopic in getSubtopics(topic)"
18
+ :key="subtopic + ' - ' + topic"
19
+ class="c-topics__subtopic"
20
+ >
21
+ <router-link
22
+ class="c-topics__link"
23
+ :to="{ name: 'results', params: { data: paramsData(topic, subtopic) } }"
24
+ >
25
+ {{ subtopic }}
26
+ </router-link>
27
+
28
+ <ul v-if="getTags(subtopic)" class="c-topics__list-tags">
29
+ <li v-for="tag in getTags(subtopic)" :key="tag + ' - ' + topic" class="c-topics__tag">
30
+ <router-link
31
+ class="c-topics__link"
32
+ :to="{ name: 'results', params: { data: paramsData(topic, subtopic, tag) } }"
33
+ >
34
+ {{ tag }}
35
+ </router-link>
36
+ </li>
37
+ </ul>
38
+ </li>
39
+ </ul>
40
+ </li>
41
+ </ul>
42
+ </div>
43
+ </template>
44
+
45
+ <script setup>
46
+ import { toRefs, computed } from 'vue';
47
+ import qs from 'qs';
48
+
49
+ import * as Utils from '../../utils';
50
+
51
+ const props = defineProps({
52
+ meta: { type: String },
53
+ topics: { type: Array },
54
+ tags: { type: Array },
55
+ topicsStyles: { type: Object },
56
+ });
57
+
58
+ const { meta, topics, tags, topicsStyles } = toRefs(props);
59
+
60
+ const sortedTopics = computed(() => {
61
+ return topics.value.slice().sort(Utils.naturalSort);
62
+ });
63
+
64
+ const getSubtopics = (topic) => {
65
+ return [...new Set(tags.value.filter((tag) => tag.topic === topic).map((tag) => tag.subtopic))];
66
+ };
67
+
68
+ const getTags = (subtopic) => {
69
+ return tags.value.filter((tag) => tag.subtopic === subtopic).map((tag) => tag.tag);
70
+ };
71
+
72
+ const paramsData = (currentTopic, currentSubtopic, currentTag) => {
73
+ return qs.stringify({
74
+ topic: currentTopic,
75
+ subtopics: currentSubtopic ? currentSubtopic : undefined,
76
+ tags: currentTag ? currentTag : undefined,
77
+ });
78
+ };
79
+ </script>
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <svg ref="twoCirclesRef" style="width: 300px; height: 500px"></svg>
3
+ </template>
4
+
5
+ <script setup>
6
+ import { ref, toRefs, onMounted, watch } from 'vue';
7
+ import { select } from 'd3-selection';
8
+ import { transition } from 'd3-transition';
9
+
10
+ const props = defineProps({
11
+ selection: Object,
12
+ topic: String,
13
+ styles: {
14
+ type: Object,
15
+ default: function () {
16
+ return { topics: {}, defaultColor: '#cecece' };
17
+ },
18
+ },
19
+ });
20
+
21
+ const { selection, topic } = toRefs(props);
22
+ const { styles } = props;
23
+
24
+ const twoCirclesRef = ref(null);
25
+
26
+ const loadVizz = () => {
27
+ //Configurations
28
+ let duration = 2000;
29
+
30
+ //Globals
31
+ let svg = select(twoCirclesRef.value);
32
+ svg.selectAll('*').remove();
33
+ let width = +svg.node().getBoundingClientRect().width;
34
+ let maxRadius = 150;
35
+ let minRadius = 5;
36
+
37
+ let mainTopic = topic.value;
38
+ let data = [selection.value.selected];
39
+ let maxName = selection.value.compareswith._id;
40
+ let maxNumber = selection.value.compareswith.initiatives;
41
+ let mainColor = styles.topics[mainTopic] ? styles.topics[mainTopic].color : styles.defaultColor;
42
+ let maxColor = styles.topics[maxName] ? styles.topics[maxName].color : mainColor;
43
+
44
+ let node = svg
45
+ .selectAll('.node')
46
+ .data(data)
47
+ .enter()
48
+ .append('g')
49
+ .attr('class', 'node')
50
+ .attr('transform', 'translate(' + width / 2 + ',' + maxRadius + ')');
51
+
52
+ node.append('circle').attr('class', 'compared').attr('r', maxRadius).attr('fill', maxColor);
53
+
54
+ node
55
+ .append('circle')
56
+ .attr('fill', function (d) {
57
+ return selectColor(d);
58
+ })
59
+ .attr('r', 0)
60
+ .transition()
61
+ .duration(duration)
62
+ .attr('r', function (d) {
63
+ let radius = Math.round((d.initiatives * maxRadius) / maxNumber);
64
+ if (d.initiatives === 0) return 0;
65
+ return radius > minRadius ? radius : minRadius;
66
+ });
67
+
68
+ let legend = svg.selectAll('.legend').data(data).enter().append('g').attr('class', 'legend');
69
+
70
+ legend
71
+ .append('rect')
72
+ .attr('width', maxRadius * 2)
73
+ .attr('height', 10)
74
+ .attr('fill', function (d) {
75
+ return selectColor(d);
76
+ })
77
+ .attr('transform', 'translate(0,' + (maxRadius * 2 + 50) + ')');
78
+
79
+ legend
80
+ .append('text')
81
+ .attr('x', 0)
82
+ .attr('y', 0)
83
+ .style('fill', '#222')
84
+ .style('font-size', '13px')
85
+ .text(function (d) {
86
+ return d._id;
87
+ })
88
+ .attr('text-anchor', 'middle')
89
+ .attr('alignment-baseline', 'central')
90
+ .attr('transform', 'translate(' + width / 2 + ',' + (maxRadius * 2 + 70) + ')');
91
+
92
+ legend
93
+ .append('rect')
94
+ .attr('width', maxRadius * 2)
95
+ .attr('height', 10)
96
+ .attr('class', 'compared')
97
+ .attr('fill', maxColor)
98
+ .attr('transform', 'translate(0,' + (maxRadius * 2 + 90) + ')');
99
+
100
+ legend
101
+ .append('text')
102
+ .attr('x', 0)
103
+ .attr('y', 0)
104
+ .style('fill', '#222')
105
+ .style('font-size', '13px')
106
+ .text(maxName)
107
+ .attr('text-anchor', 'middle')
108
+ .attr('alignment-baseline', 'central')
109
+ .attr('transform', 'translate(' + width / 2 + ',' + (maxRadius * 2 + 110) + ')');
110
+
111
+ function selectColor(d) {
112
+ //console.log(d);
113
+ return styles.topics[mainTopic] ? styles.topics[mainTopic].color : styles.defaultColor;
114
+ }
115
+ };
116
+
117
+ onMounted(() => {
118
+ loadVizz();
119
+ });
120
+
121
+ watch(
122
+ () => selection.value.selected._id,
123
+ () => {
124
+ loadVizz();
125
+ }
126
+ );
127
+ </script>
128
+
129
+ <style lang="scss">
130
+ circle.compared,
131
+ rect.compared {
132
+ opacity: 0.3;
133
+ }
134
+ </style>
@@ -0,0 +1,57 @@
1
+ import TipiResults from './Results/Results.vue';
2
+ import TipiMessage from './Message/Message.vue';
3
+ import TipiCsvDownload from './CSVDownload/CSVDownload.vue';
4
+ import TipiCongressLink from './CongressLink/CongressLink.vue';
5
+ import TipiHeader from './Header/Header.vue';
6
+ import TipiNavbar from './Navbar/Navbar.vue';
7
+ import TipiDeputy from './Deputy/Deputy.vue';
8
+ import TipiText from './Text/Text.vue';
9
+ import TipiTopics from './Topics/Topics.vue';
10
+ import TipiInitiativeMeta from './InitiativeMeta/InitiativeMeta.vue';
11
+ import TipiNeuron from './Neuron/Neuron.vue';
12
+ import TipiTopicCard from './TopicCard/TopicCard.vue';
13
+ import TipiTopicLink from './TopicLink/TopicLink.vue';
14
+ import TipiTwoCircles from './TwoCircles/TwoCircles.vue';
15
+ import TipiSplash from './Splash/Splash.vue';
16
+ import TipiIcon from './Icon/Icon.vue';
17
+ import PartyLogo from './PartyLogo/PartyLogo.vue';
18
+ import PartyLogoIcon from './PartyLogo/PartyLogoIcon.vue';
19
+ import TipiInitiativeCard from './InitiativeCard/InitiativeCard.vue';
20
+ import TipiTopicPill from './TopicPill/TopicPill.vue';
21
+ import TipiLoader from './Loader/Loader.vue';
22
+ import TipiBarchart from './TipiCharts/TipiBarchart.vue';
23
+ import D3Sunburst from './Charts/Sunburst/d3.sunburst.vue';
24
+ import D3WordsCloud from './Charts/WordsCloud/d3.wordscloud.vue';
25
+ import D3BarChart from './Charts/Barchart/d3.barchart.vue';
26
+ import D3SlicesChart from './Charts/Sliceschart/d3.sliceschart.vue';
27
+ import * as Utils from '../utils';
28
+
29
+ export {
30
+ TipiResults,
31
+ TipiMessage,
32
+ TipiCsvDownload,
33
+ TipiCongressLink,
34
+ TipiHeader,
35
+ TipiNavbar,
36
+ TipiDeputy,
37
+ TipiText,
38
+ TipiTopics,
39
+ TipiInitiativeMeta,
40
+ TipiNeuron,
41
+ TipiTopicCard,
42
+ TipiTopicLink,
43
+ TipiTwoCircles,
44
+ TipiSplash,
45
+ TipiIcon,
46
+ PartyLogo,
47
+ PartyLogoIcon,
48
+ TipiInitiativeCard,
49
+ TipiTopicPill,
50
+ TipiLoader,
51
+ TipiBarchart,
52
+ D3Sunburst,
53
+ D3WordsCloud,
54
+ D3BarChart,
55
+ D3SlicesChart,
56
+ Utils,
57
+ };