Skip to content

Commit e320a78

Browse files
dixsierfrandse
authored andcommitted
Add page anatomy quick start to documentation
The page anatomy quick start is intended to give developers a quick reference for building out new pages. Signed-off-by: Dixsie Wolmers <[email protected]> Change-Id: Idfed9e62822283c971e228a8a8a186ae05e485ae
1 parent 6d911cd commit e320a78

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

docs/.vuepress/config.js

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ module.exports = {
5050
"/guide/components/button",
5151
"/guide/components/toast",
5252
]
53+
},
54+
{
55+
title: "Quick Start",
56+
children: [
57+
"/guide/quickstart/page-anatomy"
58+
]
5359
}
5460
],
5561
"/themes/": ["", "customize", "env"]

docs/guide/quickstart/page-anatomy.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Page Anatomy
2+
Single-file components (SFC) consist of a `template`, `script` and `style` block.
3+
4+
## Template block
5+
When creating a new page, each template consists of at least 3 components:
6+
- `<b-container>`
7+
- `<page-title>`
8+
- `<page-section>`
9+
10+
### Page container
11+
Use the `fluid="xl"` prop on the `<b-container>` component to render a container that is always 100% width on larger screen sizes. Importing `BContainer` in the [scripts block](#scripts-block) is not required as it is already registered globally.
12+
13+
[Learn more about BootstrapVue containers](https://bootstrap-vue.org/docs/components/layout#responsive-fluid-containers).
14+
15+
### Page title component
16+
By including the `<page-title>` component in the template, it will automatically render the page title that corresponds with the title property set in the route record's meta field.
17+
18+
Optional page descriptions can be included by using the description prop `:description` prop and passing in the i18n localized text string.
19+
20+
### Page section component
21+
The `<page-section>` component will render semantic HTML. By adding a `:section-title` prop to the `<page-section>` component, the localized text string will be rendered in an `h2` header element.
22+
```vue
23+
<template>
24+
<b-container fluid="xl">
25+
<page-title :description="$t('pageName.pageDescription')"/>
26+
<page-section :section-title="$t('pageName.sectionTitle')">
27+
// Page content goes here
28+
</page-section>
29+
</b-container>
30+
</template>
31+
```
32+
33+
## Scripts block
34+
In the scripts section, be sure to import the `PageTitle` and `PageSection` components and declare them in the `components` property.
35+
```vue
36+
<script>
37+
import PageTitle from '@/components/Global/PageTitle';
38+
import PageSection from '@/components/Global/PageSection';
39+
export default {
40+
name: 'PageName',
41+
components: { PageTitle, PageSection }
42+
};
43+
</script>
44+
```
45+
46+
## Style block
47+
Add the `scoped` attribute to the style block to keep the styles isolated to the SFC. While the `scoped` attribute is optional, it is preferred and global changes should be done in global style sheets.
48+
```vue
49+
<style lang="scss" scoped> </style>
50+
```
51+
52+
## Complete single-file component (SFC)
53+
The final SFC will look like this.
54+
```vue
55+
<template>
56+
<b-container fluid="xl">
57+
<page-title :description="$t('pageName.pageDescription')"/>
58+
<page-section :section-title="$t('pageName.sectionTitle')">
59+
// Page content goes here
60+
</page-section>
61+
</b-container>
62+
</template>
63+
<script>
64+
import PageTitle from '@/components/Global/PageTitle';
65+
import PageSection from '@/components/Global/PageSection';
66+
export default {
67+
name: 'PageName',
68+
components: { PageTitle, PageSection }
69+
};
70+
</script>
71+
<style lang="scss" scoped>
72+
.example-class {
73+
/* Styles go here */
74+
}
75+
</style>
76+
```

0 commit comments

Comments
 (0)