@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,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,40 @@
1
+ <template>
2
+ <div :style="`background-color: ${getColor(topic)}`" 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 :src="`/img/topics/${getIcon(topic)}`" :alt="`Imagen de ${topic.name}`" class="c-topic-card__image">
7
+ </div>
8
+ <div class="o-grid__col u-12 u-8@sm">
9
+ <h1 class="c-topic-card__title">{{ topic.name }}</h1>
10
+ <div class="c-topic-card__description">
11
+ <p v-for="d in topic.description" :key="d">
12
+ {{ d }}
13
+ </p>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ export default {
23
+ name: 'TipiTopicCard',
24
+ props: {
25
+ topic: Object,
26
+ topicsStyles: {
27
+ type: Object,
28
+ default: function () { return {}; },
29
+ },
30
+ },
31
+ methods: {
32
+ getIcon: function(topic) {
33
+ return this.topicsStyles.hasOwnProperty(topic.name) && this.topicsStyles[topic.name].image ? this.topicsStyles[topic.name].image : this.topic.icon;
34
+ },
35
+ getColor: function(topic) {
36
+ return this.topicsStyles.hasOwnProperty(topic.name) && this.topicsStyles[topic.name].color ? this.topicsStyles[topic.name].color : '#000';
37
+ },
38
+ },
39
+ };
40
+ </script>
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <div>
3
+ <div class="c-topic-link">
4
+ <router-link :to="{name: 'topic', params: {id: topic.id }}" class="c-topic-link__image-link" :style="`background-color: ${color}`">
5
+ <img :src="topicImage" :alt="`Imagen de ${topic.name}`" class="c-topic-link__image">
6
+ </router-link>
7
+ <h4 class="c-topic-link__name">
8
+ <router-link :to="{name: 'topic', params: {id: topic.id }}">
9
+ {{ topic.name }}
10
+ </router-link>
11
+ </h4>
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script>
17
+ export default {
18
+ name: 'TipiTopicLink',
19
+ props: {
20
+ color: {
21
+ type: String,
22
+ default: '#000',
23
+ },
24
+ image: String,
25
+ topic: Object,
26
+ },
27
+ computed: {
28
+ topicImage: function() {
29
+ return `/img/topics/${this.image}` || `/img/topics/${this.topic.icon}`;
30
+ },
31
+ },
32
+ };
33
+ </script>
@@ -0,0 +1,69 @@
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>
15
+ import TipiIcon from '../Icon/Icon.vue';
16
+ import * as Utils from '../../utils';
17
+
18
+ export default {
19
+ name: 'TipiTopicPill',
20
+ components: {
21
+ TipiIcon,
22
+ },
23
+ props: {
24
+ topics: Array,
25
+ topicsStyles: Object,
26
+ withLinks: Boolean,
27
+ limit: Number,
28
+ order: {
29
+ type: Boolean,
30
+ default: true,
31
+ },
32
+ },
33
+ methods: {
34
+ getTopics: function() {
35
+ let topics = this.topics;
36
+ if (this.limit) {
37
+ topics = topics.slice(0, this.limit);
38
+ }
39
+ if (this.topicsStyles && topics.length) {
40
+ let returnedTopics = this.order ? topics.slice().sort(Utils.naturalSort) : topics.slice();
41
+ return returnedTopics
42
+ .map((element, i) => {
43
+ if (this.withLinks) {
44
+ return `
45
+ <a href="#topic-${i}" class="c-topics__topic c-topics__topic__small" style="background-color:${this.topicsStyles[element].color}">
46
+ ${this.topicsStyles[element].shortname}
47
+ </a>
48
+ `;
49
+ } else {
50
+ return `
51
+ <div class="c-topics__topic c-topics__topic__small" style="background-color:${this.topicsStyles[element].color}">
52
+ ${this.topicsStyles[element].shortname}
53
+ </div>
54
+ `;
55
+ }
56
+ })
57
+ .join('');
58
+ }
59
+ return topics.length
60
+ ? topics.join('<br/>')
61
+ : `<div class="c-topics__topic c-topics__topic__small" style="background-color: #ccc; color: #444;">
62
+ ${
63
+ this.topicsStyles['no-topic'] ? this.topicsStyles['no-topic'].shortname : 'Sin temática'
64
+ }
65
+ </div>`;
66
+ },
67
+ },
68
+ };
69
+ </script>
@@ -0,0 +1,84 @@
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" v-bind: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
+ v-bind: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
30
+ v-for="tag in getTags(subtopic)"
31
+ v-bind:key="tag + ' - ' + topic"
32
+ class="c-topics__tag"
33
+ >
34
+ <router-link
35
+ class="c-topics__link"
36
+ :to="{ name: 'results', params: { data: paramsData(topic, subtopic, tag) } }"
37
+ >
38
+ {{ tag }}
39
+ </router-link>
40
+ </li>
41
+ </ul>
42
+ </li>
43
+ </ul>
44
+ </li>
45
+ </ul>
46
+ </div>
47
+ </template>
48
+
49
+ <script>
50
+ import qs from "qs";
51
+ import * as Utils from "../../utils";
52
+
53
+ export default {
54
+ name: "tipi-topics",
55
+ props: {
56
+ meta: String,
57
+ topics: Array,
58
+ tags: Array,
59
+ topicsStyles: Object
60
+ },
61
+ computed: {
62
+ sortedTopics: function() {
63
+ return this.$props.topics.slice().sort(Utils.naturalSort);
64
+ }
65
+ },
66
+ methods: {
67
+ getSubtopics(topic) {
68
+ return [
69
+ ...new Set(this.$props.tags.filter(tag => tag.topic === topic).map(tag => tag.subtopic))
70
+ ];
71
+ },
72
+ getTags: function(subtopic) {
73
+ return this.$props.tags.filter(tag => tag.subtopic === subtopic).map(tag => tag.tag);
74
+ },
75
+ paramsData: function(currentTopic, currentSubtopic, currentTag) {
76
+ return qs.stringify({
77
+ topic: currentTopic,
78
+ subtopics: currentSubtopic ? currentSubtopic : undefined,
79
+ tags: currentTag ? currentTag : undefined
80
+ });
81
+ }
82
+ }
83
+ };
84
+ </script>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <svg style="width: 300px; height: 500px;"></svg>
3
+ </template>
4
+
5
+ <script>
6
+ import { select } from 'd3-selection';
7
+
8
+ export default {
9
+ name: 'TipiTwoCircles',
10
+ props: {
11
+ selection: Object,
12
+ styles: {
13
+ type: Object,
14
+ default: function() {
15
+ return { topics: {}, defaultColor: '#cecece' };
16
+ },
17
+ },
18
+ topic: String,
19
+ },
20
+ methods: {
21
+ loadVizz: function() {
22
+ //Configurations
23
+ let duration = 2000;
24
+
25
+ //Globals
26
+ let svg = select(this.$el);
27
+ svg.selectAll('*').remove();
28
+ let width = +svg.node().getBoundingClientRect().width;
29
+ let maxRadius = 150;
30
+ let minRadius = 5;
31
+
32
+ let styles = this.$props.styles;
33
+ let mainTopic = this.$props.topic;
34
+ let data = [this.$props.selection.selected];
35
+ let maxName = this.$props.selection.compareswith._id;
36
+ let maxNumber = this.$props.selection.compareswith.initiatives;
37
+ let mainColor = styles.topics[mainTopic]
38
+ ? styles.topics[mainTopic].color
39
+ : styles.defaultColor;
40
+ let maxColor = styles.topics[maxName] ? styles.topics[maxName].color : mainColor;
41
+
42
+ let node = svg
43
+ .selectAll('.node')
44
+ .data(data)
45
+ .enter()
46
+ .append('g')
47
+ .attr('class', 'node')
48
+ .attr('transform', 'translate(' + width / 2 + ',' + maxRadius + ')');
49
+
50
+ node
51
+ .append('circle')
52
+ .attr('class', 'compared')
53
+ .attr('r', maxRadius)
54
+ .attr('fill', maxColor);
55
+
56
+ node
57
+ .append('circle')
58
+ .attr('fill', function(d) {
59
+ return selectColor(d);
60
+ })
61
+ .attr('r', 0)
62
+ .transition()
63
+ .duration(duration)
64
+ .attr('r', function(d) {
65
+ let radius = Math.round((d.initiatives * maxRadius) / maxNumber);
66
+ if (d.initiatives === 0) return 0;
67
+ return radius > minRadius ? radius : minRadius;
68
+ });
69
+
70
+ let legend = svg
71
+ .selectAll('.legend')
72
+ .data(data)
73
+ .enter()
74
+ .append('g')
75
+ .attr('class', 'legend');
76
+
77
+ legend
78
+ .append('rect')
79
+ .attr('width', maxRadius * 2)
80
+ .attr('height', 10)
81
+ .attr('fill', function(d) {
82
+ return selectColor(d);
83
+ })
84
+ .attr('transform', 'translate(0,' + (maxRadius * 2 + 50) + ')');
85
+
86
+ legend
87
+ .append('text')
88
+ .attr('x', 0)
89
+ .attr('y', 0)
90
+ .style('fill', '#222')
91
+ .style('font-size', '13px')
92
+ .text(function(d) {
93
+ return d._id;
94
+ })
95
+ .attr('text-anchor', 'middle')
96
+ .attr('alignment-baseline', 'central')
97
+ .attr('transform', 'translate(' + width / 2 + ',' + (maxRadius * 2 + 70) + ')');
98
+
99
+ legend
100
+ .append('rect')
101
+ .attr('width', maxRadius * 2)
102
+ .attr('height', 10)
103
+ .attr('class', 'compared')
104
+ .attr('fill', maxColor)
105
+ .attr('transform', 'translate(0,' + (maxRadius * 2 + 90) + ')');
106
+
107
+ legend
108
+ .append('text')
109
+ .attr('x', 0)
110
+ .attr('y', 0)
111
+ .style('fill', '#222')
112
+ .style('font-size', '13px')
113
+ .text(maxName)
114
+ .attr('text-anchor', 'middle')
115
+ .attr('alignment-baseline', 'central')
116
+ .attr('transform', 'translate(' + width / 2 + ',' + (maxRadius * 2 + 110) + ')');
117
+
118
+ function selectColor(d) {
119
+ //console.log(d);
120
+ return styles.topics[mainTopic] ? styles.topics[mainTopic].color : styles.defaultColor;
121
+ }
122
+ },
123
+ },
124
+ mounted: function() {
125
+ this.loadVizz();
126
+ },
127
+ watch: {
128
+ 'selection.selected._id': 'loadVizz',
129
+ },
130
+ };
131
+ </script>
132
+
133
+ <style lang="scss">
134
+ circle.compared,
135
+ rect.compared {
136
+ opacity: 0.3;
137
+ }
138
+ </style>
@@ -0,0 +1,53 @@
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 TipiInitiativeCard from './InitiativeCard/InitiativeCard.vue';
18
+ import TipiTopicPill from './TopicPill/TopicPill.vue';
19
+ import TipiLoader from './Loader/Loader.vue';
20
+ import TipiBarchart from './TipiCharts/TipiBarchart.vue';
21
+ import D3Sunburst from './Charts/Sunburst/d3.sunburst.vue';
22
+ import D3WordsCloud from './Charts/WordsCloud/d3.wordscloud.vue';
23
+ import D3BarChart from './Charts/Barchart/d3.barchart.vue';
24
+ import D3SlicesChart from './Charts/Sliceschart/d3.sliceschart.vue';
25
+ import * as Utils from '../utils';
26
+
27
+ export {
28
+ TipiResults,
29
+ TipiMessage,
30
+ TipiCsvDownload,
31
+ TipiCongressLink,
32
+ TipiHeader,
33
+ TipiNavbar,
34
+ TipiDeputy,
35
+ TipiText,
36
+ TipiTopics,
37
+ TipiInitiativeMeta,
38
+ TipiNeuron,
39
+ TipiTopicCard,
40
+ TipiTopicLink,
41
+ TipiTwoCircles,
42
+ TipiSplash,
43
+ TipiIcon,
44
+ TipiInitiativeCard,
45
+ TipiTopicPill,
46
+ TipiLoader,
47
+ TipiBarchart,
48
+ D3Sunburst,
49
+ D3WordsCloud,
50
+ D3BarChart,
51
+ D3SlicesChart,
52
+ Utils,
53
+ };
package/src/main.js ADDED
@@ -0,0 +1,11 @@
1
+ import * as TipiComponents from './components';
2
+
3
+ let TipiUI = Vue => {
4
+ Object.values(TipiComponents).forEach((TipiComponent) => {
5
+ Vue.use(TipiComponent);
6
+ });
7
+ };
8
+
9
+ TipiUI.version = '__VERSION__';
10
+
11
+ export default TipiUI;
@@ -0,0 +1,28 @@
1
+ $xs: 450px !default;
2
+ $sm: 768px !default;
3
+ $md: 992px !default;
4
+ $lg: 1024px !default;
5
+ $xl: 1200px !default;
6
+
7
+ $xxs-max: $xs - 0.1 !default;
8
+ $xs-max: $sm - 0.1 !default;
9
+ $sm-max: $md - 0.1 !default;
10
+ $md-max: $lg - 0.1 !default;
11
+ $lg-max: $xl - 0.1 !default;
12
+
13
+ $breakpoints: (
14
+ xs: $xs,
15
+ sm: $sm,
16
+ md: $md,
17
+ lg: $lg,
18
+ xl: $xl
19
+ ) !default;
20
+
21
+ $breakpoints-max: (
22
+ max-xs: $xs-max,
23
+ max-sm: $sm-max,
24
+ max-md: $md-max,
25
+ max-lg: $lg-max
26
+ ) !default;
27
+
28
+ $breakpoint-class: '\\@' !default;
@@ -0,0 +1,30 @@
1
+ $primary: #ff6565 !default;
2
+ $black: #000 !default;
3
+ $white: #fff !default;
4
+ $neutral: #ddd !default;
5
+ $secondary: #9cb0bf !default;
6
+ $secondary-dark: #2d4252 !default;
7
+ $secondary-light: #f4f6f8 !default;
8
+ $primary-dark: #d64949 !default;
9
+ $primary-light: #ffe0e0 !default;
10
+ $error: #e81c1c !default;
11
+ $completed: #4dca7f !default;
12
+
13
+ $colors: (
14
+ "primary": $primary,
15
+ "primary-dark": $primary-dark,
16
+ "primary-light": $primary-light,
17
+ "secondary": $secondary,
18
+ "secondary-dark": $secondary-dark,
19
+ "secondary-light": $secondary-light,
20
+ "error": $error,
21
+ "white": $white,
22
+ "black": $black,
23
+ "completed": $completed,
24
+ "neutral": $neutral,
25
+ ) !default;
26
+
27
+ $navbar-background-color: $white !default;
28
+ $menu-link-color: $secondary-dark !default;
29
+ $navbar-toogle-color: $secondary-dark !default;
30
+ $topic-pill-color: $white !default;
@@ -0,0 +1,3 @@
1
+ @import url('https://fonts.googleapis.com/css?family=Rubik:300,400,500&display=swap');
2
+
3
+ $font-primary: 'Rubik', sans-serif !default;