Skip to content

Commit

Permalink
Update landmarks + Skip to Main Content link (#1973)
Browse files Browse the repository at this point in the history
* Update landmarks. Add Skip to Main Content link.
  • Loading branch information
dimak1 authored Jul 15, 2024
1 parent 7ff5fd0 commit 93d4668
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.2.37",
"version": "3.2.38",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
39 changes: 27 additions & 12 deletions ppr-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
id="app"
class="app-container"
>
<SkipToMainContent mainContentId="main-content" />

<!-- Dialogs -->
<BaseDialog
id="errorDialogApp"
Expand All @@ -23,18 +25,25 @@
:showLoginMenu="false"
/>

<SbcSystemBanner
v-if="bannerText != null"
class="mt-n1 sbc-system-banner"
:show="bannerText != null"
type="warning"
icon="''"
:message="bannerText"
:dismissible="false"
/>

<nav v-if="haveData">
<Breadcrumb />
</nav>

<div class="app-body">
<main>
<SbcSystemBanner
v-if="bannerText != null"
class="mt-n1"
:show="bannerText != null"
type="warning"
icon="''"
:message="bannerText"
:dismissible="false"
/>
<Breadcrumb v-if="haveData" />
<main
id="main-content"
tabindex="-1"
>
<Tombstone
v-if="haveData"
:actionInProgress="actionInProgress"
Expand Down Expand Up @@ -74,7 +83,7 @@ import SbcHeader from 'sbc-common-components/src/components/SbcHeader.vue'
import SbcFooter from 'sbc-common-components/src/components/SbcFooter.vue'
import SbcSystemBanner from 'sbc-common-components/src/components/SbcSystemBanner.vue'
import * as Dialogs from '@/components/dialogs'
import { Breadcrumb } from '@/components/common'
import { Breadcrumb, SkipToMainContent } from '@/components/common'
import { Tombstone } from '@/components/tombstone'
import * as Views from '@/views'
import {
Expand Down Expand Up @@ -110,6 +119,7 @@ import { useAuth, useNavigation } from '@/composables'
export default defineComponent({
name: 'App',
components: {
SkipToMainContent,
SbcHeader,
SbcFooter,
Breadcrumb,
Expand Down Expand Up @@ -702,4 +712,9 @@ export default defineComponent({

<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
.sbc-system-banner {
min-height: 60px;
flex-grow: 0;
}
</style>
44 changes: 44 additions & 0 deletions ppr-ui/src/components/common/SkipToMainContent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<a
:href="`#${props.mainContentId}`"
class="skip-main-content-link py-6 fs-16"
@click="skipToContent"
>
Skip to Main Content
</a>
</template>

<script setup lang="ts">
const props = defineProps<{
mainContentId: string
}>()
// Focuses on main content id and prevents anchor link in url
const skipToContent = event => {
event.preventDefault()
const mainContent = document.getElementById(props.mainContentId)
if (mainContent) {
mainContent.focus()
}
}
</script>

<style lang="scss">
.skip-main-content-link {
position: absolute;
z-index: 100;
left: calc(50% - 100px);
transform: translateY(-100%);
width: 200px;
border: 2px solid #000;
border-radius: 4px;
color: black;
text-align: center;
text-decoration: none;
background: #fff;
}
.skip-main-content-link:focus {
transform: translateY(0%);
}
</style>
1 change: 1 addition & 0 deletions ppr-ui/src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ export { default as StaffPayment } from './StaffPayment.vue'
export { default as CollapsibleCard } from './CollapsibleCard.vue'
export { default as TabbedContainer } from './TabbedContainer.vue'
export { default as SimpleTable } from './SimpleTable.vue'
export { default as SkipToMainContent } from './SkipToMainContent.vue'
4 changes: 2 additions & 2 deletions ppr-ui/tests/unit/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import App from '@/App.vue'
import SbcHeader from 'sbc-common-components/src/components/SbcHeader.vue'
import SbcFooter from 'sbc-common-components/src/components/SbcFooter.vue'
import { Tombstone } from '@/components/tombstone'
import { Breadcrumb } from '@/components/common'
import { Breadcrumb, SkipToMainContent } from '@/components/common'
import {
mockedDisableAllUserSettingsResponse,
mockedFinancingStatementAll,
Expand Down Expand Up @@ -105,6 +105,7 @@ describe('App component basic rendering normal account', () => {

it('renders the sub-components properly', async () => {
expect(wrapper.findComponent(App).exists()).toBe(true)
expect(wrapper.findComponent(SkipToMainContent).exists()).toBe(true)
expect(wrapper.findComponent(SbcHeader).exists()).toBe(true)
expect(wrapper.findComponent(SbcFooter).exists()).toBe(true)
expect(wrapper.findComponent(Tombstone).exists()).toBe(false)
Expand All @@ -126,4 +127,3 @@ describe('App component basic rendering normal account', () => {
expect(store.getStateModel.userInfo.feeSettings.serviceFee).toBe(1)
})
})

0 comments on commit 93d4668

Please sign in to comment.