Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox input color #413

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/components/forms/CheckboxInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
v-model="compVal"
:disabled="disabled ? true : null"
:name="name"
:color="color"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the color prop to the component's props definition in the script section to ensure it's fully integrated and reactive.

  props: {
    ...inputProps,
+   color: String,  // Add this line to handle the color prop
  },

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
:color="color"
props: {
...inputProps,
color: String, // Add this line to handle the color prop
},

>
<slot name="label">
{{ label }}
Expand Down
1 change: 1 addition & 0 deletions client/components/forms/ToggleSwitchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
v-model="compVal"
class="inline-block mr-2"
:disabled="disabled ? true : null"
:color="color"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider explicitly declaring the color prop in the component's props definition for better clarity and maintainability.

  props: {
    ...inputProps,
+   color: {
+     type: String,
+     default: null
+   },
  },

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
:color="color"
props: {
...inputProps,
color: {
type: String,
default: null
},
},

/>
<slot name="label">
<span>{{ label }}
Expand Down
18 changes: 9 additions & 9 deletions client/components/forms/components/VCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
:name="name"
type="checkbox"
:class="sizeClasses"
class="rounded border-gray-500 cursor-pointer"
class="rounded border-gray-500 cursor-pointer checkbox"
:style="{ '--accent-color': color }"
:disabled="disabled ? true : null"
>
<label
Expand All @@ -20,14 +21,7 @@
</template>

<script setup>
import {
defineEmits,
defineOptions,
defineProps,
onMounted,
ref,
watch,
} from "vue"
import { defineEmits, defineOptions, defineProps, onMounted, ref, watch, } from "vue"

defineOptions({
name: "VCheckbox",
Expand All @@ -39,6 +33,7 @@ const props = defineProps({
modelValue: { type: [Boolean, String], default: false },
disabled: { type: Boolean, default: false },
sizeClasses: { type: String, default: "w-4 h-4" },
color: { type: String, default: null },
})

const emit = defineEmits(["update:modelValue", "click"])
Expand Down Expand Up @@ -73,3 +68,8 @@ onMounted(() => {
if (internalValue.value === null) internalValue.value = false
})
</script>
<style>
.checkbox {
accent-color: var(--accent-color);
}
Comment on lines +72 to +74
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The CSS variable --accent-color is used in VCheckbox.vue but is not defined anywhere in the codebase. This could lead to issues when the CSS rule is applied.

  • client/components/forms/components/VCheckbox.vue: accent-color: var(--accent-color);
Analysis chain

The CSS rule for setting the accent-color is correctly implemented. Ensure that the CSS variable --accent-color is defined in your project's global style or theme files.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the definition of the CSS variable `--accent-color`.

# Test: Search for the variable definition. Expect: At least one occurrence.
rg --type css 'var\(--accent-color\)'

Length of output: 39



Script:

#!/bin/bash
# Description: Verify the definition of the CSS variable `--accent-color`.

# Test: Search for the variable definition in various file types.
rg 'var\(--accent-color\)' --type-add 'scss' --type-add 'less' --type-add 'js'

Length of output: 134



Script:

#!/bin/bash
# Description: Verify the definition of the CSS variable `--accent-color`.

# Test: Search for the variable definition in various file types.
rg 'var\(--accent-color\)' --type-add 'scss:*.scss' --type-add 'less:*.less' --type-add 'js:*.js'

Length of output: 187

</style>
10 changes: 9 additions & 1 deletion client/components/forms/components/VSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
>
<div
class="inline-flex items-center h-6 w-12 p-1 bg-gray-300 border rounded-full cursor-pointer focus:outline-none transition-all transform ease-in-out duration-100"
:class="{ 'bg-nt-blue': props.modelValue }"
:class="{ 'toggle-switch': props.modelValue }"
:style="{ '--accent-color': props.color }"

>
<div
class="inline-block h-4 w-4 rounded-full bg-white shadow transition-all transform ease-in-out duration-150 rounded-2xl scale-100"
Expand All @@ -21,6 +23,7 @@ import { defineEmits, defineProps } from "vue"
const props = defineProps({
modelValue: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
color: { type: String, default: null },
})
const emit = defineEmits(["update:modelValue"])

Expand All @@ -29,3 +32,8 @@ function onClick() {
emit("update:modelValue", !props.modelValue)
}
</script>
<style>
.toggle-switch {
background-color: var(--accent-color);
}
</style>
Loading