Skip to content

Commit

Permalink
fix(layout): improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Jul 9, 2023
1 parent 386483b commit 06df80a
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function convertComponentPropToApiDocs<T extends string>(propName: T, propOption
name: propName,
global: false,
description: '',
type: types.join(' | '),
types: types.join(' | '),
required: !!propOptionsRecord[propName].required,
default: getDefaultValue(propOptionsRecord[propName], types),
} as any
Expand Down
50 changes: 50 additions & 0 deletions packages/docs/page-config/ui-elements/layout/examples/Absolute.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script setup lang="ts">
const showSidebar = ref(true)
</script>

<template>
<VaLayout
style="height: 300px"
:left="{ absolute: true}"
>
<template #top>
<VaNavbar color="primary" class="py-2">
<template #left>
<VaButton @click="showSidebar = !showSidebar" :icon="showSidebar ? 'menu_open' : 'menu'" />
</template>
<h4>LOGO</h4>
</VaNavbar>
</template>

<template #left>
<VaSidebar v-model="showSidebar">
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="home" />
<VaSidebarItemTitle>
Home
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="phone" />
<VaSidebarItemTitle>
About
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
</VaSidebar>
</template>

<template #content>
<main class="p-4">
<h3>Page content</h3>
<p>Page content must be wrapped in main tag. You must do it manually. Here you can place any blocks you need in your application.</p>

<p>For example, you can place here your router view, add sidebar with navigation in #left slot.</p>
<p>If you're using VaSidebar for page navigation don't forget to wrap it in nav tag.</p>
</main>
</template>
</VaLayout>
</template>
57 changes: 45 additions & 12 deletions packages/docs/page-config/ui-elements/layout/examples/AllSlots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
</script>

<template>
<VaLayout style="height: 500px">
<VaLayout style="height: 300px">
<template #top>
<VaNavbar color="primary">
<VaNavbar color="primary" class="py-2">
<template #left>
<VaButton @click="showLeftSidebar = !showLeftSidebar" :icon="showLeftSidebar ? 'menu_open' : 'menu'" />
</template>
Hello!
<h4>LOGO</h4>
<template #right>
<VaButton @click="showRightSidebar = !showRightSidebar" :icon="showRightSidebar ? 'menu_open' : 'menu'" />
</template>
Expand All @@ -21,41 +21,74 @@
<VaSidebar v-model="showLeftSidebar">
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="home" /> Home
<VaIcon name="home" />
<VaSidebarItemTitle>
Home
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="phone" /> About
<VaIcon name="phone" />
<VaSidebarItemTitle>
About
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="bolt" />
<VaSidebarItemTitle>
Features
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="arrow_upward" />
<VaSidebarItemTitle>
Scroll back
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
</VaSidebar>
</template>

<template #content>
<div class="p-4">
<h1>Content</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum.</p>
</div>
<main class="p-4">
<h3>Page content</h3>
<p>Page content must be wrapped in main tag. You must do it manually. Here you can place any blocks you need in your application.</p>

<p>For example, you can place here your router view, add sidebar with navigation in #left slot.</p>
<p>If you're using VaSidebar for page navigation don't forget to wrap it in nav tag.</p>
</main>
</template>

<template #right>
<VaSidebar v-model="showRightSidebar">
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="home" /> Home
<VaIcon name="favorite" />
<VaSidebarItemTitle>
Favorite components
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="phone" /> About
<VaIcon name="grade" />
<VaSidebarItemTitle>
Best practices
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
</VaSidebar>
</template>

<template #bottom>
Footer!
<footer class="p-4 bg-[var(--va-primary)] text-[var(--va-on-primary)] text-right">
Footer
</footer>
</template>
</VaLayout>
</template>
27 changes: 18 additions & 9 deletions packages/docs/page-config/ui-elements/layout/examples/Default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,45 @@
</script>

<template>
<VaLayout style="height: 500px">
<VaLayout style="height: 300px">
<template #top>
<VaNavbar color="primary">
<VaNavbar color="primary" class="py-2">
<template #left>
<VaButton @click="showSidebar = !showSidebar" :icon="showSidebar ? 'menu_open' : 'menu'" />
</template>
Hello!
<h4>LOGO</h4>
</VaNavbar>
</template>

<template #left>
<VaSidebar v-model="showSidebar">
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="home" /> Home
<VaIcon name="home" />
<VaSidebarItemTitle>
Home
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="phone" /> About
<VaIcon name="phone" />
<VaSidebarItemTitle>
About
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
</VaSidebar>
</template>

<template #content>
<div class="p-4">
<h1>Content</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum.</p>
</div>
<main class="p-4">
<h3>Page content</h3>
<p>Page content must be wrapped in main tag. You must do it manually. Here you can place any blocks you need in your application.</p>

