Skip to content

Commit dadcd0f

Browse files
author
Nathan Reyes
authored
Merge pull request #745 from nathanreyes/chore/remove-grid-component
Styling updates w/ Grid component removal
2 parents a6aaa06 + 1fbee49 commit dadcd0f

File tree

8 files changed

+95
-467
lines changed

8 files changed

+95
-467
lines changed

docs/changelog/v2.0.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,5 +397,11 @@ Fixes single use of `highlight.contentStyle` or `highlight.contentClass`
397397
### Bug Fixes
398398

399399
* Fix `popover.keepVisibleOnInput`
400-
* Remove unused code
401-
* Patch Media Query `addEventListener` for browsers < Safari 14, < Edge 16
400+
* Patch Media Query `addEventListener` for browsers < Safari 14, < Edge 16
401+
* Fix focus styles in navigation pane
402+
403+
### Enhancements
404+
405+
* Remove dedicated `Grid` component to reduce DOM elements and package size
406+
* Remove unnecessary JS/CSS
407+
* Tighten min pane width to 250px

src/components/Calendar.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import addMonths from 'date-fns/addMonths';
44
import addYears from 'date-fns/addYears';
55
import Popover from './Popover';
66
import PopoverRow from './PopoverRow';
7-
import Grid from './Grid';
87
import CalendarPane from './CalendarPane';
98
import CustomTransition from './CustomTransition';
109
import SvgIcon from './SvgIcon';
@@ -196,14 +195,11 @@ export default {
196195
},
197196
[
198197
h(
199-
Grid,
198+
'div',
200199
{
201-
class: 'grid',
202-
props: {
203-
rows: this.rows,
204-
columns: this.columns,
205-
columnWidth: 'minmax(256px, 1fr)',
206-
disableFocus: true,
200+
class: 'vc-pane-layout',
201+
style: {
202+
gridTemplateColumns: `repeat(${this.columns}, 1fr)`,
207203
},
208204
attrs: {
209205
...this.$attrs,
@@ -763,6 +759,10 @@ export default {
763759
}
764760
}
765761
762+
.vc-pane-layout {
763+
display: grid;
764+
}
765+
766766
.vc-arrow {
767767
display: flex;
768768
justify-content: center;

src/components/CalendarDay.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,7 @@ export default {
435435
<style lang="postcss" scoped>
436436
.vc-day {
437437
position: relative;
438-
min-height: 28px;
439-
width: 100%;
440-
height: 100%;
438+
min-height: 32px;
441439
z-index: 1;
442440
&.is-not-in-month * {
443441
opacity: 0;
@@ -458,23 +456,20 @@ export default {
458456
display: flex;
459457
justify-content: center;
460458
align-items: center;
461-
height: 100%;
462459
transform-origin: 50% 50%;
463460
}
464461
465462
.vc-day-box-left-center {
466463
display: flex;
467464
justify-content: flex-start;
468465
align-items: center;
469-
height: 100%;
470466
transform-origin: 0% 50%;
471467
}
472468
473469
.vc-day-box-right-center {
474470
display: flex;
475471
justify-content: flex-end;
476472
align-items: center;
477-
height: 100%;
478473
transform-origin: 100% 50%;
479474
}
480475
@@ -492,7 +487,7 @@ export default {
492487
font-weight: var(--font-medium);
493488
width: 28px;
494489
height: 28px;
495-
margin: 1.6px auto;
490+
line-height: 28px;
496491
border-radius: var(--rounded-full);
497492
user-select: none;
498493
cursor: pointer;

src/components/CalendarNav.vue

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
<!--Nav panel-->
33
<div class="vc-nav-container">
44
<!--Nav header-->
5-
<grid :columns="3" ref="headerGrid" @rollover="onHeaderRollover">
5+
<div class="vc-nav-header">
66
<!--Move prev button-->
77
<span
88
role="button"
99
class="vc-nav-arrow is-left"
10-
tabindex="-1"
10+
tabindex="0"
1111
@click="movePrev"
1212
@keydown="e => onSpaceOrEnter(e, movePrev)"
13-
ref="prevButton"
1413
>
1514
<slot name="nav-left-button">
1615
<svg-icon name="left-arrow" width="20px" height="24px" />
@@ -24,51 +23,41 @@
2423
tabindex="0"
2524
@click="toggleMode"
2625
@keydown="e => onSpaceOrEnter(e, toggleMode)"
27-
ref="titleButton"
2826
>
2927
{{ title }}
3028
</span>
3129
<!--Move next button-->
3230
<span
3331
role="button"
3432
class="vc-nav-arrow is-right"
35-
tabindex="-1"
33+
tabindex="0"
3634
@click="moveNext"
3735
@keydown="e => onSpaceOrEnter(e, moveNext)"
38-
ref="nextButton"
3936
>
4037
<slot name="nav-right-button">
4138
<svg-icon name="right-arrow" width="20px" height="24px" />
4239
</slot>
4340
</span>
44-
</grid>
41+
</div>
4542
<!--Navigation items-->
46-
<grid
47-
:rows="4"
48-
:columns="3"
49-
gap="2px 5px"
50-
ref="itemsGrid"
51-
@rollover="onItemsRollover"
52-
>
43+
<div class="vc-nav-items">
5344
<span
5445
v-for="item in activeItems"
5546
:key="item.label"
5647
role="button"
5748
:aria-label="item.ariaLabel"
5849
:class="getItemClasses(item)"
59-
:tabindex="item.isDisabled ? undefined : item.isActive ? 0 : -1"
50+
:tabindex="item.isDisabled ? undefined : 0"
6051
@click="item.click"
6152
@keydown="e => onSpaceOrEnter(e, item.click)"
62-
ref="items"
6353
>
6454
{{ item.label }}
6555
</span>
66-
</grid>
56+
</div>
6757
</div>
6858
</template>
6959

7060
<script>
71-
import Grid from './Grid';
7261
import SvgIcon from './SvgIcon';
7362
import { childMixin } from '../utils/mixins';
7463
import { head, last } from '../utils/_';
@@ -79,7 +68,6 @@ const _yearGroupCount = 12;
7968
export default {
8069
name: 'CalendarNav',
8170
components: {
82-
Grid,
8371
SvgIcon,
8472
},
8573
mixins: [childMixin],
@@ -160,18 +148,13 @@ export default {
160148
created() {
161149
this.yearIndex = this.year;
162150
},
163-
mounted() {
164-
this.$refs.itemsGrid.tryFocus();
165-
},
166151
methods: {
167152
getItemClasses({ isActive, isCurrent, isDisabled }) {
168153
const classes = ['vc-nav-item'];
169154
if (isActive) {
170-
classes.push('is-active', 'vc-grid-focus');
155+
classes.push('is-active');
171156
} else if (isCurrent) {
172-
classes.push('is-inactive-current');
173-
} else {
174-
classes.push('is-inactive');
157+
classes.push('is-current');
175158
}
176159
if (isDisabled) {
177160
classes.push('is-disabled');
@@ -187,7 +170,6 @@ export default {
187170
yearClick(year) {
188171
this.yearIndex = year;
189172
this.monthMode = true;
190-
this.$refs.itemsGrid.tryFocus();
191173
},
192174
toggleMode() {
193175
this.monthMode = !this.monthMode;
@@ -216,40 +198,16 @@ export default {
216198
moveNextYearGroup() {
217199
this.yearGroupIndex++;
218200
},
219-
onHeaderRollover(e) {
220-
switch (e.direction) {
221-
case 'vertical-trailing':
222-
this.$refs.itemsGrid.tryFocus();
223-
break;
224-
}
225-
e.handled = true;
226-
},
227-
onItemsRollover(e) {
228-
switch (e.direction) {
229-
case 'horizontal-leading': {
230-
this.movePrev();
231-
break;
232-
}
233-
case 'horizontal-trailing': {
234-
this.moveNext();
235-
break;
236-
}
237-
case 'vertical-leading': {
238-
this.$refs.headerGrid.tryFocus();
239-
e.handled = true;
240-
break;
241-
}
242-
case 'vertical-trailing': {
243-
e.handled = true;
244-
break;
245-
}
246-
}
247-
},
248201
},
249202
};
250203
</script>
251204

252205
<style lang="postcss">
206+
.vc-nav-header {
207+
display: flex;
208+
justify-content: space-between;
209+
}
210+
253211
.vc-nav-arrow {
254212
display: flex;
255213
justify-content: center;
@@ -282,6 +240,7 @@ export default {
282240
border-width: 2px;
283241
border-style: solid;
284242
border-color: transparent;
243+
user-select: none;
285244
&:hover {
286245
background-color: var(--gray-900);
287246
}
@@ -290,6 +249,13 @@ export default {
290249
}
291250
}
292251
252+
.vc-nav-items {
253+
display: grid;
254+
grid-template-columns: repeat(3, 1fr);
255+
grid-row-gap: 2px;
256+
grid-column-gap: 5px;
257+
}
258+
293259
.vc-nav-item {
294260
width: 48px;
295261
text-align: center;
@@ -301,6 +267,7 @@ export default {
301267
border-width: 2px;
302268
border-style: solid;
303269
border-radius: var(--rounded);
270+
user-select: none;
304271
&:hover {
305272
color: var(--white);
306273
background-color: var(--gray-900);
@@ -312,14 +279,10 @@ export default {
312279
&.is-active {
313280
color: var(--accent-900);
314281
background: var(--accent-100);
315-
border-color: transparent;
316282
font-weight: var(--font-bold);
317283
box-shadow: var(--shadow);
318284
}
319-
&.is-inactive {
320-
border-color: transparent;
321-
}
322-
&:is-inactive-current {
285+
&:is-current {
323286
color: var(--accent-100);
324287
font-weight: var(--bold);
325288
border-color: var(--accent-100);
@@ -361,7 +324,7 @@ export default {
361324
color: var(--white);
362325
background: var(--accent-500);
363326
}
364-
&.is-inactive-current {
327+
&.is-current {
365328
color: var(--accent-600);
366329
border-color: var(--accent-500);
367330
}

0 commit comments

Comments
 (0)