Skip to content

Commit bc2bf26

Browse files
committed
Tweaks
1 parent f9f04d5 commit bc2bf26

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ app.use(degreePicker);
2727

2828
```vue
2929
<template>
30-
<degree-picker color="green" v-model="degrees" />
30+
<degree-picker active-color="green" v-model="degrees" />
3131
</template>
3232
3333
<script lang="ts" setup>
@@ -39,11 +39,13 @@ const degrees = ref(0);
3939

4040
## 📃 Props
4141

42-
| ID | Type | Default | Description |
43-
| ----------- | --------------- | ------- | ---------------------------------------------------------------------------------------------------------------- |
44-
| `color` | `string` | | Background color of the active value and clock hand |
45-
| `v-model` | `number` | | Standard two way input |
46-
| `width` | `number/string` | 290px | Sets the width of the element - can be provided as a string like "290px" or "290" or a number, defaults to 290px |
47-
| `fullWidth` | `boolean` | | Ignores the previous `width` prop and sets the width to 100% of the parent container |
48-
| `disabled` | `boolean` | | Makes the component unclickable |
49-
| `readonly` | `boolean` | | Makes the component unclickable, but does not make it seem disabled |
42+
| Name | Type | Default | Description |
43+
| -------------- | --------------- | ------- | ---------------------------------------------------------------------------------------------------------------- |
44+
| `active-color` | `string` | #567a0d | Background color of the active value and clock hand |
45+
| `body-color` | `string` | #eee | Background color of the picker body |
46+
| `v-model` | `number` | | Standard two way input |
47+
| `step` | `number` | 30 | The step used for displaying the degrees |
48+
| `width` | `number/string` | 290px | Sets the width of the element - can be provided as a string like "290px" or "290" or a number, defaults to 290px |
49+
| `full-width` | `boolean` | false | Ignores the previous `width` prop and sets the width to 100% of the parent container |
50+
| `disabled` | `boolean` | false | Makes the component unclickable |
51+
| `readonly` | `boolean` | false | Makes the component unclickable, but does not make it seem disabled |

src/components/degreePicker.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
}"
66
>
77
<degree-picker-body
8-
:color="color"
8+
:active-color="activeColor"
9+
:body-color="activeColor"
910
@input="onInput"
1011
@change="onChange"
1112
:step="step || 30"
@@ -26,17 +27,24 @@ const emit = defineEmits<{
2627
(e: "update:modelValue", degrees: number): void;
2728
}>();
2829
29-
const props = defineProps<{
30-
disabled?: boolean;
31-
min?: string;
32-
max?: string;
33-
readonly?: boolean;
34-
fullWidth?: boolean;
35-
color?: string;
36-
modelValue: number;
37-
width?: number | string;
38-
step?: number;
39-
}>();
30+
const props = withDefaults(
31+
defineProps<{
32+
disabled?: boolean;
33+
min?: string;
34+
max?: string;
35+
readonly?: boolean;
36+
fullWidth?: boolean;
37+
activeColor?: string;
38+
bodyColor?: string;
39+
modelValue: number;
40+
width?: number | string;
41+
step?: number;
42+
}>(),
43+
{
44+
activeColor: "#567a0d",
45+
bodyColor: "#eee"
46+
}
47+
);
4048
4149
const state = reactive({
4250
inputDegree: null as number | null,

src/components/degreePickerBody.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const clock = ref<HTMLElement | null>(null);
5454
const props = defineProps<{
5555
disabled?: boolean;
5656
readonly?: boolean;
57-
color?: string;
57+
activeColor?: string;
58+
bodyColor?: string;
5859
value: number | null;
5960
min: number;
6061
max: number;
@@ -86,7 +87,7 @@ const clockHandStyle = computed(() => ({
8687
transform: `rotate(${
8788
degreesPerUnit.value * (displayedValue.value - props.min)
8889
}deg)`,
89-
backgroundColor: props.value !== null ? props.color : undefined
90+
backgroundColor: props.value !== null ? props.activeColor : undefined
9091
}));
9192
9293
const displayedValue = computed(() =>
@@ -108,7 +109,7 @@ const getTransform = (i: number) => {
108109
top: `${50 + y * 50}%`,
109110
backgroundColor:
110111
props.value !== null && i === displayedValue.value
111-
? props.color
112+
? props.activeColor
112113
: undefined
113114
};
114115
};
@@ -184,7 +185,7 @@ watch(
184185
<style scoped>
185186
.degree-picker-clock {
186187
font-family: "Roboto";
187-
background-color: #eee;
188+
background-color: v-bind(bodyColor);
188189
border-radius: 100%;
189190
position: relative;
190191
transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
@@ -237,7 +238,7 @@ watch(
237238
background: transparent;
238239
border-width: 2px;
239240
border-style: solid;
240-
border-color: v-bind(color);
241+
border-color: v-bind(activeColor);
241242
border-radius: 100%;
242243
width: 10px;
243244
height: 10px;
@@ -257,8 +258,8 @@ watch(
257258
left: 50%;
258259
border-radius: 100%;
259260
border-style: solid;
260-
border-color: v-bind("color");
261-
background-color: v-bind("color");
261+
border-color: v-bind("activeColor");
262+
background-color: v-bind("activeColor");
262263
transform: translate(-50%, -50%);
263264
}
264265

0 commit comments

Comments
 (0)