<p>For example, you can place here your router view, add sidebar with navigation in #left slot.</p>
<p>If you're using VaSidebar for page navigation don't forget to wrap it in nav tag.</p>
</main>
</template>
</VaLayout>
</template>
35 changes: 22 additions & 13 deletions packages/docs/page-config/ui-elements/layout/examples/Order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

<template>
<VaLayout
:left-order="1"
:top-order="2"
style="height: 500px"
:left="{ order: 1 }"
:top="{ order: 2 }"
style="height: 300px"
>
<template #top>
<VaNavbar color="primary">
<VaNavbar color="primary" class="py-2">
<template #left>
<VaButton @click="showLeftSidebar = !showLeftSidebar" :icon="showLeftSidebar ? 'menu_open' : 'menu'" />
</template>
Hello!
<h4>LOGO</h4>
<template #right>
<VaButton @click="showRightSidebar = !showRightSidebar" :icon="showRightSidebar ? 'menu_open' : 'menu'" />
</template>
Expand All @@ -25,22 +25,31 @@
<VaSidebar v-model="showLeftSidebar">
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="home" /> Home
<VaIcon name="home" />
<VaSidebarItemTitle>
Home
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem>
<VaSidebarItemContent>
<VaIcon name="phone" /> About
<VaIcon name="phone" />
<VaSidebarItemTitle>
About
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
</VaSidebar>
</template>

<template #content>
<div class="p-4">
<h1>Content</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum.</p>
</div>
<main class="p-4">
<h3>Page content</h3>
<p>Page content must be wrapped in main tag. You must do it manually. Here you can place any blocks you need in your application.</p>

<p>For example, you can place here your router view, add sidebar with navigation in #left slot.</p>
<p>If you're using VaSidebar for page navigation don't forget to wrap it in nav tag.</p>
</main>
</template>

<template #right>
Expand All @@ -59,9 +68,9 @@
</template>

<template #bottom>
<VaNavbar color="primary">
<footer class="p-4 bg-[var(--va-primary)] text-[var(--va-on-primary)] text-right">
Footer
</VaNavbar>
</footer>
</template>
</VaLayout>
</template>
59 changes: 55 additions & 4 deletions packages/docs/page-config/ui-elements/layout/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@
export default definePageConfig({
blocks: [
block.title('Layout.title'),
block.title('Layout'),
block.paragraph('Component is used for building App layout. It is based on CSS Grid and provides a simple API for building complex layouts.'),

block.example('Default'),
block.example('AllSlots'),
block.example('Order'),
block.example('Default', {
title: 'Default usage',
description: 'Default usage of Layout component.',
}),
block.example('AllSlots', {
title: 'All slots',
description: 'Layout component has 4 slots: top, right, bottom, left, content (or default). You can use them to place your content.',
}),
block.example('Order', {
title: 'Rendering order',
description: 'You can use order area attribute to change order of slots. By default, order is 0. If order of one area is higher than another, it will be rendered on top of it.',
}),
block.example('Absolute', {
title: 'Absolute',
description: 'You can use absolute area attribute to make area absolute. It will be rendered on top of other areas and overflow them. Absolute respect order prop.',
}),

block.subtitle('Accessibility'),
block.paragraph(`
Layout component is not handling accessibility by default.
You should always wrap content in slot with \`<div role="region" aria-label="...">\` to make it accessible.
Make sure you have \`main\` role on your main content in \`content\` slot,
\`aside\` in \`left\`, \`right\` slots, \`header\` in \`top\` slot and \`footer\` in \`bottom\` slot.
More about landmarks you can read [here](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/)[[target=_blank]].
Notice that if you're using components like VaSidebar, VaHeader the correct role will be added automatically.
`),

block.api('VaLayout', {
props: {
top: 'AreaConfig for top slot',
right: 'AreaConfig for right slot',
bottom: 'AreaConfig for bottom slot',
left: 'AreaConfig for left slot',
}
},
{
props: {
top: {
types: `{ absolute?: boolean, order?: number }`
},
bottom: {
types: `{ absolute?: boolean, order?: number }`
},
left: {
types: `{ absolute?: boolean, order?: number }`
},
right: {
types: `{ absolute?: boolean, order?: number }`
}
}
})
]
})
8 changes: 7 additions & 1 deletion packages/ui/src/components/va-layout/VaLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
@import '../../styles/resources';
.va-layout {
display: grid;
grid-template-columns: v-bind(horizontalTemplate);
Expand All @@ -88,6 +90,11 @@ export default defineComponent({
overflow: hidden;
&__area {
overflow-y: auto;
overflow-x: hidden;
@include va-scroll();
&--top {
grid-area: top;
}
Expand All @@ -107,7 +114,6 @@ export default defineComponent({
&--content {
grid-area: content;
overflow: auto;
}
}
Expand Down

0 comments on commit 06df80a

Please sign in to comment.