-
Notifications
You must be signed in to change notification settings - Fork 117
feat: add directions for publishing to no schema component #6602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a6b7b57
feat: add directions for publishing on empty schema
jdolle 2fe2883
Changeset
jdolle 969ad58
Fix type
jdolle 05a5f87
feat(app): organization access token management ui (#6556)
n1ru4l b49e5e4
feat: add directions for publishing on empty schema
jdolle 94e15e4
Fix type
jdolle d7675d4
Update packages/web/app/src/components/ui/input-copy.tsx
jdolle c2add1f
Separate check noschema from others; adjust ui per feedback
jdolle 57b4608
Revert changeset
jdolle 60c2aa7
Fix typecheck
jdolle eb353a7
implement new code component
jdolle 9fb922c
Prettier
jdolle d3b3d3d
More intuitive selection and clipboard support
jdolle d145440
Prettier
jdolle 80d12d5
Add targets to example commands
jdolle 75405b0
Merge branch 'main' into publish-directions
jdolle f3a1557
Retrigger checks
jdolle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'hive': patch | ||
--- | ||
|
||
Added directions for publishing on no schema component |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useRef, type ComponentProps, type FC } from 'react'; | ||
import cn from 'clsx'; | ||
import { useHover } from '@/lib/hooks/use-hover'; | ||
import { useTimed } from '@/lib/hooks/use-timed'; | ||
import { CheckIcon, CopyIcon } from './icon'; | ||
|
||
export const Code: FC<ComponentProps<'code'>> = ({ children, className, ...props }) => { | ||
const [copied, startCopyTimer] = useTimed(1500); | ||
const [ref, hovering] = useHover(); | ||
const codeRef = useRef<HTMLElement | null>(null); | ||
// in case this browser does not support this newer API... | ||
const navigatorClipboardSupport = typeof navigator.clipboard?.writeText === 'function'; | ||
return ( | ||
<span | ||
ref={ref} | ||
className="relative flex cursor-text items-center gap-2 break-all rounded-md border border-gray-600 bg-black p-4 pr-14 font-mono text-sm" | ||
// Make this element able to be focused by setting tabIndex. | ||
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex | ||
tabIndex={0} | ||
onFocus={() => { | ||
if (codeRef.current) { | ||
const selection = window.getSelection(); | ||
const range = document.createRange(); | ||
range.setStart(codeRef.current, 0); | ||
range.setEnd(codeRef.current, codeRef.current.childNodes.length); | ||
selection?.removeAllRanges(); | ||
selection?.addRange(range); | ||
} | ||
}} | ||
> | ||
<code | ||
ref={codeRef} | ||
className={cn('whitespace-pre-line', className)} | ||
// always show code blocks in ltr | ||
dir="ltr" | ||
{...props} | ||
> | ||
{children} | ||
</code> | ||
<button | ||
hidden={!navigatorClipboardSupport} | ||
data-hovering={hovering || copied} | ||
className="absolute right-3 top-2 cursor-pointer rounded-md border border-gray-600 p-2 opacity-0 hover:text-orange-600 data-[hovering=true]:opacity-100 data-[hovering=true]:transition-opacity" | ||
onClick={async ev => { | ||
const value = children?.valueOf().toString(); | ||
if (value) { | ||
ev.preventDefault(); | ||
await navigator.clipboard.writeText(value); | ||
startCopyTimer(); | ||
} | ||
}} | ||
title="Copy to clipboard" | ||
> | ||
{copied ? <CheckIcon size={16} /> : <CopyIcon size={16} />} | ||
</button> | ||
</span> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useCallback, useRef, useState } from 'react'; | ||
|
||
export function useHover() { | ||
const [hovering, setHovering] = useState(false); | ||
const previousNode = useRef<Node | null>(null); | ||
|
||
const handleMouseEnter = useCallback(() => { | ||
setHovering(true); | ||
}, []); | ||
|
||
const handleMouseLeave = useCallback(() => { | ||
setHovering(false); | ||
}, []); | ||
|
||
const customRef = useCallback( | ||
(node: HTMLElement) => { | ||
if (previousNode.current?.nodeType === Node.ELEMENT_NODE) { | ||
previousNode.current.removeEventListener('mouseenter', handleMouseEnter); | ||
previousNode.current.removeEventListener('mouseleave', handleMouseLeave); | ||
} | ||
|
||
if (node?.nodeType === Node.ELEMENT_NODE) { | ||
node.addEventListener('mouseenter', handleMouseEnter); | ||
node.addEventListener('mouseleave', handleMouseLeave); | ||
} | ||
|
||
previousNode.current = node; | ||
}, | ||
[handleMouseEnter, handleMouseLeave], | ||
); | ||
|
||
return [customRef, hovering] as const; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export function useTimed(wait: number = 1000) { | ||
const [timer, setTimer] = useState<NodeJS.Timeout | null>(null); | ||
useEffect(() => { | ||
return () => { | ||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
}; | ||
}, [timer]); | ||
|
||
const handler = () => { | ||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
setTimer( | ||
setTimeout(() => { | ||
setTimer(null); | ||
}, wait), | ||
); | ||
}; | ||
return [timer !== null, handler] as const; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.