Skip to content

Commit bf0f134

Browse files
authored
Merge pull request #132 from Tresjs/feature/improve-ui
feat: add unocss-preset-scrollbar and update component styles
2 parents 55ce8f8 + 8c0bd70 commit bf0f134

22 files changed

+190
-116
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"dependencies": {
6262
"@unocss/core": "^65.4.2",
6363
"@vueuse/components": "^12.4.0",
64-
"@vueuse/motion": "^2.2.6"
64+
"@vueuse/motion": "^2.2.6",
65+
"unocss-preset-scrollbar": "^0.3.1"
6566
},
6667
"devDependencies": {
6768
"@histoire/plugin-vue": "^0.17.17",

pnpm-lock.yaml

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BooleanControl.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function onKeydown(event: KeyboardEvent) {
2222
</script>
2323

2424
<template>
25-
<div class="tl-flex tl-px-4 tl-justify-start tl-gap-2 tl-items-center tl-mb-2 tl-min-h-32px">
25+
<div class="tl-flex tl-px-4 tl-justify-start tl-items-center tl-mb-2 tl-min-h-32px">
2626
<label class="tl-text-gray-500 tl-w-1/3">{{ label }}</label>
2727
<input
2828
:id="control.uniqueKey"
@@ -48,6 +48,7 @@ function onKeydown(event: KeyboardEvent) {
4848
tl-rounded
4949
tl-border
5050
tl-border-gray-300
51+
tl-text-white
5152
tl-mr-2
5253
tl-transition-colors
5354
tl-duration-200"

src/components/ColorControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function onChange(event: Event) {
1515
</script>
1616

1717
<template>
18-
<div class="tl-flex tl-px-4 tl-justify-between tl-gap-4 tl-items-center tl-mb-2">
18+
<div class="tl-flex tl-px-4 tl-justify-between tl-items-center tl-mb-2">
1919
<label class="tl-text-gray-500 tl-w-1/3">{{ label }}</label>
2020
<input
2121
:id="control.uniqueKey"

src/components/FPSGraph.vue

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
11
<script lang="ts" setup>
2-
import { ref } from 'vue'
2+
import { onMounted, onUnmounted, ref } from 'vue'
33
import { useFps, useRafFn } from '@vueuse/core'
44
import type { LechesControl } from '../types'
55
66
defineProps<{
77
label: string
88
control: LechesControl
99
}>()
10-
const width = 160
11-
const height = 40
10+
11+
const containerRef = ref<HTMLElement | null>(null)
12+
const width = ref(160)
13+
const height = ref(40)
1214
const strokeWidth = 2
1315
const updateInterval = 100 // Update interval in milliseconds
1416
const topOffset = 20 // Offset from the top
1517
const fps = useFps({ every: updateInterval })
1618
1719
const points = ref('')
1820
const frameTimes = ref([])
19-
const maxFrames = ref(width / strokeWidth)
21+
const maxFrames = ref(width.value / strokeWidth)
2022
2123
let lastUpdateTime = performance.now()
24+
let resizeObserver: ResizeObserver | null = null
25+
26+
onMounted(() => {
27+
if (containerRef.value) {
28+
resizeObserver = new ResizeObserver((entries) => {
29+
for (const entry of entries) {
30+
width.value = entry.contentRect.width
31+
maxFrames.value = Math.floor(width.value / strokeWidth)
32+
// Trim frame times if needed after resize
33+
if (frameTimes.value.length > maxFrames.value) {
34+
frameTimes.value = frameTimes.value.slice(-maxFrames.value)
35+
}
36+
}
37+
})
38+
resizeObserver.observe(containerRef.value)
39+
}
40+
})
41+
42+
onUnmounted(() => {
43+
if (resizeObserver) {
44+
resizeObserver.disconnect()
45+
}
46+
})
2247
2348
useRafFn(({ timestamp }) => {
2449
if (timestamp - lastUpdateTime >= updateInterval) {
@@ -34,7 +59,7 @@ useRafFn(({ timestamp }) => {
3459
.map(
3560
(fps, index) =>
3661
`${index * strokeWidth},${
37-
height + topOffset - strokeWidth / 2 - (fps * (height + topOffset - strokeWidth)) / 120
62+
height.value + topOffset - strokeWidth / 2 - (fps * (height.value + topOffset - strokeWidth)) / 120
3863
}`,
3964
)
4065
.join(' ')
@@ -43,20 +68,20 @@ useRafFn(({ timestamp }) => {
4368
</script>
4469

4570
<template>
46-
<div class="tl-flex tl-px-4 tl-justify-between tl-gap-4 tl-items-center tl-mb-2">
71+
<div class="tl-flex tl-px-4 tl-items-center tl-mb-2">
4772
<label class="tl-text-gray-500 tl-w-1/3">{{ label }}</label>
4873

4974
<div
75+
ref="containerRef"
5076
class="
5177
tl-relative
5278
tl-w-2/3
53-
tl-p-1
79+
tl-py-1
5480
tl-rounded
5581
tl-text-right
5682
tl-text-xs
5783
tl-text-gray-400
5884
tl-bg-gray-100
59-
tl-focus:border-gray-200
6085
tl-outline-none
6186
tl-border-none
6287
tl-font-sans

src/components/NumberControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ watch(mouse.x, (newValue) => {
5757
</script>
5858

5959
<template>
60-
<div class="tl-flex tl-px-4 tl-justify-between tl-gap-4 tl-items-center tl-mb-2">
60+
<div class="tl-flex tl-px-4 tl-justify-between tl-items-center tl-mb-2">
6161
<ControlLabel
6262
:label="label"
6363
:control="control"

src/components/SelectControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function onChange(event: Event) {
1515
</script>
1616

1717
<template>
18-
<div class="tl-flex tl-px-4 tl-justify-between tl-gap-4 tl-items-center tl-mb-2 tl-min-h-32px">
18+
<div class="tl-flex tl-px-4 tl-justify-start tl-items-center tl-mb-2 tl-min-h-32px">
1919
<ControlLabel
2020
:label="label"
2121
:control="control"

src/components/SliderControl.vue

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,45 +63,47 @@ watch(mouse.x, (newValue) => {
6363
</script>
6464

6565
<template>
66-
<div class="tl-px-4 tl-relative tl-flex tl-justify-between tl-gap-4 tl-items-center tl-mb-2">
66+
<div class="tl-px-4 tl-relative tl-flex tl-justify-between tl-items-center tl-mb-2">
6767
<ControlLabel
6868
:label="label"
6969
:control="control"
7070
/>
71-
<input
72-
:value="control.value"
73-
class="tl-w-1/2 tl-h-0.75 tl-bg-dark-200 tl-rounded-full tl-appearance-none"
74-
:style="sliderFilledStyle"
75-
type="range"
76-
:min="control.min"
77-
:max="control.max"
78-
:step="control.step"
79-
@input="onChange"
80-
/>
81-
<input
82-
:value="control.value"
83-
class="
84-
tl-p-2
85-
tl-w-1/4
86-
tl-rounded
87-
tl-text-right
88-
tl-text-xs
89-
tl-text-gray-400
90-
tl-bg-gray-100
91-
tl-focus:border-gray-200
92-
tl-outline-none
93-
tl-border-none
94-
tl-font-sans
95-
"
96-
:class="{ 'tl-cursor-ew-resize': isMouseDown }"
97-
type="number"
98-
:min="control.min"
99-
:max="control.max"
100-
:step="control.step"
101-
@input="onChange"
102-
@mousedown="onInputMouseDown"
103-
@mouseup="onInputMouseUp"
104-
/>
71+
<div class="tl-relative tl-w-2/3 tl-flex tl-justify-between tl-items-center tl-gap-0.5">
72+
<input
73+
:value="control.value"
74+
class="tl-w-1/2 tl-h-0.75 tl-bg-dark-200 tl-rounded-full tl-appearance-none"
75+
:style="sliderFilledStyle"
76+
type="range"
77+
:min="control.min"
78+
:max="control.max"
79+
:step="control.step"
80+
@input="onChange"
81+
/>
82+
<input
83+
:value="control.value"
84+
class="
85+
tl-p-2
86+
tl-w-1/4
87+
tl-rounded
88+
tl-text-right
89+
tl-text-xs
90+
tl-text-gray-400
91+
tl-bg-gray-100
92+
tl-focus:border-gray-200
93+
tl-outline-none
94+
tl-border-none
95+
tl-font-sans
96+
"
97+
:class="{ 'tl-cursor-ew-resize': isMouseDown }"
98+
type="number"
99+
:min="control.min"
100+
:max="control.max"
101+
:step="control.step"
102+
@input="onChange"
103+
@mousedown="onInputMouseDown"
104+
@mouseup="onInputMouseUp"
105+
/>
106+
</div>
105107
</div>
106108
</template>
107109

@@ -114,10 +116,10 @@ input[type='range'] {
114116
}
115117
116118
input[type='range']::-webkit-slider-thumb {
117-
@apply tl-h-4 tl-w-3 tl-border-2 tl-bg-dark-200 tl-rounded-sm tl-cursor-pointer tl-appearance-none tl-shadow-lg;
119+
@apply h-4 w-3 border-2 bg-dark-200 rounded-sm cursor-pointer appearance-none shadow-lg;
118120
}
119121
120122
input[type='range']::-moz-range-thumb {
121-
@apply tl-h-4 tl-w-3 tl-border-2 tl-bg-dark-200 tl-rounded-sm tl-cursor-pointer tl-appearance-none tl-shadow-lg;
123+
@apply h-4 w-3 border-2 bg-dark-200 rounded-sm cursor-pointer appearance-none shadow-lg;
122124
}
123125
</style>

src/components/TextControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function onChange(event: Event) {
1616
</script>
1717

1818
<template>
19-
<div class="tl-flex tl-px-4 tl-justify-between tl-gap-4 tl-items-center tl-mb-2 tl-min-h-32px">
19+
<div class="tl-flex tl-px-4 tl-justify-between tl-items-center tl-mb-2 tl-min-h-32px">
2020
<ControlLabel
2121
:label="label"
2222
:control="control"

src/components/TresLeches.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ watch(isCollapsed, async (value) => {
162162
<div
163163
:id="`tres-leches-pane-${uuid}`"
164164
ref="paneRef"
165-
class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-overflow-hidden"
165+
class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-flex tl-flex-col"
166166
:class="[$attrs.class, isCollapsed ? 'tl-rounded-full' : 'tl-rounded-lg']"
167167
:style="[style, { width: `${panelWidth}px`, height: `${panelHeight}px`, right: '16px', left: 'auto' }]"
168168
>
169-
<header class="tl-flex tl-justify-between tl-items-center tl-text-gray-200 tl-text-xs">
169+
<header class="tl-flex tl-justify-between tl-items-center tl-text-gray-200 tl-text-xs tl-flex-none">
170170
<div v-show="!isCollapsed" class="w-1/3"></div>
171171
<div v-show="!isCollapsed" ref="handleRef" class="tl-cursor-grabbing">
172172
<i class="i-ic-baseline-drag-indicator"></i><i class="i-ic-baseline-drag-indicator"></i><i
@@ -190,7 +190,7 @@ watch(isCollapsed, async (value) => {
190190
@mouseleave="isHover = false"
191191
>🍰</i>
192192
</header>
193-
<div v-if="!isCollapsed" class="mt-2">
193+
<div v-if="!isCollapsed" class="tl-flex-1 tl-overflow-y-auto tl-overflow-x-hidden tl-my-4 tl-scrollbar tl-scrollbar-rounded tl-scrollbar-w-4px tl-scrollbar-radius-2 tl-scrollbar-track-radius-4 tl-scrollbar-thumb-radius-4">
194194
<template
195195
v-for="(group, folderName) of groupedControls"
196196
:key="folderName"

0 commit comments

Comments
 (0)