Enhance MessageContext for desktop compatibility

- Updated MessageContext to adjust message positioning in the Electrobun desktop application, ensuring messages clear the custom title bar.
- Introduced a conditional MESSAGE_TOP value based on the desktop environment, improving the user experience for desktop users.
This commit is contained in:
Tom Butcher 2026-08-09 14:52:06 +01:00
parent 3caa62d675
commit 3a8239c92d

View File

@ -1,11 +1,16 @@
import { createContext, useContext } from 'react'
import PropTypes from 'prop-types'
import { message } from 'antd'
import { isElectrobunDesktop } from '../../../electrobun-bridge'
const MessageContext = createContext()
// antd's default message top is 8px; push messages down an extra 40px in the
// desktop app so they clear the custom title bar / drag region.
const MESSAGE_TOP = isElectrobunDesktop() ? 48 : undefined
export const MessageProvider = ({ children }) => {
const [msgApi, contextHolder] = message.useMessage()
const [msgApi, contextHolder] = message.useMessage({ top: MESSAGE_TOP })
const showMessage = (type, content, options = {}) => {
return msgApi.open({