diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2022-12-08 15:13:13 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2022-12-08 15:13:13 +0300 |
commit | 7385e139b0c9efca7430458cee982e63e282f4ae (patch) | |
tree | 1bbdb0164e556b76eec72cb558c66974c8f95dd8 /docs/guide/quickstart | |
parent | b24a483eda5ca0b0ecdb4f0c61b90d76d0d8e1e0 (diff) | |
download | webui-vue-7385e139b0c9efca7430458cee982e63e282f4ae.tar.xz |
prettier: re-format
Prettier is enabled in openbmc-build-scripts on Markdown, JSON, and YAML
files to have consistent formatting for these file types. Re-run the
formatter on the whole repository.
Change-Id: I2804ee3ab5ff6bcbf986b028db2fafec8e616779
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'docs/guide/quickstart')
-rw-r--r-- | docs/guide/quickstart/forms.md | 47 | ||||
-rw-r--r-- | docs/guide/quickstart/page-anatomy.md | 43 | ||||
-rw-r--r-- | docs/guide/quickstart/store-anatomy.md | 46 |
3 files changed, 72 insertions, 64 deletions
diff --git a/docs/guide/quickstart/forms.md b/docs/guide/quickstart/forms.md index 5356eac0..b30c946d 100644 --- a/docs/guide/quickstart/forms.md +++ b/docs/guide/quickstart/forms.md @@ -1,23 +1,24 @@ # Forms -Forms are created using the [bootstrap-vue form -component](https://bootstrap-vue.org/docs/components/form) +Forms are created using the +[bootstrap-vue form component](https://bootstrap-vue.org/docs/components/form) and validated with the [Vuelidate](https://vuelidate.js.org/#sub-installation) plugin. ## Form component -When creating a new form, use the `<b-form>` [form -component](https://bootstrap-vue.org/docs/components/form). Use the `.prevent` -event modifier on submit to prevent the submit event from reloading the page. +When creating a new form, use the `<b-form>` +[form component](https://bootstrap-vue.org/docs/components/form). Use the +`.prevent` event modifier on submit to prevent the submit event from reloading +the page. ## Form group component -The `<b-form-group>` [form group -component](https://bootstrap-vue.org/docs/components/form-group) -pairs form controls with a legend or label, helper text, invalid/valid -feedback text, and visual validation state feedback. Learn more about -commonly used form components: +The `<b-form-group>` +[form group component](https://bootstrap-vue.org/docs/components/form-group) +pairs form controls with a legend or label, helper text, invalid/valid feedback +text, and visual validation state feedback. Learn more about commonly used form +components: - [Form checkbox](https://bootstrap-vue.org/docs/components/form-checkbox) - [Form input](https://bootstrap-vue.org/docs/components/form-input) @@ -25,21 +26,19 @@ commonly used form components: - [Form select](https://bootstrap-vue.org/docs/components/form-select) - [Form file custom component](/guide/components/file-upload) -When helper text is provided, use the `<b-form-text>` component and `aria-describedby` on the -form group component the helper text describes. +When helper text is provided, use the `<b-form-text>` component and +`aria-describedby` on the form group component the helper text describes. ## Validation -For custom form validation messages, disable browser native HTML5 -validation by setting the `novalidate` prop on `<b-form>`. Use Vuelidate to -check the form validation state and add -custom validation messages in the `<b-form-invalid-feedback>` component. +For custom form validation messages, disable browser native HTML5 validation by +setting the `novalidate` prop on `<b-form>`. Use Vuelidate to check the form +validation state and add custom validation messages in the +`<b-form-invalid-feedback>` component. -When creating a new form add the `VuelidateMixin` -to the `scripts` block and import any -[validators](https://vuelidate.js.org/#validators) needed -such as: `required`, `requiredIf`, etc. The use of built-in validators is -preferred. +When creating a new form add the `VuelidateMixin` to the `scripts` block and +import any [validators](https://vuelidate.js.org/#validators) needed such as: +`required`, `requiredIf`, etc. The use of built-in validators is preferred. ## Complete form @@ -53,7 +52,7 @@ A complete form will look like this. label-for="form-input-id" > <b-form-text id="form-input-helper-text"> - {{ $t('pageName.form.helperText') }} + {{ $t("pageName.form.helperText") }} </b-form-text> <b-form-input id="form-input-id" @@ -65,12 +64,12 @@ A complete form will look like this. /> <b-form-invalid-feedback role="alert"> <div v-if="!$v.form.input.required"> - {{ $t('global.form.fieldRequired') }} + {{ $t("global.form.fieldRequired") }} </div> </b-form-invalid-feedback> </b-form-group> <b-button variant="primary" type="submit" class="mb-3"> - {{ $t('global.action.save') }} + {{ $t("global.action.save") }} </b-button> </b-form> </template> diff --git a/docs/guide/quickstart/page-anatomy.md b/docs/guide/quickstart/page-anatomy.md index fd49a8f5..0a347e50 100644 --- a/docs/guide/quickstart/page-anatomy.md +++ b/docs/guide/quickstart/page-anatomy.md @@ -1,15 +1,18 @@ # Page Anatomy + Single-file components (SFC) consist of a `template`, `script` and `style` block. ## Template block + When creating a new page, each template consists of at least 3 components: + - `<b-container>` - `<page-title>` - `<page-section>` -Learn more about the [page title](/guide/components/page-title)and [page -section](/guide/components/page-section) components. +Learn more about the [page title](/guide/components/page-title)and +[page section](/guide/components/page-section) components. ```vue <template> @@ -21,7 +24,9 @@ section](/guide/components/page-section) components. </b-container> </template> ``` + ## Scripts block + In the scripts section, be sure to import the `PageTitle` and `PageSection` components and declare them in the `components` property. @@ -30,45 +35,49 @@ it is already registered globally. ```vue <script> -import PageTitle from '@/components/Global/PageTitle'; -import PageSection from '@/components/Global/PageSection'; +import PageTitle from "@/components/Global/PageTitle"; +import PageSection from "@/components/Global/PageSection"; export default { - name: 'PageName', - components: { PageTitle, PageSection } + name: "PageName", + components: { PageTitle, PageSection }, }; </script> ``` ## Style block + 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. + ```vue -<style lang="scss" scoped> </style> +<style lang="scss" scoped></style> ``` ## Complete single-file component (SFC) + The final SFC will look like this. + ```vue <template> <b-container fluid="xl"> - <page-title :description="$t('pageName.pageDescription')"/> + <page-title :description="$t('pageName.pageDescription')" /> <page-section :section-title="$t('pageName.sectionTitle')"> // Page content goes here </page-section> </b-container> </template> <script> -import PageTitle from '@/components/Global/PageTitle'; -import PageSection from '@/components/Global/PageSection'; +import PageTitle from "@/components/Global/PageTitle"; +import PageSection from "@/components/Global/PageSection"; export default { - name: 'PageName', - components: { PageTitle, PageSection } + name: "PageName", + components: { PageTitle, PageSection }, }; </script> <style lang="scss" scoped> - .example-class { - /* Styles go here */ - } - </style> -```
\ No newline at end of file +.example-class { + /* Styles go here */ +} +</style> +``` diff --git a/docs/guide/quickstart/store-anatomy.md b/docs/guide/quickstart/store-anatomy.md index 3ad5694f..a01ddb64 100644 --- a/docs/guide/quickstart/store-anatomy.md +++ b/docs/guide/quickstart/store-anatomy.md @@ -2,8 +2,8 @@ ## Store -A "store" is a container that holds the application's state. [Learn more about -Vuex.](https://vuex.vuejs.org/) +A "store" is a container that holds the application's state. +[Learn more about Vuex.](https://vuex.vuejs.org/) ```sh # Store structure @@ -26,26 +26,26 @@ bloated. Each module contains its own state, mutations, actions, and getters. #### Module Anatomy -- **State:** You cannot directly mutate the store's state. [Learn more about - state.](https://vuex.vuejs.org/guide/state.html) +- **State:** You cannot directly mutate the store's state. + [Learn more about state.](https://vuex.vuejs.org/guide/state.html) - **Getters:** Getters are used to compute derived state based on store state. [Learn more about getters.](https://vuex.vuejs.org/guide/getters.html) - **Mutations:** The only way to mutate the state is by committing mutations, - which are synchronous transactions. [Learn more about - mutations.](https://vuex.vuejs.org/guide/mutations.html) + which are synchronous transactions. + [Learn more about mutations.](https://vuex.vuejs.org/guide/mutations.html) - **Actions:** Asynchronous logic should be encapsulated in, and can be composed - with actions. [Learn more about - actions.](https://vuex.vuejs.org/guide/actions.html) + with actions. + [Learn more about actions.](https://vuex.vuejs.org/guide/actions.html) Import new store modules in `src/store/index.js`. ```js // `src/store/index.js` -import Vue from 'vue'; -import Vuex from 'vuex'; +import Vue from "vue"; +import Vuex from "vuex"; -import FeatureNameStore from './modules/FeatureNameStore'; +import FeatureNameStore from "./modules/FeatureNameStore"; Vue.use(Vuex); @@ -64,42 +64,42 @@ export default new Vuex.Store({ A store module will look like this. ```js -import api from '@/store/api'; -import i18n from '@/i18n'; +import api from "@/store/api"; +import i18n from "@/i18n"; const FeatureNameStore = { // getters, actions, and mutations will be namespaced // based on the path the module is registered at namespaced: true, state: { - exampleValue: 'Off', + exampleValue: "Off", }, getters: { // namespace -> getters['featureNameStore/getExampleValue'] - getExampleValue: state => state.exampleValue, + getExampleValue: (state) => state.exampleValue, }, mutations: { // namespace -> commit('featureNameStore/setExampleValue) - setExampleValue: state => state.exampleValue, + setExampleValue: (state) => state.exampleValue, }, actions: { // namespace -> dispatch('featureNameStore/getExampleValue') async getExampleValue({ commit }) { return await api - .get('/redfish/v1/../..') - .then(response => { - commit('setExampleValue', response.data.Value); + .get("/redfish/v1/../..") + .then((response) => { + commit("setExampleValue", response.data.Value); }) - .catch(error => console.log(error)); + .catch((error) => console.log(error)); }, // namespace -> ('featureNameStore/saveExampleValue', payload) async saveExampleValue({ commit }, payload) { return await api - .patch('/redfish/v1/../..', { Value: payload }) + .patch("/redfish/v1/../..", { Value: payload }) .then(() => { - commit('setExampleValue', payload); + commit("setExampleValue", payload); }) - .catch(error => { + .catch((error) => { console.log(error); }); }, |