-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tailwind-components): add form legend component (#4616)
add form legend component * scroll to chapter * temp code to highlight active chapter
- Loading branch information
1 parent
aef1535
commit 11ec853
Showing
8 changed files
with
237 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<nav class="pt-4 pb-8"> | ||
<h2 class="text-disabled p-4 ml-1">Jump to</h2> | ||
<ul class="list-none space-y-3"> | ||
<li | ||
v-for="section in sections" | ||
class="group felx flex items-center cursor-pointer" | ||
@click="handleGotoRequest(section)" | ||
> | ||
<div | ||
class="h-[24px] w-1 group-hover:bg-button-primary" | ||
:class="{ 'bg-button-primary': section.isActive }" | ||
/> | ||
<span | ||
class="pl-4 text-title capitalize" | ||
:class="{ 'font-bold': section.isActive }" | ||
>{{ section.label }}</span | ||
> | ||
<span v-if="(section.errorCount ?? 0) > 0" class="ml-2"> | ||
<div | ||
class="flex h-5 w-5 shrink-0 grow-0 items-center justify-center rounded-full bg-notification text-legend-error-count" | ||
> | ||
{{ section.errorCount }} | ||
</div> | ||
</span> | ||
</li> | ||
</ul> | ||
</nav> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { IFormLegendSection } from "../../../metadata-utils/src/types"; | ||
defineProps<{ | ||
sections: IFormLegendSection[]; | ||
}>(); | ||
const emit = defineEmits(["goToSection"]); | ||
function handleGotoRequest(section: IFormLegendSection) { | ||
document.getElementById(`${section.domId}-chapter-title`)?.scrollIntoView({ | ||
behavior: "smooth", | ||
block: "start", | ||
}); | ||
emit("goToSection", section); | ||
} | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<div class="flex flex-row"> | ||
<div class="basis-1/2 bg-sidebar-gradient"> | ||
<FormLegend :sections="sections" @go-to-section="handleGoToRequest" /> | ||
</div> | ||
<div class="basis-1/2 text-title p-4"> | ||
<h3>Active section: {{ sections.find((s) => s.isActive) }}</h3> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { IFormLegendSection } from "../../metadata-utils/src/types"; | ||
function handleGoToRequest(section: IFormLegendSection) { | ||
sections.value.forEach((s) => { | ||
if (s.domId === section.domId) { | ||
s.isActive = true; | ||
} else { | ||
s.isActive = false; | ||
} | ||
}); | ||
} | ||
const sections = ref<IFormLegendSection[]>([ | ||
{ | ||
label: "Overview", | ||
domId: "overview", | ||
isActive: true, | ||
errorCount: 1, | ||
}, | ||
{ | ||
label: "Population", | ||
domId: "population", | ||
errorCount: 2, | ||
}, | ||
{ | ||
label: "Contents", | ||
domId: "contents", | ||
}, | ||
{ | ||
label: "Access", | ||
domId: "access", | ||
}, | ||
{ | ||
label: "Information", | ||
domId: "information", | ||
}, | ||
]); | ||
</script> |
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