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:
parent
3caa62d675
commit
3a8239c92d
@ -1,11 +1,16 @@
|
|||||||
import { createContext, useContext } from 'react'
|
import { createContext, useContext } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { message } from 'antd'
|
import { message } from 'antd'
|
||||||
|
import { isElectrobunDesktop } from '../../../electrobun-bridge'
|
||||||
|
|
||||||
const MessageContext = createContext()
|
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 }) => {
|
export const MessageProvider = ({ children }) => {
|
||||||
const [msgApi, contextHolder] = message.useMessage()
|
const [msgApi, contextHolder] = message.useMessage({ top: MESSAGE_TOP })
|
||||||
|
|
||||||
const showMessage = (type, content, options = {}) => {
|
const showMessage = (type, content, options = {}) => {
|
||||||
return msgApi.open({
|
return msgApi.open({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user