-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeline2014.vue
More file actions
158 lines (142 loc) · 3.88 KB
/
Copy pathTimeline2014.vue
File metadata and controls
158 lines (142 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<script setup lang="ts">
import { computed } from 'vue';
import BubbleGroup from './BubbleGroup.vue';
import TimelineArrow from './TimelineArrow.vue';
import {
KEY_2014_START,
KEY_2014_INTRO,
KEY_2014_INTRO_BUBBLES,
KEY_2014_INEFFECT,
KEY_2014_INEFFECT_HIGHLIGHT,
KEY_2014_DEAD,
KEY_2014_DEAD_HIGHLIGHT,
KEY_2014_YEAREND,
KEY_2014_COLLAPSE,
TRIGGERS,
} from '../helpers/timelineKeyframes'
import type { Law, Trigger } from '../helpers/types';
import { INEFFECT, DEAD } from '../helpers/billStatus'
import TimelineDate from './TimelineDate.vue';
import TimelineText from './TimelineText.vue';
const props = defineProps({
allLaws: {
type: Array<Law>,
required: true,
},
keyframe: {
type: Number,
required: true,
},
fired: {
type: Array<Trigger>,
required: true,
},
progress: {
type: Number,
required: true,
},
})
const laws = computed(() => {
return props.allLaws.filter(law => law.year === 2014)
})
const keyFired = (key : number) => {
return !!props.fired.find(t => t.id === key);
}
const setLabel = (laws: Law[], status: string, label: string) : Law[] => {
const i = laws.findIndex(l => l.status === status)
if (i > -1) {
laws[i].label = label
}
return laws
}
const currentLaws = computed(() => {
if (keyFired(KEY_2014_YEAREND)) {
let currentLaws = laws.value.slice()
setLabel(currentLaws, DEAD, '')
return currentLaws;
} else if (keyFired(KEY_2014_INTRO_BUBBLES)) {
let currentLaws = laws.value.slice(0, 8)
if (keyFired(KEY_2014_DEAD_HIGHLIGHT)) {
setLabel(currentLaws, DEAD, 'Dead')
} else if (keyFired(KEY_2014_DEAD)) {
setLabel(currentLaws, INEFFECT, '')
} else if (keyFired(KEY_2014_INEFFECT_HIGHLIGHT)) {
setLabel(currentLaws, INEFFECT, 'In Effect')
}
return currentLaws
}
return []
})
const end = TRIGGERS
.find(t => t.id === KEY_2014_COLLAPSE)
?.progress
const yearProgress = computed(() => {
return Math.min(
end ? props.progress / end : 1,
1
)
})
</script>
<template>
<div class="timeline-year">
<TimelineArrow :progress="yearProgress" />
<TimelineDate :keyframe="keyframe" :target="KEY_2014_START">
2014
</TimelineDate>
<div class="timeline-text-group">
<TimelineText :keyframe="keyframe" :start="KEY_2014_START" :end="KEY_2014_COLLAPSE">
<span class="fade" :class="keyframe >= KEY_2014_INTRO ? 'fade-in' : 'fade-out'">
Eight measures are introduced in January.
</span>
<span class="fade" :class="keyframe >= KEY_2014_INEFFECT ? 'fade-in' : 'fade-out'">
Two of them — in Maryland and Pennsylvania — are adopted.
</span>
<span class="fade" :class="keyframe >= KEY_2014_DEAD ? 'fade-in' : 'fade-out'">
The rest are defeated or withdrawn without a vote.
</span>
<span class="fade" :class="keyframe >= KEY_2014_YEAREND ? 'fade-in' : 'fade-out'">
By the end of the year 18 anti-boycott measures have been introduced.
</span>
</TimelineText>
</div>
<BubbleGroup :laws="currentLaws" class="bubble-group-2014" :class="keyframe < KEY_2014_COLLAPSE ? 'bubble-group-2014-big' : ''"/>
</div>
</template>
<style lang="postcss">
@import '../assets/css/variables.css';
.bubble-group-2014 {
width: 9.8rem; /* 8 bubbles per row */
transform: scale(1, 1);
transform-origin: left top;
transition: all 0.6s 0.6s;
}
.bubble-group-2014-big {
transform: scale(1.7, 1.7);
gap: 0.125rem;
& .bubble-label-text {
transform: scale(0.6, 0.6);
}
}
@media (orientation: portrait) {
@media (--tablets-sm) {
.bubble-group-2014 {
width: 19.6rem;
}
.bubble-group-2014-big {
gap: 0.25rem
}
}
}
@media (orientation: landscape) {
@media (--tablets-landscape) {
.bubble-group-2014 {
width: 16.5rem;
}
}
@media (--laptops) {
.bubble-group-2014 {
width: 18.5rem;
}
}
}
</style>