Skip to content

Commit e15f159

Browse files
committed
Dynamic darker hover color for button widget
1 parent c870bea commit e15f159

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"react-toastify": "^7.0.3",
4848
"react-tooltip": "^4.2.18",
4949
"rxjs": "^6.3.3",
50+
"tinycolor2": "^1.4.2",
5051
"yup": "^0.27.0"
5152
},
5253
"devDependencies": {

frontend/src/Editor/Components/Button.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState, useEffect } from 'react';
22
import { resolveReferences } from '@/_helpers/utils';
3+
var tinycolor = require("tinycolor2");
34

45
export const Button = function Button({
56
id, width, height, component, onComponentClick, currentState
@@ -24,12 +25,13 @@ export const Button = function Button({
2425
backgroundColor,
2526
color,
2627
width,
27-
height
28+
height,
29+
'--tblr-btn-color-darker': tinycolor(backgroundColor).darken(8).toString()
2830
};
2931

3032
return (
3133
<button
32-
className={`btn btn-primary p-1 ${loadingState === true ? ' btn-loading' : ''}`}
34+
className={`jet-button btn btn-primary p-1 ${loadingState === true ? ' btn-loading' : ''}`}
3335
style={computedStyles}
3436
onClick={() => onComponentClick(id, component)}
3537
>

frontend/src/_styles/theme.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,4 +1546,10 @@ input:focus-visible {
15461546

15471547
.column-sort-row {
15481548
border-radius: 0;
1549-
}
1549+
}
1550+
1551+
.jet-button {
1552+
&.btn-primary:hover {
1553+
background: var(--tblr-btn-color-darker) !important;
1554+
}
1555+
}

0 commit comments

Comments
 (0)