add diabledMessage to TabbedContent
This commit is contained in:
@@ -33,7 +33,7 @@ export const Button = ({
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div className="m-auto flex items-center gap-2 font-medium">
|
<div className="m-auto flex shrink-0 items-center gap-2 font-medium">
|
||||||
{iconBefore}
|
{iconBefore}
|
||||||
{children}
|
{children}
|
||||||
{iconAfter}
|
{iconAfter}
|
||||||
|
|||||||
@@ -13,20 +13,24 @@ export const NewDevice = () => {
|
|||||||
name: "BLE",
|
name: "BLE",
|
||||||
icon: <FiBluetooth className="h-4" />,
|
icon: <FiBluetooth className="h-4" />,
|
||||||
element: BLE,
|
element: BLE,
|
||||||
disabled: !navigator.bluetooth
|
disabled: !navigator.bluetooth,
|
||||||
|
disabledMessage:
|
||||||
|
"WebBluetooth is currently only supported by Chromium based browsers: https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "HTTP",
|
name: "HTTP",
|
||||||
icon: <FiWifi className="h-4" />,
|
icon: <FiWifi className="h-4" />,
|
||||||
element: HTTP,
|
element: HTTP,
|
||||||
disabled: false
|
disabled: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Serial",
|
name: "Serial",
|
||||||
icon: <FiTerminal className="h-4" />,
|
icon: <FiTerminal className="h-4" />,
|
||||||
element: Serial,
|
element: Serial,
|
||||||
disabled: !navigator.serial
|
disabled: !navigator.serial,
|
||||||
}
|
disabledMessage:
|
||||||
|
"WebSerial is currently only supported by Chromium based browsers: https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API#browser_compatibility",
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
|
|
||||||
import { Tab } from "@headlessui/react";
|
|
||||||
import { Mono } from "@app/components/Mono";
|
import { Mono } from "@app/components/Mono";
|
||||||
|
import { Tab } from "@headlessui/react";
|
||||||
|
|
||||||
export interface TabType {
|
export interface TabType {
|
||||||
name: string;
|
name: string;
|
||||||
icon?: JSX.Element;
|
icon?: JSX.Element;
|
||||||
element: () => JSX.Element;
|
element: () => JSX.Element;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
disabledMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TabbedContentProps {
|
export interface TabbedContentProps {
|
||||||
@@ -42,7 +43,7 @@ export const TabbedContent = ({
|
|||||||
)}
|
)}
|
||||||
</Tab>
|
</Tab>
|
||||||
))}
|
))}
|
||||||
<div className="ml-auto">
|
<div className="ml-auto flex gap-2">
|
||||||
{actions?.map((Action, index) => (
|
{actions?.map((Action, index) => (
|
||||||
<Action key={index} />
|
<Action key={index} />
|
||||||
))}
|
))}
|
||||||
@@ -51,10 +52,10 @@ export const TabbedContent = ({
|
|||||||
<Tab.Panels as={Fragment}>
|
<Tab.Panels as={Fragment}>
|
||||||
{tabs.map((entry, index) => (
|
{tabs.map((entry, index) => (
|
||||||
<Tab.Panel key={index} className="flex flex-grow">
|
<Tab.Panel key={index} className="flex flex-grow">
|
||||||
{!entry.disabled ? <entry.element /> : (
|
{!entry.disabled ? (
|
||||||
<Mono>
|
<entry.element />
|
||||||
This functionality is not supported in your browser.
|
) : (
|
||||||
</Mono>
|
<Mono>{entry.disabledMessage}</Mono>
|
||||||
)}
|
)}
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user