-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from stevebauman/custom-colors
Add background color picker
- Loading branch information
Showing
5 changed files
with
161 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,15 @@ | ||
<template> | ||
<V-Popover | ||
<ColorPicker | ||
v-bind="$attrs" | ||
boundaries-element="body" | ||
class="flex justify-center" | ||
popover-inner-class="overflow-hidden border-2 rounded-lg shadow-xl bg-ui-gray-700 border-ui-gray-800" | ||
#default="{ backgroundColor }" | ||
> | ||
<Button class="w-full tooltip-target"> | ||
<span class="w-6 h-6 rounded-full" :style="{ backgroundColor: backgroundColor }" /> | ||
|
||
Pick Color | ||
</Button> | ||
|
||
<template #popover> | ||
<Chrome | ||
:value="{ r: value.red, g: value.green, b: value.blue, a: value.alpha }" | ||
@input=" | ||
({ rgba }) => { | ||
$emit('change', { | ||
red: rgba.r, | ||
green: rgba.g, | ||
blue: rgba.b, | ||
alpha: rgba.a, | ||
}); | ||
} | ||
" | ||
/> | ||
</template> | ||
</V-Popover> | ||
</ColorPicker> | ||
</template> | ||
|
||
<style> | ||
.vc-chrome { | ||
@apply !rounded-lg !bg-none !shadow-none; | ||
} | ||
.vc-chrome-body { | ||
@apply !bg-ui-gray-700; | ||
} | ||
.vc-saturation { | ||
@apply m-2 rounded-lg; | ||
} | ||
.vc-chrome-saturation-wrap { | ||
@apply p-6 !bg-ui-gray-700; | ||
} | ||
.vc-saturation--white { | ||
@apply rounded-lg; | ||
} | ||
.vc-saturation--black { | ||
@apply rounded-lg; | ||
} | ||
.vc-chrome-fields-wrap { | ||
@apply space-x-2; | ||
} | ||
.vc-chrome-fields .vc-input__input { | ||
@apply !border-0 !rounded-lg !shadow-none !text-ui-gray-400 !bg-ui-gray-600 hover:bg-ui-gray-900 focus:outline-none focus:ring-0; | ||
} | ||
.vc-chrome-fields .vc-input__label { | ||
@apply text-xs font-semibold text-ui-gray-300 whitespace-nowrap; | ||
} | ||
.vc-chrome-toggle-btn { | ||
@apply flex items-center !text-ui-gray-300 rounded-lg border border-gray-300 justify-center transition duration-100 ease-in-out bg-ui-gray-700 hover:bg-ui-gray-900; | ||
} | ||
[color-scheme='dark'] .vc-chrome-toggle-btn { | ||
@apply border-ui-gray-900; | ||
} | ||
.vc-chrome-toggle-icon { | ||
@apply !m-0 inline-flex items-center gap-2 leading-none transition duration-100 ease-in-out focus:outline-none focus:ring-0; | ||
} | ||
.vc-chrome-toggle-icon svg path { | ||
fill: currentColor !important; | ||
} | ||
.vc-chrome-toggle-icon-highlight { | ||
@apply hidden; | ||
} | ||
</style> | ||
|
||
<script> | ||
import { Chrome } from 'vue-color'; | ||
import { computed } from '@nuxtjs/composition-api'; | ||
export default { | ||
props: { | ||
value: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
components: { Chrome }, | ||
setup(props) { | ||
const backgroundColor = computed(() => { | ||
return `rgb(${props.value.red}, ${props.value.green}, ${props.value.blue})`; | ||
}); | ||
return { backgroundColor }; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<template> | ||
<V-Popover | ||
boundaries-element="body" | ||
class="flex justify-center" | ||
popover-inner-class="overflow-hidden border rounded-lg shadow-xl bg-ui-gray-700 border-ui-gray-800" | ||
> | ||
<slot :background-color="backgroundColor" /> | ||
|
||
<template #popover> | ||
<Chrome | ||
:value="{ r: rgba.red, g: rgba.green, b: rgba.blue, a: rgba.alpha }" | ||
@input=" | ||
$emit('change', { | ||
red: $event.rgba.r, | ||
green: $event.rgba.g, | ||
blue: $event.rgba.b, | ||
alpha: $event.rgba.a, | ||
}) | ||
" | ||
/> | ||
</template> | ||
</V-Popover> | ||
</template> | ||
|
||
<style> | ||
.vc-chrome { | ||
@apply !rounded-md !bg-none !shadow-none; | ||
} | ||
.vc-chrome-body { | ||
@apply !bg-ui-gray-700; | ||
} | ||
.vc-saturation { | ||
@apply m-2 rounded-md; | ||
} | ||
.vc-chrome-saturation-wrap { | ||
@apply p-6 !bg-ui-gray-700; | ||
} | ||
.vc-saturation--white { | ||
@apply rounded-md; | ||
} | ||
.vc-saturation--black { | ||
@apply rounded-md; | ||
} | ||
.vc-chrome-fields-wrap { | ||
@apply space-x-2; | ||
} | ||
.vc-chrome-fields .vc-input__input { | ||
@apply !border-0 !rounded-md !shadow-none !text-ui-gray-400 !bg-ui-gray-600 hover:bg-ui-gray-900 focus:outline-none focus:ring-0; | ||
} | ||
.vc-chrome-fields .vc-input__label { | ||
@apply text-xs font-semibold text-ui-gray-300 whitespace-nowrap; | ||
} | ||
.vc-chrome-toggle-btn { | ||
@apply flex items-center !text-ui-gray-300 rounded-md border border-gray-300 justify-center transition duration-100 ease-in-out bg-ui-gray-700 hover:bg-ui-gray-900; | ||
} | ||
[color-scheme='dark'] .vc-chrome-toggle-btn { | ||
@apply border-ui-gray-900; | ||
} | ||
.vc-chrome-toggle-icon { | ||
@apply !m-0 inline-flex items-center gap-2 leading-none transition duration-100 ease-in-out focus:outline-none focus:ring-0; | ||
} | ||
.vc-chrome-toggle-icon svg path { | ||
fill: currentColor !important; | ||
} | ||
.vc-chrome-toggle-icon-highlight { | ||
@apply hidden; | ||
} | ||
</style> | ||
|
||
<script> | ||
import { Chrome } from 'vue-color'; | ||
import { computed } from '@nuxtjs/composition-api'; | ||
export default { | ||
props: { | ||
value: { | ||
type: Object, | ||
required: false, | ||
}, | ||
}, | ||
components: { Chrome }, | ||
setup(props) { | ||
const rgba = computed( | ||
() => | ||
props.value ?? { | ||
red: 0, | ||
green: 0, | ||
blue: 0, | ||
alpha: 1, | ||
} | ||
); | ||
const backgroundColor = computed(() => { | ||
return `rgb(${rgba.value.red}, ${rgba.value.green}, ${rgba.value.blue})`; | ||
}); | ||
return { rgba, backgroundColor }; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters