@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,92 @@
1
+ .chart {
2
+
3
+ /* Wrapper div (chart, title and source) */
4
+ &__wrapper {
5
+ margin: 20px 0;
6
+ }
7
+
8
+ /* Wrap div (chart only) */
9
+ &__wrap {
10
+ margin: 0;
11
+ }
12
+
13
+ /* Title */
14
+ &__title {
15
+ text-align: center;
16
+ }
17
+
18
+ /* Source */
19
+ &__source {
20
+ font-size: 12px;
21
+ }
22
+
23
+ /* Download */
24
+ &__source {
25
+ font-size: 12px;
26
+ span {
27
+ cursor: pointer;
28
+ background: #f4f6f8;
29
+ color: #394d5c;
30
+ padding: 2px 5px;
31
+ transition: opacity 250ms ease;
32
+ &:hover {
33
+ opacity: 0.5;
34
+ }
35
+ }
36
+ }
37
+
38
+ /* Tooltip */
39
+ &__tooltip {
40
+ position: absolute;
41
+ pointer-events: none;
42
+ display: none;
43
+
44
+ &.active {
45
+ display: block;
46
+ }
47
+
48
+ > div {
49
+ background: #2b2b2b;
50
+ color: white;
51
+ padding: 6px 10px;
52
+ border-radius: 3px;
53
+ }
54
+ }
55
+
56
+ /* Axis */
57
+ &__axis {
58
+ font-size: 12px;
59
+ shape-rendering: crispEdges;
60
+
61
+ /* Axis title */
62
+ &-title {}
63
+ }
64
+
65
+ /* Grid */
66
+ &__grid {
67
+ .domain {
68
+ stroke: none;
69
+ fill: none;
70
+ }
71
+
72
+ .tick line {
73
+ opacity: 0.2;
74
+ }
75
+ }
76
+
77
+ /* Elements labels */
78
+ &__label {
79
+ font-size: 12px;
80
+ }
81
+
82
+ /* Clickable element */
83
+ .clickable {
84
+ cursor: pointer;
85
+ }
86
+
87
+ &__line {
88
+ &--hidden {
89
+ fill: none;
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <a
3
+ :href="url"
4
+ class="c-congress-link u-color-primary"
5
+ target="_blank"
6
+ title="Ver en el Congreso.es"
7
+ ><tipi-icon class="u-filling-primary" icon="open-blank"></tipi-icon>Ver en el Congreso.es</a
8
+ >
9
+ </template>
10
+
11
+ <script setup>
12
+ import { toRefs } from 'vue';
13
+ import TipiIcon from '../Icon/Icon.vue';
14
+
15
+ const props = defineProps({
16
+ url: { type: String },
17
+ });
18
+ const { url } = toRefs(props);
19
+ </script>
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <div class="c-deputy" :class="addBirthdayClass()" v-if="deputy">
3
+ <div class="o-container">
4
+ <div class="o-grid o-grid--reverse">
5
+ <div class="o-grid__col u-4@sm">
6
+ <div class="c-deputy__image_container">
7
+ <img class="c-deputy__image" :src="deputy.image" :alt="'Foto de ' + deputy.name" />
8
+ <party-logo-icon :party="deputy.party_name" />
9
+ </div>
10
+ </div>
11
+ <div class="o-grid__col u-12 u-8@sm">
12
+ <h1 class="c-deputy__name">{{ deputy.name }}</h1>
13
+ <h3 class="c-deputy__group" v-if="parliamentaryGroup">
14
+ <router-link
15
+ :to="{ name: 'parliamentarygroup', params: { id: parliamentaryGroup.id } }"
16
+ >
17
+ {{ parliamentaryGroup.name }}
18
+ </router-link>
19
+ </h3>
20
+ <div class="c-deputy__extra">
21
+ <span class="c-deputy__personal"
22
+ ><tipi-icon v-if="addBirthdayClass()" icon="birthday" />{{ getAge() }} años</span
23
+ ><span class="c-deputy__personal"
24
+ ><tipi-icon icon="location" />{{ getConstituency() }}</span
25
+ >
26
+ </div>
27
+ <div class="c-deputy__links">
28
+ <slot />
29
+ </div>
30
+ </div>
31
+ <div class="o-grid__col u-12 u-12@sm c-deputy__more">
32
+ <a href="#" @click="collapse"
33
+ >{{ getCollapseMessage() }}<tipi-icon :icon="getCollapseIcon()"
34
+ /></a>
35
+ </div>
36
+ <div :class="getCollapsedClass()" class="o-grid__col u-12 u-4@sm">
37
+ <h3>Declaraciones</h3>
38
+ <p v-for="(link, title) in deputy.extra.declarations" :key="title">
39
+ <tipi-icon icon="document" /><a :href="link">{{ title }}</a>
40
+ </p>
41
+ </div>
42
+ <div :class="getCollapsedClass()" class="o-grid__col u-12 u-4@sm">
43
+ <h3>Cargos</h3>
44
+ <p v-for="position in deputy.public_position" :key="position">{{ position }}</p>
45
+ </div>
46
+ <div :class="getCollapsedClass()" class="o-grid__col u-12 u-4@sm">
47
+ <h3>Ficha personal</h3>
48
+ <p v-for="entry in deputy.bio" :key="entry">{{ entry }}</p>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </template>
54
+
55
+ <script setup>
56
+ import { ref, toRefs } from 'vue';
57
+
58
+ import TipiIcon from '../Icon/Icon.vue';
59
+ import PartyLogoIcon from '../PartyLogo/PartyLogoIcon.vue';
60
+
61
+ const props = defineProps({
62
+ deputy: Object,
63
+ parliamentaryGroup: Object,
64
+ });
65
+
66
+ const { deputy, parliamentaryGroup } = toRefs(props);
67
+
68
+ const isCollapsed = ref(true);
69
+
70
+ const getCollapsedClass = () => {
71
+ return isCollapsed.value ? 'c-deputy__hidden' : 'c-deputy__info';
72
+ };
73
+
74
+ const getCollapseIcon = () => {
75
+ return isCollapsed.value ? 'plus' : 'less';
76
+ };
77
+
78
+ const getCollapseMessage = () => {
79
+ return isCollapsed.value ? 'Mostrar más' : 'Mostrar menos';
80
+ };
81
+
82
+ const collapse = () => {
83
+ isCollapsed.value = !isCollapsed.value;
84
+ };
85
+
86
+ const addBirthdayClass = () => {
87
+ const date = new Date(deputy.value.birthdate);
88
+ const today = new Date();
89
+ if (date.getDate() == today.getDate() && date.getMonth() == today.getMonth()) {
90
+ return 'c-deputy__birthday';
91
+ }
92
+ };
93
+
94
+ const getAge = () => {
95
+ const date = new Date(deputy.value.birthdate);
96
+ const today = new Date();
97
+ const age = today.getFullYear() - date.getFullYear();
98
+ return age;
99
+ };
100
+
101
+ const getConstituency = () => {
102
+ return deputy.value.constituency;
103
+ };
104
+ </script>
105
+
106
+ <style scoped lang="scss"></style>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <header class="c-page-header" :class="{ 'c-page-header--nosub': !subtitle }">
3
+ <h1 class="c-page-header__title">
4
+ {{ title }}
5
+ </h1>
6
+ <p class="c-page-header__subtitle" v-if="subtitle">{{ subtitle }}</p>
7
+ </header>
8
+ </template>
9
+
10
+ <script setup>
11
+ import { toRefs } from 'vue';
12
+
13
+ const props = defineProps({
14
+ title: String,
15
+ subtitle: String,
16
+ });
17
+
18
+ const { title, subtitle } = toRefs(props);
19
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <span class="c-icon" :class="`c-icon--type-${icon}`">
3
+ <component :is="svg" :style="{ fill: customColor }" />
4
+ </span>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { toRefs, computed } from 'vue';
9
+
10
+ import icons from '../../assets/svg/icons';
11
+
12
+ const props = defineProps({
13
+ icon: { type: String },
14
+ color: { type: String },
15
+ });
16
+
17
+ const { icon, color } = toRefs(props);
18
+
19
+ const svg = computed(() => {
20
+ let svg = '';
21
+ if (icon.value in icons) {
22
+ svg = icons[icon.value];
23
+ } else {
24
+ svg = icon.value;
25
+ }
26
+ return svg;
27
+ });
28
+
29
+ const customColor = computed(() => color.value || '#2d4252');
30
+ </script>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div>
3
+ <article class="c-initiative-card" :id="`initiative-card-${initiative.id}`">
4
+ <h2 class="c-initiative-card__title">
5
+ <router-link
6
+ v-if="initiative.id"
7
+ :to="{ name: 'initiative', params: { id: initiative.id } }"
8
+ >{{ initiative.title }}</router-link
9
+ >
10
+ <span v-else>{{ initiative.title }}</span>
11
+ </h2>
12
+ <div class="c-initiative-card__authors" v-if="getDeputies(initiative) && extendedLayout">
13
+ <h3 class="c-initiative-card__label">{{ metaDeputies }}</h3>
14
+ <p v-html="getDeputies(initiative)"></p>
15
+ </div>
16
+ <div class="c-initiative-card__authors" v-if="getAuthors(initiative) && extendedLayout">
17
+ <h3 class="c-initiative-card__label">{{ metaGroupsOthers }}</h3>
18
+ <p v-html="getAuthors(initiative)"></p>
19
+ </div>
20
+ <router-link
21
+ v-if="initiative.id"
22
+ :to="{ name: 'initiative', params: { id: initiative.id } }"
23
+ v-slot="{ href }"
24
+ >
25
+ <a :href="href" target="_blank">
26
+ <tipi-topic-pill
27
+ class="c-initiative-card__topics"
28
+ :topicsStyles="topicsStyles"
29
+ :topics="getTopics(initiative)"
30
+ :limit="3"
31
+ />
32
+ </a>
33
+ </router-link>
34
+ <div class="o-grid">
35
+ <div class="o-grid__col">
36
+ <tipi-initiative-meta :initiative="initiative" :metaColors="metaColors" />
37
+ </div>
38
+ <div class="o-grid__col o-grid__col--right">
39
+ <router-link
40
+ v-if="initiative.id"
41
+ :to="{ name: 'initiative', params: { id: initiative.id } }"
42
+ v-slot="{ href }"
43
+ >
44
+ <a :href="href" target="_blank">
45
+ <tipi-icon icon="open-blank" class="c-icon--secondary" />
46
+ </a>
47
+ </router-link>
48
+ </div>
49
+ </div>
50
+ </article>
51
+ </div>
52
+ </template>
53
+
54
+ <script setup>
55
+ import { toRefs } from 'vue';
56
+
57
+ import TipiIcon from '../Icon/Icon.vue';
58
+ import TipiTopicPill from '../TopicPill/TopicPill.vue';
59
+ import TipiInitiativeMeta from '../InitiativeMeta/InitiativeMeta.vue';
60
+
61
+ const props = defineProps({
62
+ initiative: Object,
63
+ topicsStyles: Object,
64
+ extendedLayout: Boolean,
65
+ metaDeputies: String,
66
+ metaGroupsOthers: String,
67
+ metaColors: { type: Object, default: undefined },
68
+ });
69
+
70
+ const { initiative, extendedLayout, metaDeputies, metaGroupsOthers, metaColors } = toRefs(props);
71
+ const { topicsStyles } = props;
72
+
73
+ const getAuthors = () => {
74
+ return initiative.value.authors.length ? initiative.value.authors.join('<br/>') : '';
75
+ };
76
+
77
+ const getTopics = () => {
78
+ return initiative.value['tagged'].reduce((topics, tagged) => {
79
+ return topics.concat(tagged['topics']);
80
+ }, []);
81
+ };
82
+
83
+ const getDeputies = () => {
84
+ if (initiative.value.deputies.length == 0) return '';
85
+ let regex_id = /\[.*\]/;
86
+ return initiative.value.deputies
87
+ .map((d) => {
88
+ var has_id = regex_id.exec(d);
89
+ if (!has_id) return d;
90
+ return d.replace(has_id[0], '').trim();
91
+ })
92
+ .join('<br/>');
93
+ };
94
+ </script>
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <div class="c-initiative-meta">
3
+ <div :class="`c-initiative-meta__status c-initiative-meta__status--${getColorByStatus()}`">
4
+ <strong>
5
+ <tipi-icon :icon="getIcon()"></tipi-icon>
6
+ {{ getStateMessage() }}
7
+ </strong>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script setup>
13
+ import { toRefs } from 'vue';
14
+ import { formatDistanceToNow } from 'date-fns/formatDistanceToNow';
15
+ import { es } from 'date-fns/locale/es';
16
+
17
+ import TipiIcon from '../Icon/Icon.vue';
18
+
19
+ const props = defineProps({
20
+ initiative: Object,
21
+ metaColors: {
22
+ type: Object,
23
+ default: function () {
24
+ return {
25
+ completed: [
26
+ 'Aprobada',
27
+ 'Respondida',
28
+ 'Celebrada',
29
+ 'Convertida en otra',
30
+ 'Acumulada en otra',
31
+ ],
32
+ neutral: ['En tramitación', 'Desconocida'],
33
+ error: [
34
+ 'No admitida a trámite',
35
+ 'No debatida',
36
+ 'Caducada',
37
+ 'Rechazada',
38
+ 'Retirada',
39
+ 'Derogada',
40
+ 'No celebrada',
41
+ ],
42
+ };
43
+ },
44
+ },
45
+ });
46
+
47
+ const { initiative, metaColors } = toRefs(props);
48
+
49
+ const getColorByStatus = () => {
50
+ for (let color in metaColors.value) {
51
+ if (metaColors.value[color].indexOf(initiative.value.status) != -1) return color;
52
+ }
53
+ return 'neutral';
54
+ };
55
+
56
+ const getIcon = () => {
57
+ const color = getColorByStatus();
58
+ const map = { completed: 'success', neutral: 'clock', error: 'denied' };
59
+ return map[color];
60
+ };
61
+
62
+ const getStateMessage = () => {
63
+ if (initiative.value['status'] == 'Desconocida') {
64
+ return `${initiative.value['status']}`;
65
+ }
66
+
67
+ const color = getColorByStatus();
68
+ let date = initiative.value['updated'];
69
+ if (color == 'neutral') {
70
+ date = initiative.value['created'];
71
+ }
72
+
73
+ const formattedDate = formatDistanceToNow(new Date(date), {
74
+ locale: es,
75
+ addSuffix: true,
76
+ }).replace('alrededor de ', '');
77
+ return `${initiative.value['status']} ${formattedDate}`;
78
+ };
79
+ </script>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div class="c-loader">
3
+ <div class="c-loader__spinner">
4
+ <div class="c-loader__spinner-dot"></div>
5
+ <div class="c-loader__spinner-dot"></div>
6
+ <div class="c-loader__spinner-dot"></div>
7
+ <div class="c-loader__spinner-dot"></div>
8
+ <div class="c-loader__spinner-dot"></div>
9
+ <div class="c-loader__spinner-dot"></div>
10
+ </div>
11
+ <div class="c-loader__text" v-if="title || subtitle">
12
+ <h4 v-if="title" class="c-loader__title">{{ title }}</h4>
13
+ {{ subtitle }}
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+ const { title, subtitle } = defineProps({
20
+ title: String,
21
+ subtitle: String,
22
+ });
23
+ </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div :class="`c-message c-message--${type} ${icon ? 'c-message--icon' : ''}`">
3
+ <div class="c-message__wrapper">
4
+ <TipiIcon class="c-message__icon" v-if="icon" :icon="type" />
5
+ <slot />
6
+ </div>
7
+ </div>
8
+ </template>
9
+
10
+ <script setup>
11
+ import { toRefs } from 'vue';
12
+
13
+ import TipiIcon from '../Icon/Icon.vue';
14
+
15
+ const props = defineProps({
16
+ type: {
17
+ type: String,
18
+ default: 'success',
19
+ validator: function (value) {
20
+ return ['success', 'error', 'info'].includes(value);
21
+ },
22
+ },
23
+ icon: Boolean,
24
+ });
25
+
26
+ const { type, icon } = toRefs(props);
27
+ </script>
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <header class="c-navbar">
3
+ <div class="c-disclaimer" v-if="!closedDisclaimer && disclaimerLink.hasOwnProperty('name')">
4
+ <a
5
+ v-if="disclaimerLink.external"
6
+ :href="disclaimerLink.route"
7
+ target="_blank"
8
+ v-html="disclaimerLink.name"
9
+ ></a>
10
+ <router-link
11
+ v-else
12
+ :to="{ name: disclaimerLink.route }"
13
+ v-html="disclaimerLink.name"
14
+ ></router-link>
15
+
16
+ <a class="c-disclaimer__close" href="#" @click="closeDisclaimer"
17
+ ><icon icon="close" color="#fff"
18
+ /></a>
19
+ </div>
20
+ <div v-if="preImage" class="c-decorator" :style="`background-image: url(${preImage})`"></div>
21
+ <div class="c-navbar__wrapper o-container">
22
+ <div class="c-navbar__brand">
23
+ <a class="c-navbar__brand-link" href="/"
24
+ ><img class="c-navbar__brand-logo" :src="logo"
25
+ /></a>
26
+ </div>
27
+ <button
28
+ type="button"
29
+ class="c-navbar__menu-toggle"
30
+ :class="{ 'is-active': menuVisible }"
31
+ v-on:click="toggleMenu"
32
+ >
33
+ <span class="bar"></span>
34
+ <span class="bar"></span>
35
+ <span class="bar"></span>
36
+ <span class="u-hide">Menú</span>
37
+ </button>
38
+ <nav class="c-navbar__menu" :class="{ 'is-active': menuVisible }">
39
+ <ul class="c-menu">
40
+ <li
41
+ @click="closeMenuMobile"
42
+ class="c-menu__item"
43
+ :class="{ 'has-submenu': link.children }"
44
+ v-for="link in links"
45
+ :key="link.route"
46
+ v-show="link.condition"
47
+ >
48
+ <a v-if="link.external" :href="link.route" class="c-menu__link" target="_blank"
49
+ >{{ link.name }}<icon :icon="link.icon" class="c-menu__icon" v-if="link.icon"
50
+ /></a>
51
+ <router-link v-else :to="{ name: link.route }" class="c-menu__link"
52
+ >{{ link.name }}<icon :icon="link.icon" class="c-menu__icon" v-if="link.icon"
53
+ /></router-link>
54
+ <ul class="c-menu__submenu" v-if="link.children">
55
+ <li
56
+ @click="closeMenuMobile"
57
+ class="c-menu__item"
58
+ v-for="child in link.children"
59
+ :key="child.route"
60
+ v-show="child.condition"
61
+ >
62
+ <a v-if="child.external" :href="child.route" class="c-menu__link" target="_blank"
63
+ >{{ child.name }}<icon :icon="child.icon" class="c-menu__icon" v-if="child.icon"
64
+ /></a>
65
+ <router-link v-else :to="{ name: child.route }" class="c-menu__link"
66
+ >{{ child.name }}<icon :icon="child.icon" class="c-menu__icon" v-if="child.icon"
67
+ /></router-link>
68
+ </li>
69
+ </ul>
70
+ </li>
71
+ </ul>
72
+ </nav>
73
+ </div>
74
+ </header>
75
+ </template>
76
+
77
+ <script setup>
78
+ import { ref, toRefs, computed } from 'vue';
79
+
80
+ import Icon from '../Icon/Icon.vue';
81
+
82
+ const props = defineProps({
83
+ links: Array,
84
+ disclaimerLink: {
85
+ type: Object,
86
+ default: function () {
87
+ return {};
88
+ },
89
+ },
90
+ preImage: String,
91
+ logo: String,
92
+ });
93
+
94
+ const { links, disclaimerLink, preImage, logo } = toRefs(props);
95
+
96
+ const closedMessage = ref(false);
97
+ const menuVisible = ref(false);
98
+
99
+ const closedDisclaimer = computed(() => {
100
+ return window.sessionStorage.getItem('closedDisclaimer') || closedMessage.value ? true : false;
101
+ });
102
+
103
+ const closeDisclaimer = () => {
104
+ window.sessionStorage.setItem('closedDisclaimer', true);
105
+ closedMessage.value = true;
106
+ };
107
+
108
+ const toggleMenu = () => {
109
+ menuVisible.value = !menuVisible.value;
110
+ };
111
+
112
+ const closeMenuMobile = () => {
113
+ if (menuVisible.value) {
114
+ menuVisible.value = false;
115
+ }
116
+ };
117
+ </script>