Skip to content

Commit a3b75eb

Browse files
Calculate color and hoverBackgroundColor in the same way
1 parent 61c7f39 commit a3b75eb

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

src/widgets/buttons.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ const dragAndDrop = require('./dragAndDrop')
2222
const cancelIconURI = iconBase + 'noun_1180156.svg' // black X
2323
const checkIconURI = iconBase + 'noun_1180158.svg' // green checkmark; Continue
2424

25-
const PRIMARY_COLOR = '#7c4dff'
26-
const SECONDARY_COLOR = '#01C9EA'
27-
2825
export type StatusAreaContext = {
2926
statusArea?: HTMLElement
3027
div?: HTMLElement
@@ -488,15 +485,11 @@ export function deleteButtonWithCheck (
488485
}
489486

490487
function getButtonStyle (options: ButtonWidgetOptions = { buttonColor: 'Primary', needsBorder: false }) {
491-
// We need to accomadate for legacy code, which is why we have to allow buttonType and filled to be optional
492-
let color = PRIMARY_COLOR
493-
if (options.buttonColor === 'Secondary') {
494-
color = SECONDARY_COLOR
495-
}
488+
const color: string = (options.buttonColor === 'Primary') ? '#7c4dff' : '#01C9EA'
496489
let backgroundColor: string = color
497490
let fontColor: string = '#ffffff'
498491
let borderColor: string = color
499-
// hoverBackground i used the color picker tool to change the rgb and then find out the hex
492+
// hoverBackground in design.inrupt.com is rgb, using the equivalent hex here
500493
// lighten is used in design.inrupt.com, but this only works in sass and less
501494
let hoverBackgroundColor: string = (options.buttonColor === 'Primary') ? '#9f7dff' : '#37cde6'
502495
let hoverFontColor: string = fontColor
@@ -529,6 +522,7 @@ function getButtonStyle (options: ButtonWidgetOptions = { buttonColor: 'Primary'
529522
}
530523
}
531524
}
525+
532526
/* Make a button
533527
*
534528
* @param dom - the DOM document object
@@ -962,7 +956,7 @@ export function removeButton (dom: HTMLDocument, element: HTMLElement) {
962956
b.setAttribute('type', 'button')
963957
b.textContent = '✕' // MULTIPLICATION X
964958
b.addEventListener('click', function (_event) {
965-
;(element as any).parentNode.removeChild(element)
959+
;(element as any).parentNode.removeChild(element)
966960
}, true)
967961
return b
968962
}

0 commit comments

Comments
 (0)