Files
sim/apps/sim/hooks/use-branded-button-class.ts
Waleed 6262503b89 feat(deployed-form): added deployed form input (#2679)
* feat(deployed-form): added deployed form input

* styling consolidation, finishing touches on form

* updated docs

* remove unused files with knip

* added more form fields

* consolidated more test utils

* remove unused/unneeded zustand stores, refactored stores for consistency

* improvement(files): uncolorized plan name

* feat(emcn): button-group

* feat(emcn): tag input, tooltip shortcut

* improvement(emcn): modal padding, api, chat, form

* fix: deleted migrations

* feat(form): added migrations

* fix(emcn): tag input

* fix: failing tests on build

* add suplementary hover and fix bg color in date picker

* fix: build errors

---------

Co-authored-by: Emir Karabeg <emirkarabeg@berkeley.edu>
2026-01-09 23:42:21 -08:00

45 lines
1.3 KiB
TypeScript

'use client'
import { useEffect, useState } from 'react'
const DEFAULT_BRAND_ACCENT = '#6f3dfa'
export type BrandedButtonClass = 'branded-button-gradient' | 'branded-button-custom'
/**
* Hook to determine the appropriate button class based on brand customization.
* Returns 'branded-button-gradient' for default Sim branding, 'branded-button-custom' for whitelabeled instances.
*/
export function useBrandedButtonClass(): BrandedButtonClass {
const [buttonClass, setButtonClass] = useState<BrandedButtonClass>('branded-button-gradient')
useEffect(() => {
const checkCustomBrand = () => {
const computedStyle = getComputedStyle(document.documentElement)
const brandAccent = computedStyle.getPropertyValue('--brand-accent-hex').trim()
if (brandAccent && brandAccent !== DEFAULT_BRAND_ACCENT) {
setButtonClass('branded-button-custom')
} else {
setButtonClass('branded-button-gradient')
}
}
checkCustomBrand()
window.addEventListener('resize', checkCustomBrand)
const observer = new MutationObserver(checkCustomBrand)
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['style', 'class'],
})
return () => {
window.removeEventListener('resize', checkCustomBrand)
observer.disconnect()
}
}, [])
return buttonClass
}