Skip to content

Commit

Permalink
fix(useElementBackground): correct alpha in hex color
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Sep 28, 2023
1 parent 307f0be commit 001a809
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/ui/src/composables/useElementBackground.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export const WithTransition = () => ({
}
},

setup () {
return {
color: useElementBackground(useCurrentElement()),
}
},

template: `
<div :style="{ ...styles, transition: 'all 0.5s ease-in-out' }">
<button @click="styles = { background: '#000', color: '#fff' }">Black</button>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/composables/useElementBackground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const toHex = (color: RGBAColorParsed): string => {
(color[0] | 1 << 8).toString(16).slice(1) +
(color[1] | 1 << 8).toString(16).slice(1) +
(color[2] | 1 << 8).toString(16).slice(1) +
(color[3] | 1 << 8).toString(16).slice(1)
(color[3] * 255 | 1 << 8).toString(16).slice(1)
}

const getParentsWithBackground = (el: HTMLElement): HTMLElement[] => {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import "global/index.scss";
// Mixins, functions and variables
@import "resources/index.scss";
@import "essential.scss";

0 comments on commit 001a809

Please sign in to comment.