mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 09:38:26 +00:00
fix copy to clipboard and tabs styles in Safari (#69)
This commit is contained in:
parent
33fcbb71de
commit
7f2b8cf3f7
3 changed files with 7 additions and 22 deletions
|
|
@ -36,8 +36,8 @@ export default class MyDocument extends Document {
|
|||
id="force-dark-mode"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
localStorage['chakra-ui-color-mode'] = 'dark';
|
||||
document.documentElement.classList.add('dark');
|
||||
localStorage['chakra-ui-color-mode'] = 'dark';
|
||||
document.documentElement.classList.add('dark');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Tabs.Trigger = forwardRef(
|
|||
<Trigger
|
||||
ref={forwardedRef as any}
|
||||
className={clsx(
|
||||
'!appearance-none', // unset button styles in Safari
|
||||
`
|
||||
radix-state-active:text-white
|
||||
font-bold
|
||||
|
|
|
|||
|
|
@ -6,33 +6,17 @@ export function useClipboard() {
|
|||
|
||||
return useCallback(
|
||||
async (text: string): Promise<void> => {
|
||||
const result = await navigator.permissions.query({
|
||||
name: 'clipboard-write' as any,
|
||||
});
|
||||
|
||||
if (result.state === 'denied') {
|
||||
if (!navigator?.clipboard) {
|
||||
notify('Access to clipboard rejected!', 'error');
|
||||
return;
|
||||
}
|
||||
// TODO: toast throws when used in Modal and modal's Portal is document.body
|
||||
const isV2 = window.location.pathname.startsWith('/v2');
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
if (!isV2) {
|
||||
notify('Copied to clipboard!', 'info');
|
||||
}
|
||||
} catch (e) {
|
||||
if (!isV2) {
|
||||
notify('Failed to copy!', 'error');
|
||||
}
|
||||
notify('Copied to clipboard!', 'info');
|
||||
} catch {
|
||||
notify('Failed to copy!', 'error');
|
||||
}
|
||||
},
|
||||
[notify]
|
||||
);
|
||||
}
|
||||
|
||||
// navigator.permissions.query({name: "clipboard-write"}).then(result => {
|
||||
// if (result.state == "granted" || result.state == "prompt") {
|
||||
// /* write to the clipboard now */
|
||||
// }
|
||||
// });
|
||||
|
|
|
|||
Loading…
Reference in a new issue