xref: /openbmc/webui-vue/docs/guide/quickstart/page-anatomy.md (revision 492875622b39cb2cf04bbb9248b6ed0c52ced2df)
126c8fae0SDixsie Wolmers# Page Anatomy
2*49287562SDerick MontagueSingle-file components (SFC) consist of a `template`, `script` and `style`
3*49287562SDerick Montagueblock.
426c8fae0SDixsie Wolmers
526c8fae0SDixsie Wolmers## Template block
626c8fae0SDixsie WolmersWhen creating a new page, each template consists of at least 3 components:
726c8fae0SDixsie Wolmers- `<b-container>`
826c8fae0SDixsie Wolmers- `<page-title>`
926c8fae0SDixsie Wolmers- `<page-section>`
1026c8fae0SDixsie Wolmers
11*49287562SDerick MontagueLearn more about the [page title](/guide/components/page-title)and [page
12*49287562SDerick Montaguesection](/guide/components/page-section) components.
1326c8fae0SDixsie Wolmers
1426c8fae0SDixsie Wolmers```vue
1526c8fae0SDixsie Wolmers<template>
1626c8fae0SDixsie Wolmers  <b-container fluid="xl">
17e2707ef0SDixsie Wolmers    <page-title />
1826c8fae0SDixsie Wolmers    <page-section :section-title="$t('pageName.sectionTitle')">
1926c8fae0SDixsie Wolmers      // Page content goes here
2026c8fae0SDixsie Wolmers    </page-section>
2126c8fae0SDixsie Wolmers  </b-container>
2226c8fae0SDixsie Wolmers</template>
2326c8fae0SDixsie Wolmers```
2426c8fae0SDixsie Wolmers## Scripts block
25*49287562SDerick MontagueIn the scripts section, be sure to import the `PageTitle` and `PageSection`
26*49287562SDerick Montaguecomponents and declare them in the `components` property.
27e2707ef0SDixsie Wolmers
28*49287562SDerick MontagueImporting `BContainer` in the [scripts block](#scripts-block) is not required as
29*49287562SDerick Montagueit is already registered globally.
30e2707ef0SDixsie Wolmers
3126c8fae0SDixsie Wolmers```vue
3226c8fae0SDixsie Wolmers<script>
3326c8fae0SDixsie Wolmersimport PageTitle from '@/components/Global/PageTitle';
3426c8fae0SDixsie Wolmersimport PageSection from '@/components/Global/PageSection';
3526c8fae0SDixsie Wolmersexport default {
3626c8fae0SDixsie Wolmers  name: 'PageName',
3726c8fae0SDixsie Wolmers  components: { PageTitle, PageSection }
3826c8fae0SDixsie Wolmers};
3926c8fae0SDixsie Wolmers</script>
4026c8fae0SDixsie Wolmers```
4126c8fae0SDixsie Wolmers
4226c8fae0SDixsie Wolmers## Style block
43*49287562SDerick MontagueAdd the `scoped` attribute to the style block to keep the styles isolated to the
44*49287562SDerick MontagueSFC. While the `scoped` attribute is optional, it is preferred and global
45*49287562SDerick Montaguechanges should be done in global style sheets.
4626c8fae0SDixsie Wolmers```vue
4726c8fae0SDixsie Wolmers<style lang="scss" scoped> </style>
4826c8fae0SDixsie Wolmers```
4926c8fae0SDixsie Wolmers
5026c8fae0SDixsie Wolmers## Complete single-file component (SFC)
5126c8fae0SDixsie WolmersThe final SFC will look like this.
5226c8fae0SDixsie Wolmers```vue
5326c8fae0SDixsie Wolmers<template>
5426c8fae0SDixsie Wolmers  <b-container fluid="xl">
5526c8fae0SDixsie Wolmers    <page-title :description="$t('pageName.pageDescription')"/>
5626c8fae0SDixsie Wolmers    <page-section :section-title="$t('pageName.sectionTitle')">
5726c8fae0SDixsie Wolmers      // Page content goes here
5826c8fae0SDixsie Wolmers    </page-section>
5926c8fae0SDixsie Wolmers  </b-container>
6026c8fae0SDixsie Wolmers</template>
6126c8fae0SDixsie Wolmers<script>
6226c8fae0SDixsie Wolmersimport PageTitle from '@/components/Global/PageTitle';
6326c8fae0SDixsie Wolmersimport PageSection from '@/components/Global/PageSection';
6426c8fae0SDixsie Wolmersexport default {
6526c8fae0SDixsie Wolmers  name: 'PageName',
6626c8fae0SDixsie Wolmers  components: { PageTitle, PageSection }
6726c8fae0SDixsie Wolmers};
6826c8fae0SDixsie Wolmers</script>
6926c8fae0SDixsie Wolmers<style lang="scss" scoped>
7026c8fae0SDixsie Wolmers    .example-class {
7126c8fae0SDixsie Wolmers      /* Styles go here */
7226c8fae0SDixsie Wolmers    }
7326c8fae0SDixsie Wolmers </style>
7426c8fae0SDixsie Wolmers```