-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: show selected path if block scroll in view (#6079)
Co-authored-by: PatrickJS <github@patrickjs.com>
- Loading branch information
1 parent
e9012d1
commit 80ea7cf
Showing
9 changed files
with
261 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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
64 changes: 64 additions & 0 deletions
64
packages/docs/src/components/copy-code/copy-code-block.tsx
This file contains 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,64 @@ | ||
import { component$, useSignal, useStyles$ } from '@builder.io/qwik'; | ||
import { CopyCode as CopyCodeIcon } from '../svgs/copy-code-icon'; | ||
import styles from './copy-code.css?inline'; | ||
|
||
const Check = component$(({ height = 12, width = 12 }: { height?: number; width?: number }) => { | ||
useStyles$(styles); | ||
|
||
return ( | ||
<svg | ||
class="w-3.5 h-3.5 text-white " | ||
height={height} | ||
width={width} | ||
aria-hidden="true" | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 16 12" | ||
> | ||
<path | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M1 5.917 5.724 10.5 15 1.5" | ||
/> | ||
</svg> | ||
); | ||
}); | ||
export const CopyCode = component$(({ code }: { code: string }) => { | ||
const copied = useSignal(false); | ||
return ( | ||
<button | ||
preventdefault:click | ||
onClick$={async (e) => { | ||
copied.value = !copied.value; | ||
if (copied.value) { | ||
setTimeout(() => (copied.value = false), 1500); | ||
} | ||
if (navigator.clipboard) { | ||
await navigator.clipboard.writeText(code); | ||
} | ||
}} | ||
class="absolute text-white right-2 top-2 shadow-2xl bg-[#1e1e1e] z-10" | ||
> | ||
<span | ||
class={{ | ||
animate: true, | ||
visible: copied.value, | ||
hidden: !copied.value, | ||
}} | ||
> | ||
<Check /> | ||
</span> | ||
<span | ||
class={{ | ||
animate: true, | ||
visible: !copied.value, | ||
hidden: copied.value, | ||
}} | ||
> | ||
<CopyCodeIcon /> | ||
</span> | ||
</button> | ||
); | ||
}); |
This file contains 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,14 @@ | ||
.animate { | ||
opacity: 1; | ||
animation: check-in 1 1s; | ||
} | ||
|
||
@keyframes check-in { | ||
0% { | ||
opacity: 0; | ||
} | ||
|
||
100% { | ||
opacity: 1; | ||
} | ||
} |
This file contains 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,23 @@ | ||
interface CopyIconProps { | ||
width?: number; | ||
height?: number; | ||
} | ||
|
||
export const CopyCode = ({ height = 18, width = 18 }: CopyIconProps) => { | ||
return ( | ||
<svg | ||
width={width} | ||
height={height} | ||
viewBox="0 0 24 24" | ||
stroke-width="2" | ||
stroke="currentColor" | ||
fill="none" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
> | ||
{' '} | ||
<path stroke="none" d="M0 0h24v24H0z" /> <rect x="8" y="8" width="12" height="12" rx="2" /> | ||
<path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" /> | ||
</svg> | ||
); | ||
}; |
This file contains 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 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 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.