Skip to content

Commit 1720084

Browse files
l
1 parent 7851c77 commit 1720084

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

apps/nobel/src/pages/UI.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
</Button>
4545

4646
<Select />
47-
<Select />
47+
<!-- <Select /> -->
4848

4949
<section class="buttons">
5050
<Button variant="primary" size="mini">

packages/nobel/components/ui/Select.vue

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const values = ref([
1616
'Orange',
1717
])
1818
const open = ref(false)
19+
const activeItemAboveCenter = ref(false)
1920
2021
const ListContent = useTemplateRef<HTMLDivElement>('ListContent')
2122
@@ -28,12 +29,29 @@ function handleClick() {
2829
open.value = !open.value
2930
}
3031
32+
// setInterval(() => {
33+
// open.value = !open.value
34+
// }, 1000)
35+
36+
const transitionMax = 0.4
37+
const transitionMin = transitionMax / 2
38+
const transition = ref(transitionMax)
39+
3140
function handleItemClick(v: string, index: number, event: MouseEvent) {
3241
value.value = v
3342
const itemClicked = event.currentTarget as HTMLDivElement
3443
const itemClickedHeight = itemClicked.clientHeight
3544
if (!ListContent.value) return
3645
46+
const numberOfItems = values.value.length
47+
const halfWay = numberOfItems / 2
48+
49+
if (index < halfWay) {
50+
activeItemAboveCenter.value = true
51+
} else {
52+
activeItemAboveCenter.value = false
53+
}
54+
3755
const listContentHeight = ListContent.value.clientHeight
3856
const amountOfItems = values.value.length
3957
@@ -50,8 +68,9 @@ function handleItemClick(v: string, index: number, event: MouseEvent) {
5068
<button
5169
ref="button"
5270
class="SelectRoot button buttonFocus buttonHover"
53-
:class="{ open: open }"
71+
:class="{ open: open, aboveHalf: activeItemAboveCenter }"
5472
@click="handleClick"
73+
anchor="select"
5574
>
5675
<p class="space-value">{{ longestValue }}</p>
5776
<div class="SelectList">
@@ -100,7 +119,6 @@ function handleItemClick(v: string, index: number, event: MouseEvent) {
100119
left: 0;
101120
z-index: 2;
102121
103-
height: var(--option-height);
104122
overflow: hidden;
105123
106124
display: flex;
@@ -110,25 +128,43 @@ function handleItemClick(v: string, index: number, event: MouseEvent) {
110128
111129
background: var(--base-10);
112130
box-shadow: 10px 10px 50px 50px red;
113-
transition: 0.4s;
131+
transition: 1s;
114132
interpolate-size: allow-keywords;
115133
}
116134
117135
.SelectRoot.open .SelectList {
118136
bottom: calc(v-bind(itemOffsetBottom) * -1px);
119137
top: calc(v-bind(itemOffsetTop) * -1px);
120-
height: auto;
138+
right: 0;
139+
left: 0;
140+
width: 100%;
121141
}
122142
123143
.SelectList-content {
124-
margin-top: calc(v-bind(itemOffsetTop) * -1px);
125-
transition: 0.4s linear;
144+
position: fixed;
145+
146+
bottom: anchor(center);
147+
148+
width: 100%;
149+
transition: 1s linear;
150+
}
151+
/*
152+
.SelectRoot.aboveHalf .SelectList-content {
153+
top: calc(v-bind(itemOffsetTop) * -1px);
154+
}
155+
156+
.SelectRoot.aboveHalf.open .SelectList-content {
157+
top: 0;
126158
}
127159
128-
.SelectRoot.open .SelectList .SelectList-content {
129-
margin-top: 0;
160+
.SelectRoot:not(.aboveHalf) .SelectList-content {
161+
bottom: calc(v-bind(itemOffsetBottom) * -1px);
130162
}
131163
164+
.SelectRoot:not(.aboveHalf).open .SelectList-content {
165+
bottom: 0;
166+
} */
167+
132168
.SelectList .SelectOption {
133169
display: flex;
134170
gap: var(--space-1);

0 commit comments

Comments
 (0)