Skip to content

Style updates #116

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 9 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ defineProps<{
variant="accordian_trigger"
:aria-label="item.label"
>
<span class="truncate">{{ item.label }}</span>

<span class="flex-1 text-left">{{ item.label }}</span>
<template #trailing>
<UIcon
name="i-mdi-menu-up"
class="ms-auto size-7 transition-transform duration-200"
class="ms-auto size-7 shrink-0 transition-transform duration-200"
:class="[!open && 'rotate-180']"
/>
</template>
Expand All @@ -35,6 +34,7 @@ defineProps<{
class="mx-2"
:links="item.children"
:ui="{
label: 'text-ellipsis relative',
wrapper: 'border-s border-gray-500 dark:border-[#94A3B8] space-y-2',
base: 'group block border-s -ms-px leading-6 before:hidden focus-visible:rounded',
padding: 'p-0 ps-4',
Expand Down
25 changes: 25 additions & 0 deletions web/site/app/components/Sbc/Docs/NextPrevButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script setup lang="ts">
import type { ParsedContent } from '@nuxt/content'
defineProps<{
page: Pick<ParsedContent, '_path' | 'title'> | undefined
direction: 'next' | 'prev'
}>()

const localePath = useLocalePath()
</script>
<template>
<UButton
:aria-label="`${handleContentDirectoryLabel(page?._path?.split('/')[2] ?? '')}, ${page?.title}`"
:to="localePath(page?._path || '/')"
variant="outline"
color="gray"
class="w-full sm:w-auto"
>
<UIcon v-if="direction === 'prev'" name="i-mdi-arrow-left-circle" class="size-8" />
<div :class="[ direction === 'next' ? 'ml-auto' : '', 'flex flex-col']">
<span class="text-lg font-medium text-bcGovColor-darkGray dark:text-white">{{ handleContentDirectoryLabel(page?._path?.split('/')[2] ?? '') }}</span>
<span class="text-base text-bcGovColor-midGray dark:text-gray-300">{{ page?.title }}</span>
</div>
<UIcon v-if="direction === 'next'" name="i-mdi-arrow-right-circle" class="size-8" />
</UButton>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defineProps<{
}>()
</script>
<template>
<aside class="min-w-fit max-w-min px-2 py-4">
<SbcAccordianNavigation :nav-items="navItems" />
<aside class="mx-2 min-w-48 max-w-min py-4">
<SbcDocsAccordianNavigation :nav-items="navItems" />
</aside>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { TocLink } from '@nuxt/content/dist/runtime/types'
import type { TocLink } from '@nuxt/content'
defineProps<{
tocLinks: TocLink[] | [],
currentDir?: string,
Expand Down
4 changes: 2 additions & 2 deletions web/site/app/components/Sbc/MobileNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const {
</template>
<!-- item slot is the content inside each accordian, pass toc component into item slot of accordian -->
<template #item>
<SbcTableOfContents
<SbcDocsTableOfContents
class="-mt-2 ml-4"
:hide-label="true"
:toc-links="tocLinks"
Expand All @@ -139,7 +139,7 @@ const {
</template>
</UAccordion>
<UDivider class="my-4" />
<SbcAccordianNavigation :nav-items="accordianNavItems" />
<SbcDocsAccordianNavigation :nav-items="accordianNavItems" />
</UCard>
</UModal>
</template>
10 changes: 6 additions & 4 deletions web/site/app/components/content/ProseTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div class="w-full overflow-x-auto">
<table class="w-full min-w-[50rem] border-collapse overflow-x-hidden">
<slot />
</table>
<div class="w-full overflow-hidden rounded-lg border border-bcGovGray-100 dark:border-gray-300/50">
<div class="overflow-x-auto">
<table class="my-0 w-full min-w-[50rem]">
<slot />
</table>
</div>
</div>
</template>
5 changes: 5 additions & 0 deletions web/site/app/components/content/ProseTbody.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<tbody class="divide-y divide-bcGovGray-100 dark:divide-gray-300/50">
<slot />
</tbody>
</template>
2 changes: 1 addition & 1 deletion web/site/app/components/content/ProseTd.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<td class="border border-bcGovGray-100 p-4 align-middle dark:border-gray-300/50">
<td class="p-4">
<slot />
</td>
</template>
2 changes: 1 addition & 1 deletion web/site/app/components/content/ProseTh.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<th
class="whitespace-nowrap border border-bcGovGray-100 bg-bcGovBlue-600 p-4 text-lg font-semibold text-white dark:border-gray-300/50 dark:bg-bcGovGray-900"
class="whitespace-nowrap bg-bcGovBlue-600 p-4 text-left font-semibold text-white dark:border-b dark:border-gray-300/50 dark:bg-bcGovGray-900"
>
<slot />
</th>
Expand Down
6 changes: 3 additions & 3 deletions web/site/app/components/content/rs/BcrosSearchExample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const tabs = [

function onChange (index: number) {
const item = tabs[index]
shownTab.value = item.key
shownTab.value = item?.key
}

const shownTab = ref(tabs[0].key)
const shownTab = ref(tabs[0]?.key)

function handleSelect (event: CustomEvent) {
selected.value = event.detail
Expand Down Expand Up @@ -87,7 +87,7 @@ function handleSelect (event: CustomEvent) {
</div>
<template v-if="showCodepen" #footer>
<div class="flex">
<ButtonCodepen class="ml-auto" :link />
<SbcDocsButtonCodepen class="ml-auto" :link />
</div>
</template>
</UCard>
Expand Down
2 changes: 1 addition & 1 deletion web/site/app/composables/docPageData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ParsedContent, TocLink } from '@nuxt/content/dist/runtime/types'
import type { ParsedContent, TocLink } from '@nuxt/content'

// get current docs page content for page head and table of contents
export function useDocPageData () {
Expand Down
8 changes: 4 additions & 4 deletions web/site/app/composables/surroundPages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NavItem, ParsedContent } from '@nuxt/content/dist/runtime/types'
import type { NavItem, ParsedContent } from '@nuxt/content'

// get data for next/previous page buttons
export function useSurroundPages () {
Expand All @@ -7,7 +7,7 @@ export function useSurroundPages () {
const route = useRoute()

// get the very last item.child.child index, returns -1 if navitems are undefined
const lastNavItemIndex = (navItems?.value[0].children?.length ?? 0) - 1
const lastNavItemIndex = (navItems?.value[0]?.children?.length ?? 0) - 1
const lastNavChildIndex = (navItems?.value[0]?.children?.[lastNavItemIndex]?.children?.length ?? 0) - 1

// refs for watch/query, queryContent requires route without locale
Expand All @@ -29,9 +29,9 @@ export function useSurroundPages () {

// assign query to refs
// if query === null, (reached start of files), return last item in content files to 'wrap' the button navigation, fallback to not found
prevPage.value = prev ?? navItems?.value[0].children?.[lastNavItemIndex]?.children?.[lastNavChildIndex] ?? { title: 'Not Found', _path: 'Not Found' }
prevPage.value = prev ?? navItems?.value[0]?.children?.[lastNavItemIndex]?.children?.[lastNavChildIndex] ?? { title: 'Not Found', _path: 'Not Found' }
// if query === null, (reached end of files), return first item in content files to 'wrap' the button navigation, fallback to not found
nextPage.value = next ?? navItems?.value[0].children?.[0]?.children?.[0] ?? { title: 'Not Found', _path: 'Not Found' }
nextPage.value = next ?? navItems?.value[0]?.children?.[0]?.children?.[0] ?? { title: 'Not Found', _path: 'Not Found' }
}
}

Expand Down
87 changes: 34 additions & 53 deletions web/site/app/layouts/docs.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script setup lang="ts">
import type { NavItem } from '@nuxt/content/dist/runtime/types'
import type { NavItem } from '@nuxt/content'
const navItems = inject<Ref<NavItem[]>>('docNavItems')
const mainHeaderHeight = inject<Ref<number>>('mainHeaderHeight')
const footerHeight = inject<Ref<number>>('footerHeight')
const localePath = useLocalePath()
const { prevPage, nextPage } = useSurroundPages()
const { currentDir, tocLinks, createPageHead } = useDocPageData()
const contentWrapper = shallowRef<HTMLDivElement | null>(null)
Expand All @@ -12,67 +11,49 @@ const { activeTocId } = useHeadingObserver(contentWrapper.value)
useHead({
title: () => createPageHead()
})
</script>

// styles for nav + toc sticky, for some reason header + footer height are consistently 18px short
const stickyStyles = computed(() => ({
top: `${mainHeaderHeight!.value + 18}px`,
maxHeight: `calc(100vh - (${mainHeaderHeight!.value + footerHeight!.value + 36}px))`,
minHeight: `calc(100vh - ${mainHeaderHeight!.value + 18}px)`
}))
</script>
<template>
<main class="relative mx-auto flex w-full max-w-[1360px] grow flex-col lg:grid lg:grid-cols-12">
<main class="relative mx-auto flex w-full max-w-[1360px] grow gap-4 px-2 xl:gap-8 xl:px-0">
<!-- side navigation -->
<div
class="fixed col-start-1 col-end-4 hidden overflow-y-auto py-5 lg:block"
:style="{
top: `${mainHeaderHeight}px`,
maxHeight: `calc(100% - (${mainHeaderHeight}px + ${footerHeight}px))`,
minHeight: `calc(100% - ${mainHeaderHeight}px)`
}"
class="sticky hidden overflow-y-auto overflow-x-hidden py-4 lg:block"
:style="stickyStyles"
>
<SbcSideNavigation
class=""
:nav-items="createContentNav(navItems)"
/>
</div>
<div ref="contentWrapper" class="w-full lg:col-start-4 lg:col-end-11 xl:-ml-8">
<slot />
<SbcDocsSideNavigation :nav-items="createContentNav(navItems)" />
</div>
<UDivider class="px-2 lg:col-start-4 lg:col-end-11 xl:-ml-8" />
<div class="flex w-full flex-col items-center justify-between gap-4 px-2 py-8 sm:flex-row lg:col-start-4 lg:col-end-11 xl:-ml-8">
<UButton
:aria-label="`${handleContentDirectoryLabel(prevPage?._path?.split('/')[2] ?? '')}, ${prevPage?.title}`"
:to="localePath(prevPage?._path || '/')"
variant="outline"
color="gray"
class="w-full sm:w-auto"
>
<UIcon name="i-mdi-arrow-left-circle" class="size-8" />
<div class="flex flex-col">
<span class="text-lg font-medium text-bcGovColor-darkGray dark:text-white">{{ handleContentDirectoryLabel(prevPage?._path?.split('/')[2] ?? '') }}</span>
<span class="text-base text-bcGovColor-midGray dark:text-gray-300">{{ prevPage?.title }}</span>
</div>
</UButton>
<UButton
:aria-label="`${handleContentDirectoryLabel(nextPage?._path?.split('/')[2] ?? '')}, ${nextPage?.title}`"
:to="localePath(nextPage?._path || '/')"
variant="outline"
color="gray"
class="w-full sm:w-auto"
>
<div class="ml-auto flex flex-col">
<span class="text-lg font-medium text-bcGovColor-darkGray dark:text-white">{{ handleContentDirectoryLabel(nextPage?._path?.split('/')[2] ?? '') }}</span>
<span class="text-base text-bcGovColor-midGray dark:text-gray-300">{{ nextPage?.title }}</span>
</div>
<UIcon name="i-mdi-arrow-right-circle" class="size-8" />
</UButton>
<!-- main content -->
<div class="flex grow flex-col gap-8 py-8">
<div ref="contentWrapper">
<slot />
</div>
<UDivider />
<div class="flex w-full flex-col items-center justify-between gap-4 sm:flex-row">
<SbcDocsNextPrevButton
:page="prevPage"
direction="prev"
/>
<SbcDocsNextPrevButton
:page="nextPage"
direction="next"
/>
</div>
</div>
<!-- table of contents -->
<div
class="fixed col-span-full col-start-11 row-start-1 hidden overflow-y-auto py-5 lg:block"
:style="{
top: `${mainHeaderHeight}px`,
maxHeight: `calc(100% - (${mainHeaderHeight}px + ${footerHeight}px))`,
minHeight: `calc(100% - ${mainHeaderHeight}px)`
}"
class="sticky hidden overflow-y-auto py-8 lg:block"
:style="stickyStyles"
>
<SbcTableOfContents
<SbcDocsTableOfContents
v-show="tocLinks.length"
:hide-label="false"
class="sticky top-0 mt-6"
class="max-w-48"
:toc-links="tocLinks"
:current-dir="currentDir"
:active-toc-id="activeTocId"
Expand Down
16 changes: 8 additions & 8 deletions web/site/app/middleware/requireAuth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default defineNuxtRouteMiddleware(async (to) => {
const user = await getCurrentUser()
export default defineNuxtRouteMiddleware(async () => {
// const user = await getCurrentUser()
// const { $i18n } = useNuxtApp()
const localePath = useLocalePath()
if (!user) {
// might need to manually build localePath
// return navigateTo({ path: `/${$i18n.locale.value}/sbc/auth/login`, query: { redirect: to.fullPath } })
return navigateTo({ path: localePath('/sbc/auth/login'), query: { redirect: to.fullPath } })
}
// const localePath = useLocalePath()
// if (!user) {
// // might need to manually build localePath
// // return navigateTo({ path: `/${$i18n.locale.value}/sbc/auth/login`, query: { redirect: to.fullPath } })
// return navigateTo({ path: localePath('/sbc/auth/login'), query: { redirect: to.fullPath } })
// }
})
2 changes: 1 addition & 1 deletion web/site/app/pages/products/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ definePageMeta({
</script>
<template>
<ContentDoc
class="prose prose-bcGov dark:prose-invert min-w-full px-2 py-6"
class="prose prose-bcGov dark:prose-invert min-w-full max-w-[94vw] sm:max-w-0"
:query="{
path: $route.path.replace(/^\/[a-zA-Z]{2}-[a-zA-Z]{2}\//, '/'),
where: { _locale: $i18n.locale }
Expand Down
2 changes: 1 addition & 1 deletion web/site/app/pages/products/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { data: products } = await useAsyncData(
{{ $t('page.products.h1') }}
</h1>
<ul class="mx-auto flex flex-wrap justify-center gap-8">
<SbcProductCard
<SbcDocsProductCard
v-for="product in products"
:key="product._dir"
:name="product.name"
Expand Down
4 changes: 2 additions & 2 deletions web/site/app/tests/mocks/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createI18n } from 'vue-i18n'
import en from '~/app/locales/en-CA'
import fr from '~/app/locales/fr-CA'
import en from '~/locales/en-CA'
import fr from '~/locales/fr-CA'

export const enI18n = createI18n({
legacy: false,
Expand Down
18 changes: 9 additions & 9 deletions web/site/app/tests/unit/components/SbcHeaderMain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { renderSuspended, mockNuxtImport } from '@nuxt/test-utils/runtime'
import { screen } from '@testing-library/vue'
import { SbcHeaderMain } from '#components'
import { enI18n } from '~/tests/mocks/i18n'
import en from '~/app/locales/en-CA'
import en from '~/locales/en-CA'

// Function to access nested properties by dot-separated key
const getTranslationByKey = (key: string): any => {
Expand Down Expand Up @@ -41,13 +41,13 @@ mockNuxtImport('useI18n', () => {
)
})

mockNuxtImport('useCurrentUser', () => {
return () => (
{
displayName: 'Test User'
}
)
})
// mockNuxtImport('useCurrentUser', () => {
// return () => (
// {
// displayName: 'Test User'
// }
// )
// })

describe('<SbcHeaderMain/>', () => {
it('mounts', async () => {
Expand All @@ -73,7 +73,7 @@ describe('<SbcHeaderMain/>', () => {
}
})

const linkTexts = ['Service BC Connect', 'Products', 'Dashboard', 'Docs']
const linkTexts = ['Service BC Connect', 'Products', 'Docs'] // 'Dashboard',

linkTexts.forEach((link: string) => {
expect(screen.getByText(link)).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
import { useRouteWithoutLocale } from '~/app/composables/routeWithoutLocale'
import { useRouteWithoutLocale } from '~/composables/routeWithoutLocale'

mockNuxtImport('useRoute', () => {
return () => (
Expand Down
2 changes: 1 addition & 1 deletion web/site/app/tests/unit/utils/createContentNav.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
import { createContentNav } from '~/app/utils/createContentNav'
import { createContentNav } from '~/utils/createContentNav'

function mockUseLocalePath (path: string) {
return '/en-CA' + path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
import { handleContentDirectoryLabel } from '~/app/utils/handleContentDirectoryLabel'
import { handleContentDirectoryLabel } from '~/utils/handleContentDirectoryLabel'

function mockGetStartedString (key: string) {
if (key === 'btn.getStarted') {
Expand Down
Loading
Loading