Skip to content

Commit

Permalink
Quickly scroll to the prompt information location (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: bluwy <[email protected]>
  • Loading branch information
btea and bluwy authored Sep 8, 2023
1 parent 59ca641 commit 075832b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 13 additions & 3 deletions site/src/components/Label.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<script>
import { messageTypeToColor } from '../utils/colors'
export let type
function handleClick() {
const el = document.querySelector(`.message-type-${type}`)
el?.scrollIntoView({ behavior: 'smooth' })
}
</script>
<span
class="border-2 px-2 py-1 rounded-lg text-black {messageTypeToColor(type)}"
<button
class="
inline text-base leading-tight border-none px-2 py-1 rounded-lg
{messageTypeToColor(type)}
"
on:click={handleClick}
>
<slot />
</span>
</button>
7 changes: 6 additions & 1 deletion site/src/components/PkgNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@
/>
<div class="-mx-4">
{#each shownMessages as msg}
<div class="{messageTypeToColor(msg.type)} border-4 px-4 py-2">
<div
class="
{messageTypeToColor(msg.type)}
message-type-{msg.type} border-4 px-4 py-2 scroll-mt-8
"
>
{@html formatMessage(msg, pkg)}
</div>
{/each}
Expand Down
4 changes: 4 additions & 0 deletions site/src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ body {
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

button {
cursor: pointer;
}

.docs h1 {
margin-bottom: 1rem;
position: relative;
Expand Down

0 comments on commit 075832b

Please sign in to comment.