Skip to content

Commit

Permalink
feat: add rgba util
Browse files Browse the repository at this point in the history
  • Loading branch information
aube-dev committed Aug 16, 2024
1 parent 429822d commit 552f5b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/common/Button/Button.css.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { style, styleVariants } from '@vanilla-extract/css';
import { Breakpoint } from '@/constants/style';
import { themeVars } from '@/styles/theme.css';
import { getMediaQuery } from '@/utils/style';
import { getMediaQuery, rgba } from '@/utils/style';

export const buttonBase = style({
cursor: 'pointer',
Expand Down Expand Up @@ -33,10 +33,10 @@ export const buttonStyleByVariant = styleVariants({
borderColor: themeVars.color.primary.normal.hex,
backgroundColor: 'transparent',
':hover': {
backgroundColor: `rgba(${themeVars.color.primary.normal.rgb}, 0.1)`,
backgroundColor: rgba(themeVars.color.primary.normal.rgb, 0.1),
},
':active': {
backgroundColor: `rgba(${themeVars.color.primary.normal.rgb}, 0.2)`,
backgroundColor: rgba(themeVars.color.primary.normal.rgb, 0.2),
},
':disabled': {
backgroundColor: 'transparent',
Expand Down
3 changes: 3 additions & 0 deletions app/utils/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ export const getRGBFromHex = (hex: string) => {
}
return [aRgbHex[0], aRgbHex[1], aRgbHex[2]].map((item) => parseInt(item, 16));
};

export const rgba = (cssVar: string, alpha: number) =>
`rgba(${cssVar}, ${alpha})`;

0 comments on commit 552f5b4

Please sign in to comment.